PINA
PINA copied to clipboard
.cpu() method for LabelTensor
When I perform some computations with LabelTensor I may obtain another LabelTensor without labels, and I found that, if I use .cpu() it does not work because at some points it needs to take out the labels and it finds none of them. While if I give any name to that LabelTensor, it works with no problems.
Maybe there could be a way of avoiding this error?
Hi! Can you provide extra context with a snippet of code? I experimented locally and I did not see any issue with labels
>>> from pina import LabelTensor
>>> import torch
>>>
>>> x_cpu = LabelTensor(torch.rand(3,1), ['x'])
>>> print(x_cpu.labels, x_cpu.device)
['x'] cpu
>>>
>>> x_gpu = x_cpu.to('mps') # should be the same with .cuda() if you have torch compiled with cuda
>>> print(x_gpu.labels, x_gpu.device)
['x'] mps:0
>>>
>>> x_cpu_back = x_gpu.cpu()
>>> print(x_cpu_back.labels, x_cpu_back.device)
['x'] cpu
Hi @luAndre00 ! Do you still face the issue?