unilab.utils

unilab.utils.get_default_device()[source]

Detect the best available device.

Return type:

str

unilab.utils.to_numpy(x)[source]

Convert torch tensor or numpy-like input to numpy.

Return type:

ndarray

unilab.utils.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

Modules

device

nan_guard

NaN/Inf guard for env-layer numerical anomaly detection and state dumping.

support_matrix

Generate backend support matrix content from registry, configs, and tests.

tensor

Generic array <-> torch conversion utilities.