tfe_tensor_f64_from_dlpack

Function tfe_tensor_f64_from_dlpack 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tfe_tensor_f64_from_dlpack( _managed: *mut DLManagedTensorVersioned, _status: *mut tfe_status_t, ) -> *mut TfeTensorF64
Expand description

Import a DLPack managed tensor as a tenferro tensor (zero-copy).

Takes ownership of the DLManagedTensorVersioned. The deleter callback will be called when the returned tensor is released via tfe_tensor_f64_release.

The tensor data is NOT copied. The returned tensor references the same memory as the DLPack tensor.

Currently only kDLCPU device and float64 dtype are accepted (POC phase). Returns NULL with TFE_INVALID_ARGUMENT for other device types or dtypes.

§Safety

  • managed must be a valid pointer to a DLManagedTensorVersioned.
  • The DLPack tensor’s data must remain valid until the deleter is called.
  • status must be a valid, non-null pointer.

§Examples (C)

// Obtain DLManagedTensorVersioned* from Julia/Python
DLManagedTensorVersioned *dl = /* ... */;

tfe_status_t status;
tfe_tensor_f64 *t = tfe_tensor_f64_from_dlpack(dl, &status);
// dl is now owned by t — do NOT call dl->deleter(dl)

// Use t in einsum, SVD, etc.
tfe_tensor_f64_release(t); // calls DLPack deleter internally