unilab.utils.tensor.to_torch

unilab.utils.tensor.to_torch(x, device)[source]

Convert numpy-like input to torch on the target device.

Supports torch tensors, numpy arrays, and any array exposing __dlpack__.

Parameters:

device (str | device)

Return type:

Tensor