pub struct Tensor(/* private fields */);
Implementations§
source§impl Tensor
impl Tensor
pub fn new( backend: impl Into<Box<dyn Backend>>, dtype: DType, shape: impl Shape, primitive: impl Into<Box<dyn Primitive>>, inputs: impl Into<Vec<Tensor>> ) -> Self
pub fn id(&self) -> usize
pub fn backend(&self) -> &dyn Backend
pub fn dtype(&self) -> DType
pub fn shape(&self) -> impl Shape + '_
pub fn primitive(&self) -> &dyn Primitive
pub fn inputs(&self) -> impl Deref<Target = [Tensor]> + '_
pub fn full( val: f64, shape: impl Shape, dtype: DType, backend: impl Into<Box<dyn Backend>> + Debug ) -> Tensor
pub fn ones( shape: impl Shape, dtype: DType, backend: impl Into<Box<dyn Backend>> + Debug ) -> Tensor
pub fn zeros( shape: impl Shape, dtype: DType, backend: impl Into<Box<dyn Backend>> + Debug ) -> Tensor
pub fn full_like(&self, val: f64) -> Tensor
pub fn zeros_like(&self) -> Tensor
pub fn ones_like(&self) -> Tensor
pub fn normal( shape: impl Shape, dtype: DType, backend: impl Into<Box<dyn Backend>> + Debug ) -> Tensor
pub fn arange<T: ArangeArgs>( args: T, backend: impl Into<Box<dyn Backend>> + Debug ) -> Tensor
pub fn matmul<T: AsRef<Tensor>>(&self, rhs: T) -> Tensor
pub fn t(&self) -> Tensor
pub fn transpose(&self, axes: impl Into<Vec<usize>> + Debug) -> Tensor
pub fn broadcast_to(&self, shape: impl Shape) -> Tensor
pub fn reshape(&self, shape: impl Shape) -> Tensor
pub fn add<T>(&self, rhs: T) -> Tensor
pub fn mul<T>(&self, rhs: T) -> Tensor
pub fn sin(&self) -> Tensor
pub fn cos(&self) -> Tensor
pub fn square(&self) -> Tensor
pub fn sqrt(&self) -> Tensor
pub fn rsqrt(&self) -> Tensor
pub fn sign(&self) -> Tensor
pub fn abs(&self) -> Tensor
pub fn exp(&self) -> Tensor
pub fn sum(&self) -> Tensor
pub fn reduce_sum<T: ReduceSumArgs>(&self, args: T) -> Tensor
pub fn jvp(&self, tangent_cache: &mut HashMap<usize, Tensor>) -> Tensor
pub fn vjp(&self, cotangent_cache: &mut HashMap<usize, Tensor>)
pub fn dot_graph(&self) -> String
pub fn detach(&self)
pub fn set_data<T: TensorLike + 'static>(&self, data: T)
pub fn get_data<T>(&self) -> Option<impl Deref<Target = T> + '_>where
T: 'static,
pub fn is_evalualted(&self) -> bool
Trait Implementations§
source§impl Ord for Tensor
impl Ord for Tensor
source§impl PartialEq for Tensor
impl PartialEq for Tensor
source§impl PartialOrd for Tensor
impl PartialOrd for Tensor
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Shape for &Tensor
impl Shape for &Tensor
fn dims(&self) -> &[usize]
fn ndim(&self) -> usize
fn size(&self) -> usize
fn to_vec(&self) -> Vec<usize>
fn shape_transpose(&self) -> Vec<usize>
fn shape_at(&self, index: usize) -> usizewhere
Self: Sized,
fn shape_eq(&self, rhs: &impl Shape) -> boolwhere
Self: Sized,
fn shape_ndim_eq(&self, rhs: &impl Shape) -> boolwhere
Self: Sized,
fn shape_size_eq(&self, rhs: &impl Shape) -> boolwhere
Self: Sized,
fn shape_broadcast(&self, rhs: &impl Shape) -> Result<Vec<usize>>where
Self: Sized,
fn shape_broadcast_matmul(&self, rhs: &impl Shape) -> Result<Vec<usize>>where
Self: Sized,
source§impl Shape for Tensor
impl Shape for Tensor
fn dims(&self) -> &[usize]
fn ndim(&self) -> usize
fn size(&self) -> usize
fn to_vec(&self) -> Vec<usize>
fn shape_transpose(&self) -> Vec<usize>
fn shape_at(&self, index: usize) -> usizewhere
Self: Sized,
fn shape_eq(&self, rhs: &impl Shape) -> boolwhere
Self: Sized,
fn shape_ndim_eq(&self, rhs: &impl Shape) -> boolwhere
Self: Sized,
fn shape_size_eq(&self, rhs: &impl Shape) -> boolwhere
Self: Sized,
fn shape_broadcast(&self, rhs: &impl Shape) -> Result<Vec<usize>>where
Self: Sized,
fn shape_broadcast_matmul(&self, rhs: &impl Shape) -> Result<Vec<usize>>where
Self: Sized,
source§impl TensorIter for &Tensor
impl TensorIter for &Tensor
fn tensor_iter(&self) -> impl Iterator<Item = &Tensor>
source§impl TensorIter for Tensor
impl TensorIter for Tensor
fn tensor_iter(&self) -> impl Iterator<Item = &Tensor>
impl Eq for Tensor
Auto Trait Implementations§
impl !RefUnwindSafe for Tensor
impl !Send for Tensor
impl !Sync for Tensor
impl Unpin for Tensor
impl !UnwindSafe for Tensor
Blanket Implementations§
§impl<'short, T, Target> AsGeneralizedRef<'short, &'short Target> for T
impl<'short, T, Target> AsGeneralizedRef<'short, &'short Target> for T
fn as_generalized_ref(&'short self) -> &'short Target
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