pub struct TensorInfo {
pub data: *mut c_void,
pub device: DLDevice,
pub dtype: DLDataType,
pub shape: Vec<i64>,
pub strides: Option<Vec<i64>>,
pub byte_offset: u64,
}Expand description
Information about a tensor for DLPack export.
This struct holds all the metadata needed to create a DLPack tensor.
Use this with into_dlpack_with_info for explicit control over
tensor properties.
Fields§
§data: *mut c_voidRaw data pointer (device pointer for GPU tensors)
device: DLDeviceDevice descriptor
dtype: DLDataTypeData type descriptor
shape: Vec<i64>Shape (dimensions)
strides: Option<Vec<i64>>Strides in elements (None for contiguous)
byte_offset: u64Byte offset from data pointer
Implementations§
Source§impl TensorInfo
impl TensorInfo
Sourcepub fn contiguous(
data: *mut c_void,
device: DLDevice,
dtype: DLDataType,
shape: Vec<i64>,
) -> Self
pub fn contiguous( data: *mut c_void, device: DLDevice, dtype: DLDataType, shape: Vec<i64>, ) -> Self
Create tensor info for a contiguous tensor.
Sourcepub fn strided(
data: *mut c_void,
device: DLDevice,
dtype: DLDataType,
shape: Vec<i64>,
strides: Vec<i64>,
) -> Self
pub fn strided( data: *mut c_void, device: DLDevice, dtype: DLDataType, shape: Vec<i64>, strides: Vec<i64>, ) -> Self
Create tensor info with explicit strides.
§Panics
Panics if strides.len() != shape.len(). This invariant is required by
DLPack consumers which will read strides[i] for each dimension i.
Sourcepub fn with_byte_offset(self, offset: u64) -> Self
pub fn with_byte_offset(self, offset: u64) -> Self
Set the byte offset.
Trait Implementations§
Source§impl Clone for TensorInfo
impl Clone for TensorInfo
Source§fn clone(&self) -> TensorInfo
fn clone(&self) -> TensorInfo
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TensorInfo
impl RefUnwindSafe for TensorInfo
impl !Send for TensorInfo
impl !Sync for TensorInfo
impl Unpin for TensorInfo
impl UnwindSafe for TensorInfo
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