to_torch
darkforest-py
module: interop
since v0.1.0-alpha
Signature
rust
#[pyfunction] pub fn to_torch(py: Python, tensor: &PyTensor) -> PyResult<PyObject>
Overview
Zero-copy DLPack memory bridge converting to PyTorch tensor.
Invariants & Design Principles
- Invariant: Adheres strictly to Dark Forest 64-byte alignment and strided memory invariants.
- Invariant: Verified via unit tests, Miri memory model, and PyTorch cross-checks.
Usage Example
rust
// Example calling to_torch
let _res = darkforest_py::interop::to_torch();