pub struct Tensor {
pub shape: Vec<usize>,
pub dtype: DataType,
pub device: Device,
pub data: TensorData,
pub strides: Vec<usize>,
}Expand description
Tensor structure with real data storage
Fields§
§shape: Vec<usize>§dtype: DataType§device: Device§data: TensorData§strides: Vec<usize>Implementations§
Source§impl Tensor
impl Tensor
pub fn new(shape: Vec<usize>, dtype: DataType, device: Device) -> Self
pub fn zeros(shape: &[usize]) -> Self
pub fn ones(shape: &[usize]) -> Self
pub fn from_data(shape: Vec<usize>, data: TensorData, device: Device) -> Self
pub fn numel(&self) -> usize
pub fn size_bytes(&self) -> usize
pub fn index_select(&self, _dim: usize, _indices: &Tensor) -> Result<Tensor>
pub fn matmul(&self, other: &Tensor) -> Result<Tensor>
pub fn add(&self, other: &Tensor) -> Result<Tensor>
pub fn arange(start: i64, end: i64) -> Self
pub fn layer_norm(&self, _weight: &Tensor) -> Result<Tensor>
pub fn gelu(&self) -> Result<Tensor>
pub fn tanh(&self) -> Result<Tensor>
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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