pub struct TensorRef {
pub ptr: u64,
pub shape: Vec<usize>,
pub strides: Vec<usize>,
pub dtype: DType,
}Expand description
2026-09-25: A non-owning reference to a device tensor: a raw pointer plus shape, strides and element type. It neither allocates nor frees.
Fields§
§ptr: u64§shape: Vec<usize>§strides: Vec<usize>2026-09-25: Strides in elements, not bytes.
dtype: DTypeImplementations§
Source§impl TensorRef
impl TensorRef
Sourcepub fn new(ptr: u64, shape: Vec<usize>, dtype: DType) -> Self
pub fn new(ptr: u64, shape: Vec<usize>, dtype: DType) -> Self
2026-09-25: Create a tensor reference with contiguous row-major strides.
pub fn numel(&self) -> usize
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
2026-09-25: Total size in bytes, rounded up for sub-byte element types.
pub fn ndim(&self) -> usize
pub fn as_device_ptr<T>(&self) -> *const T
pub fn as_device_ptr_mut<T>(&self) -> *mut T
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TensorRef
impl RefUnwindSafe for TensorRef
impl Send for TensorRef
impl Sync for TensorRef
impl Unpin for TensorRef
impl UnwindSafe for TensorRef
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