warp.from_torch#
- warp.from_torch(
- t,
- dtype=None,
- requires_grad=None,
- grad=None,
- return_ctype=False,
Convert a Torch tensor to a Warp array without copying the data.
- Parameters:
t (torch.Tensor) – The torch tensor to wrap.
dtype (warp.DType | None) – The target data type of the resulting Warp array. Defaults to the tensor value type mapped to a Warp array value type.
requires_grad (bool | None) – Whether the resulting array should wrap the tensor’s gradient, if it exists (the grad tensor will be allocated otherwise). Defaults to the tensor’s
requires_gradvalue.grad – Optional gradient array to attach to the result. Can be a Warp array or Torch tensor. If not provided and
requires_gradis True, the tensor’s gradient will be wrapped or allocated.return_ctype (bool) – Whether to return a low-level array descriptor instead of a
wp.arrayobject (faster). The descriptor can be passed to Warp kernels.
- Returns:
The wrapped array or array descriptor.
- Return type:
warp.array | warp._src.types.array_t