pub struct Tensor {
pub id: TensorId,
pub name: Option<String>,
pub data: Buffer,
pub shape: Shape,
pub device: Device,
pub dtype: DType,
pub requires_grad: bool,
}Expand description
The core Tensor struct.
Strictly acts as a metadata wrapper. It points to a physical memory Buffer
and maps it using a geometric Shape. It contains NO recursive graph pointers.
Fields§
§id: TensorIdThe globally unique token used by the Tape to track gradients.
name: Option<String>An optional string for explainability (e.g., “layer_1_weights”).
data: BufferThe physical memory container (wrapped in Arc for zero-copy sharing).
shape: ShapeThe geometric layout and memory strides.
device: DeviceThe hardware context where the physical memory resides.
dtype: DTypeThe precision format of the memory buffer.
requires_grad: boolFlag indicating whether the Autograd engine should track this tensor.
Implementations§
Source§impl Tensor
impl Tensor
Sourcepub fn new(
data: Buffer,
shape: Shape,
device: Device,
dtype: DType,
requires_grad: bool,
) -> Self
pub fn new( data: Buffer, shape: Shape, device: Device, dtype: DType, requires_grad: bool, ) -> Self
Constructs a new Tensor from raw components.
Automatically assigns a new unique TensorId.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tensor
impl RefUnwindSafe for Tensor
impl Send for Tensor
impl Sync for Tensor
impl Unpin for Tensor
impl UnsafeUnpin for Tensor
impl UnwindSafe for Tensor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more