tfe_tensor_f64_to_dlpack

Function tfe_tensor_f64_to_dlpack 

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

Export a tensor as a DLPack managed tensor (zero-copy).

The tensor handle is consumed by this call and must not be used afterwards (do not call tfe_tensor_f64_release on it).

The returned DLManagedTensorVersioned must be consumed by the caller (e.g., passed to Julia DLPack.from_dlpack() or Python numpy.from_dlpack()). The consumer must call the deleter callback when done with the data.

If the tensor is NULL, returns NULL and sets status to TFE_INVALID_ARGUMENT.

§Safety

  • tensor must be a valid tensor pointer or NULL.
  • status must be a valid, non-null pointer.

§Examples (C)

tfe_status_t status;
tfe_tensor_f64 *t = tfe_tensor_f64_zeros(shape, 2, &status);

// Export to DLPack (tensor handle is consumed)
DLManagedTensorVersioned *dl = tfe_tensor_f64_to_dlpack(t, &status);
// t is now invalid — do NOT call tfe_tensor_f64_release(t)

// Pass dl to Julia/Python, which calls dl->deleter(dl) when done