pub fn from_dlpack(
_py: Python<'_>,
capsule: &Bound<'_, PyAny>,
) -> PyResult<Py<PyAny>>Expand description
Convert a DLPack capsule (from PyTorch, JAX, CuPy, TensorFlow, …) into a scirs2 NumPy-compatible array.
§Parameters
capsule : PyCapsule
A PyCapsule object whose name is "dltensor". Anything that
implements __dlpack__() can produce such an object.
§Returns
array-like A zero-copy view (when the device is CPU) as a NumPy array.
§Notes
The full zero-copy path is exercised when capsule comes from a
CPU-resident tensor. GPU tensors raise NotImplementedError until
the optional gpu feature is enabled.