pub struct TensorRef {
pub ptr: u64,
pub shape: Vec<usize>,
pub strides: Vec<usize>,
pub dtype: DType,
}Expand description
A zero-copy reference to a GPU tensor, typically from PyTorch via data_ptr().
Atlas never allocates or copies tensor data — it receives raw CUDA device pointers from Python and wraps them for kernel launches.
Fields§
§ptr: u64Raw CUDA device pointer (from torch.Tensor.data_ptr())
shape: Vec<usize>Shape dimensions (e.g., [batch, seq_len, hidden_size])
strides: Vec<usize>Strides in elements (not bytes)
dtype: DTypeElement data type
Implementations§
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
Create a new tensor reference from a raw pointer and shape. Assumes contiguous (row-major) layout.
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Total size in bytes.
Sourcepub fn as_device_ptr<T>(&self) -> *const T
pub fn as_device_ptr<T>(&self) -> *const T
Raw pointer cast to a typed device pointer (for kernel launches).
Sourcepub fn as_device_ptr_mut<T>(&self) -> *mut T
pub fn as_device_ptr_mut<T>(&self) -> *mut T
Mutable raw pointer cast.
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