pub unsafe fn dlarray_from_torch_f32<'a>(
tensor: *const DLTensor,
) -> Result<ArrayViewD<'a, f32>, DlpackError>Expand description
Convert a raw DLTensor pointer (from a PyTorch DLPack capsule) to an
ndarray dynamic array view of f32 elements.
§Safety
The caller must guarantee that:
tensoris a valid, aligned, non-null pointer to aDLTensor.- The tensor’s
datafield points to at leastproduct(shape) * 4valid bytes off32values in native byte order. - The tensor (and its data) remains live and unmodified for the lifetime
of the returned view
'a.
§Errors
Returns DlpackError if the tensor is not a 32-bit float CPU tensor.