pub struct DLPackTensor { /* private fields */ }Expand description
Opaque handle to a DLPack DLManagedTensor.
This is a GPU tensor representation used for zero-copy exchange with frameworks like PyTorch and CuPy.
§Requirements
- All columns must have the same numeric data type.
- Null count must be zero for all columns.
Implementations§
Source§impl DLPackTensor
impl DLPackTensor
Sourcepub fn from_table(table: &Table) -> Result<Self>
pub fn from_table(table: &Table) -> Result<Self>
Convert a table to a DLPack tensor.
§Errors
Returns an error if columns have different types, non-numeric types, or non-zero null counts.
Sourcepub fn to_table(self) -> Result<Table>
pub fn to_table(self) -> Result<Table>
Import a table from this DLPack tensor, consuming the tensor.
Sourcepub fn as_raw_ptr(&self) -> usize
pub fn as_raw_ptr(&self) -> usize
Get the raw DLManagedTensor* pointer as usize.
This is useful for passing to Python / C frameworks. The caller must NOT free the tensor; it is still owned by this handle.
Sourcepub unsafe fn from_raw_ptr(ptr: usize) -> Self
pub unsafe fn from_raw_ptr(ptr: usize) -> Self
Create from a raw DLManagedTensor* pointer.
§Safety
The pointer must be a valid DLManagedTensor* with a working deleter.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DLPackTensor
impl RefUnwindSafe for DLPackTensor
impl Send for DLPackTensor
impl Sync for DLPackTensor
impl Unpin for DLPackTensor
impl UnsafeUnpin for DLPackTensor
impl UnwindSafe for DLPackTensor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more