Struct dfdx::tensor::Tensor

source ·
pub struct Tensor<S: Shape, E: Unit, D: DeviceStorage, T = NoneTape> { /* private fields */ }
Expand description

The single tensor struct that stores nd arrays and tapes.

See module level documentation on how to create and use tensors.

Generics:

  1. Shape - the shape of the underlying nd array
  2. Dtype - the type of the datas stored in the array
  3. DeviceStorage - the device the array is stored on
  4. Tape - the tape the tensor has

Examples:

// A 1d tensor with 1000 f32 elements, stored on the Cpu
type A = Tensor<Rank1<1000>, f32, Cpu>;

// A 2d tensor with bool elements, stored on the Cpu
type B = Tensor<Rank2<2, 3>, bool, Cpu>;

// A 3d tensor with usize elements, stored on the Cpu, without any tape
type C = Tensor<Rank3<4, 2, 3>, usize, Cpu, NoneTape>;

Implementations§

source§

impl<S: Shape, E: Dtype + NumpyDtype, D: DeviceStorage + CopySlice<E>, T> Tensor<S, E, D, T>

source

pub fn write_to_npz<W: Write + Seek>( &self, w: &mut ZipWriter<W>, filename: String ) -> ZipResult<()>

Writes data to a new file in a zip archive named filename.

source

pub fn read_from_npz<R: Read + Seek>( &mut self, r: &mut ZipArchive<R>, filename: String ) -> Result<(), NpzError>

Reads data from a file already in a zip archive named filename.

source

pub fn load_from_npy<P: AsRef<Path>>(&mut self, path: P) -> Result<(), NpyError>

Attemps to load the data from a .npy file at path

source

pub fn save_to_npy<P: AsRef<Path>>(&self, path: P) -> Result<()>

Saves the tensor to a .npy file located at path

source§

impl<S: Shape, E: Dtype + SafeDtype, D: CopySlice<E>, T> Tensor<S, E, D, T>

source

pub fn load_safetensor( &mut self, tensors: &SafeTensors<'_>, key: &str ) -> Result<(), Error>

Loads data from the SafeTensors storage with the given key

source§

impl<S: Shape, E: Unit, D: CopySlice<E>, T> Tensor<S, E, D, T>

source

pub fn copy_from(&mut self, src: &[E])

Copy physical data from a slice - panics if there are not enough elements in the slice.

let data = [1.0, 2.0, 3.0, 4.0];
let mut t: Tensor<Rank2<2, 2>, f32, _> = dev.zeros();
t.copy_from(&data);
assert_eq!(t.array(), [[1.0, 2.0], [3.0, 4.0]]);
source

pub fn copy_into(&self, dst: &mut [E])

Copy physical data into a slice - panics if there are not enough elements in the tensor.

let t: Tensor<Rank2<2, 2>, f32, _> = dev.tensor([[1.0, 2.0], [3.0, 4.0]]);
let mut data = [0.0; 4];
t.copy_into(&mut data);
assert_eq!(data, [1.0, 2.0, 3.0, 4.0]);
source§

impl<S: Shape, E: Unit, D: DeviceStorage, T> Tensor<S, E, D, T>

source

pub fn as_vec(&self) -> Vec<E>

source§

impl<S: Shape, E: Unit, D: DeviceStorage, T> Tensor<S, E, D, T>

source

pub fn retaped<New: Tape<E, D>>(&self) -> Tensor<S, E, D, New>

Clone and insert a new tape of type New into the tensor

source§

impl<S: Shape, E: Dtype, D: ZeroFillStorage<E>, T> Tensor<S, E, D, T>

source

pub fn fill_with_zeros(&mut self)

Fills the tensor with zeros

source

pub fn try_fill_with_zeros(&mut self) -> Result<(), D::Err>

Fallible version of Tensor::fill_with_zeros

source§

impl<S: Shape, E: Dtype, D: OneFillStorage<E>, T> Tensor<S, E, D, T>

source

pub fn fill_with_ones(&mut self)

Fills the tensor with ones

source

pub fn try_fill_with_ones(&mut self) -> Result<(), D::Err>

Fallible version of Tensor::fill_with_ones

source§

impl<S: Shape, E: Unit, D: SampleTensor<E>, T> Tensor<S, E, D, T>

source

pub fn fill_with_distr<Distr: Distribution<E>>(&mut self, distr: Distr)

Fills the tensor with random data from the distribution

source

pub fn try_fill_with_distr<Distr: Distribution<E>>( &mut self, distr: Distr ) -> Result<(), D::Err>

Fallible version of Tensor::fill_with_distr

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<AbsKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn abs(self) -> Self

See abs

source

pub fn try_abs(self) -> Result<Self, D::Err>

See abs

source§

impl<S: Shape, E: Unit, D: AxpyKernel<E>> Tensor<S, E, D>

source

pub fn axpy<T>(&mut self, alpha: E, b: &Tensor<S, E, D, T>, beta: E)

Updates self with elementwise function self = self * alpha + b * beta.

source

pub fn try_axpy<T>( &mut self, alpha: E, b: &Tensor<S, E, D, T>, beta: E ) -> Result<(), D::Err>

Updates self with elementwise function self = self * alpha + b * beta.

source§

impl<S: Shape, E: Dtype, D: BinaryKernel<BCEKernelOp, E>, LTape: Tape<E, D>> Tensor<S, E, D, LTape>

source

pub fn bce_with_logits<RTape: Tape<E, D>>( self, prob: Tensor<S, E, D, RTape> ) -> Selfwhere LTape: Merge<RTape>,

source

pub fn try_bce_with_logits<RTape>( self, prob: Tensor<S, E, D, RTape> ) -> Result<Self, D::Err>where RTape: Tape<E, D>, LTape: Merge<RTape>,

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<ClampKernelOp<E>, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn clamp(self, min: E, max: E) -> Self

See clamp

source

pub fn try_clamp(self, min: E, max: E) -> Result<Self, D::Err>

See clamp

source§

impl<S: Shape, E: Unit, D: CmpKernel<EqKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_eq( &self, other: &Self ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See eq

source

pub fn eq(&self, other: &Self) -> Tensor<S, bool, D, NoneTape>

See eq

source§

impl<S: Shape, E: Unit, D: ScalarCmpKernel<EqKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_scalar_eq( &self, scalar: E ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See eq

source

pub fn scalar_eq(&self, scalar: E) -> Tensor<S, bool, D, NoneTape>

See eq

source§

impl<S: Shape, E: Unit, D: CmpKernel<NeKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_ne( &self, other: &Self ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See ne

source

pub fn ne(&self, other: &Self) -> Tensor<S, bool, D, NoneTape>

See ne

source§

impl<S: Shape, E: Unit, D: ScalarCmpKernel<NeKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_scalar_ne( &self, scalar: E ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See ne

source

pub fn scalar_ne(&self, scalar: E) -> Tensor<S, bool, D, NoneTape>

See ne

source§

impl<S: Shape, E: Unit, D: CmpKernel<GtKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_gt( &self, other: &Self ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See gt

source

pub fn gt(&self, other: &Self) -> Tensor<S, bool, D, NoneTape>

See gt

source§

impl<S: Shape, E: Unit, D: ScalarCmpKernel<GtKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_scalar_gt( &self, scalar: E ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See gt

source

pub fn scalar_gt(&self, scalar: E) -> Tensor<S, bool, D, NoneTape>

See gt

source§

impl<S: Shape, E: Unit, D: CmpKernel<GeKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_ge( &self, other: &Self ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See ge

source

pub fn ge(&self, other: &Self) -> Tensor<S, bool, D, NoneTape>

See ge

source§

impl<S: Shape, E: Unit, D: ScalarCmpKernel<GeKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_scalar_ge( &self, scalar: E ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See ge

source

pub fn scalar_ge(&self, scalar: E) -> Tensor<S, bool, D, NoneTape>

See ge

source§

impl<S: Shape, E: Unit, D: CmpKernel<LtKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_lt( &self, other: &Self ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See lt

source

pub fn lt(&self, other: &Self) -> Tensor<S, bool, D, NoneTape>

See lt

source§

impl<S: Shape, E: Unit, D: ScalarCmpKernel<LtKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_scalar_lt( &self, scalar: E ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See lt

source

pub fn scalar_lt(&self, scalar: E) -> Tensor<S, bool, D, NoneTape>

See lt

source§

impl<S: Shape, E: Unit, D: CmpKernel<LeKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_le( &self, other: &Self ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See le

source

pub fn le(&self, other: &Self) -> Tensor<S, bool, D, NoneTape>

See le

source§

impl<S: Shape, E: Unit, D: ScalarCmpKernel<LeKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_scalar_le( &self, scalar: E ) -> Result<Tensor<S, bool, D, NoneTape>, D::Err>

See le

source

pub fn scalar_le(&self, scalar: E) -> Tensor<S, bool, D, NoneTape>

See le

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<CosKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn cos(self) -> Self

See cos

source

pub fn try_cos(self) -> Result<Self, D::Err>

See cos

source§

impl<S: Shape, E: Dtype, D: DropoutKernel<E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn dropout(self, prob: E) -> Self

See dropout

source

pub fn try_dropout(self, prob: E) -> Result<Self, D::Err>

See dropout

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<ExpKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn exp(self) -> Self

See exp

source

pub fn try_exp(self) -> Result<Self, D::Err>

See exp

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<GeLUKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn gelu(self) -> Self

See gelu

source

pub fn try_gelu(self) -> Result<Self, D::Err>

See gelu

source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn huber_error<R: Tape<E, D>>( self, rhs: Tensor<S, E, D, R>, delta: E ) -> Selfwhere T: Merge<R>,

source

pub fn try_huber_error<R: Tape<E, D>>( self, rhs: Tensor<S, E, D, R>, delta: E ) -> Result<Self, D::Err>where T: Merge<R>,

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<LnKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn ln(self) -> Self

See ln

source

pub fn try_ln(self) -> Result<Self, D::Err>

See ln

source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn log_softmax<Ax: Axes>(self) -> Selfwhere S: ReduceShape<Ax>,

source

pub fn try_log_softmax<Ax: Axes>(self) -> Result<Self, D::Err>where S: ReduceShape<Ax>,

source§

impl<S: Shape, E: Dtype, D: Device<E>, LTape: Tape<E, D>> Tensor<S, E, D, LTape>

source

pub fn maximum<R: Default>(self, rhs: Tensor<S, E, D, R>) -> Selfwhere LTape: Merge<R>,

See maximum

source

pub fn try_maximum<R: Default>( self, rhs: Tensor<S, E, D, R> ) -> Result<Self, D::Err>where LTape: Merge<R>,

See maximum

source§

impl<S: Shape, E: Dtype, D: Device<E>, LTape: Tape<E, D>> Tensor<S, E, D, LTape>

source

pub fn minimum<R: Default>(self, rhs: Tensor<S, E, D, R>) -> Selfwhere LTape: Merge<R>,

See minimum

source

pub fn try_minimum<R: Default>( self, rhs: Tensor<S, E, D, R> ) -> Result<Self, D::Err>where LTape: Merge<R>,

See minimum

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<NansToKernelOp<E>, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn nans_to(self, value: E) -> Self

See nans_to

source

pub fn try_nans_to(self, value: E) -> Result<Self, D::Err>

See nans_to

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<NegateKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn negate(self) -> Self

source

pub fn try_negate(self) -> Result<Self, D::Err>

source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn normalize<Ax: Axes>(self, epsilon: E) -> Selfwhere S: ReduceShape<Ax>,

source

pub fn try_normalize<Ax: Axes>( self, epsilon: E ) -> Result<Self, <Self as HasErr>::Err>where S: ReduceShape<Ax>,

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<PowfKernelOp<E>, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn powf(self, exponent: E) -> Self

See powf

source

pub fn try_powf(self, exponent: E) -> Result<Self, D::Err>

See powf

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<PowiKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn powi(self, exponent: i32) -> Self

See powi

source

pub fn try_powi(self, exponent: i32) -> Result<Self, D::Err>

See powi

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<ReLUKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn relu(self) -> Self

See relu

source

pub fn try_relu(self) -> Result<Self, D::Err>

See relu

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<SigmoidKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn sigmoid(self) -> Self

See sigmoid

source

pub fn try_sigmoid(self) -> Result<Self, D::Err>

See sigmoid

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<SinKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn sin(self) -> Self

See sin

source

pub fn try_sin(self) -> Result<Self, D::Err>

See sin

source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn softmax<Ax: Axes>(self) -> Selfwhere S: ReduceShape<Ax>,

See softmax

source

pub fn try_softmax<Ax: Axes>(self) -> Result<Self, D::Err>where S: ReduceShape<Ax>,

See softmax

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<SqrtKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn sqrt(self) -> Self

See sqrt

source

pub fn try_sqrt(self) -> Result<Self, D::Err>

See sqrt

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<SquareKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn square(self) -> Self

See square

source

pub fn try_square(self) -> Result<Self, D::Err>

See square

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<TanhKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn tanh(self) -> Self

See tanh

source

pub fn try_tanh(self) -> Result<Self, D::Err>

See tanh

Trait Implementations§

source§

impl<S: Shape, E: Dtype, D: DeviceStorage, LhsTape: Tape<E, D>, Rhs> Add<Rhs> for Tensor<S, E, D, LhsTape>where Self: TryAdd<Rhs>,

source§

fn add(self, rhs: Rhs) -> Self::Output

See add

§

type Output = Tensor<S, E, D, LhsTape>

The resulting type after applying the + operator.
source§

impl<S: Shape, E: Unit, D: TensorToArray<S, E>, T> AsArray for Tensor<S, E, D, T>

source§

fn array(&self) -> Self::Array

Convert tensors to rust arrays

§

type Array = <D as TensorToArray<S, E>>::Array

source§

impl<E: Dtype, D: OneFillStorage<E>> Backward<E, D> for Tensor<Rank0, E, D, OwnedTape<E, D>>

source§

fn try_backward(self) -> Result<Gradients<E, D>, Self::Err>

Fallible version of Backward::backward
source§

fn backward(self) -> Gradients<E, D>

Runs backprop
source§

impl<S: Shape, D: BooleanKernel> BitAnd<&Tensor<S, bool, D, NoneTape>> for &Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
source§

impl<S: Shape, D: BooleanKernel> BitAnd<Tensor<S, bool, D, NoneTape>> for Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self

Performs the & operation. Read more
source§

impl<S: Shape, D: BooleanKernel> BitAnd<bool> for &Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: bool) -> Self::Output

Performs the & operation. Read more
source§

impl<S: Shape, D: BooleanKernel> BitAnd<bool> for Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: bool) -> Self

Performs the & operation. Read more
source§

impl<S: Shape, D: BooleanKernel> BitOr<&Tensor<S, bool, D, NoneTape>> for &Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
source§

impl<S: Shape, D: BooleanKernel> BitOr<Tensor<S, bool, D, NoneTape>> for Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
source§

impl<S: Shape, D: BooleanKernel> BitOr<bool> for &Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: bool) -> Self::Output

Performs the | operation. Read more
source§

impl<S: Shape, D: BooleanKernel> BitOr<bool> for Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: bool) -> Self

Performs the | operation. Read more
source§

impl<S: Shape, D: BooleanKernel> BitXor<&Tensor<S, bool, D, NoneTape>> for &Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
source§

impl<S: Shape, D: BooleanKernel> BitXor<Tensor<S, bool, D, NoneTape>> for Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Self) -> Self

Performs the ^ operation. Read more
source§

impl<S: Shape, D: BooleanKernel> BitXor<bool> for &Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: bool) -> Self::Output

Performs the ^ operation. Read more
source§

impl<S: Shape, D: BooleanKernel> BitXor<bool> for Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: bool) -> Self

Performs the ^ operation. Read more
source§

impl<S: Shape, E: Unit, D: DeviceStorage, T: Tape<E, D>> BroadcastTo for Tensor<S, E, D, T>

source§

fn try_broadcast_like<Dst: Shape, Ax: Axes>( self, dst: &Dst ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: BroadcastShapeTo<Dst, Ax>,

fallible version of BroadcastTo::broadcast_like
source§

fn broadcast<Dst: ConstShape, Ax: Axes>(self) -> Self::WithShape<Dst>where Self::Shape: BroadcastShapeTo<Dst, Ax>,

Broadcast into shape Dst along axes Ax: Read more
source§

fn try_broadcast<Dst: ConstShape, Ax: Axes>( self ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: BroadcastShapeTo<Dst, Ax>,

Fallible version of BroadcastTo::broadcast
source§

fn broadcast_like<Dst: Shape, Ax: Axes>(self, dst: &Dst) -> Self::WithShape<Dst>where Self::Shape: BroadcastShapeTo<Dst, Ax>,

Same as BroadcastTo::broadcast, but the target shape is given
source§

impl<S: Shape, E: Dtype, D: ChooseKernel<E>, LhsTape: Tape<E, D> + Merge<RhsTape>, RhsTape: Tape<E, D>> ChooseFrom<Tensor<S, E, D, LhsTape>, Tensor<S, E, D, RhsTape>> for Tensor<S, bool, D>

§

type Output = Tensor<S, E, D, LhsTape>

source§

fn try_choose( self, lhs: Tensor<S, E, D, LhsTape>, rhs: Tensor<S, E, D, RhsTape> ) -> Result<Self::Output, Self::Err>

Fallible version of choose
source§

fn choose(self, lhs: Lhs, rhs: Rhs) -> Self::Output

Construct a new tensor, where the output tensor contains the elements of lhs where self is true, and rhs where self is false.
source§

impl<S: Clone + Shape, E: Clone + Unit, D: Clone + DeviceStorage, T: Clone> Clone for Tensor<S, E, D, T>where D::Vec<E>: Clone, S::Concrete: Clone,

source§

fn clone(&self) -> Tensor<S, E, D, T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S: Debug + Shape, E: Debug + Unit, D: Debug + DeviceStorage, T: Debug> Debug for Tensor<S, E, D, T>where D::Vec<E>: Debug, S::Concrete: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, LhsTape: Tape<E, D>, Rhs> Div<Rhs> for Tensor<S, E, D, LhsTape>where Self: TryDiv<Rhs>,

source§

fn div(self, rhs: Rhs) -> Self::Output

See div

§

type Output = Tensor<S, E, D, LhsTape>

The resulting type after applying the / operator.
source§

impl<Src: Shape, E: Dtype, D: ReplaceDimKernel<E>, T: Tape<E, D>> GatherTo<D> for Tensor<Src, E, D, T>

source§

fn try_gather<Dst: Shape, Idx: Shape>( self, idx: Tensor<Idx, usize, D> ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: ReplaceDimTo<Dst, Idx>,

source§

fn gather<Dst: Shape, Idx: Shape>( self, idx: Tensor<Idx, usize, D> ) -> Self::WithShape<Dst>where Self::Shape: ReplaceDimTo<Dst, Idx>,

Gather values given indices. Read more
source§

impl<S: Shape, E: Dtype, D: DeviceStorage, T> HasDtype for Tensor<S, E, D, T>

§

type Dtype = E

source§

impl<S: Shape, E: Unit, D: DeviceStorage, T> HasErr for Tensor<S, E, D, T>

§

type Err = <D as HasErr>::Err

source§

impl<S: Shape, E: Unit, D: DeviceStorage, T> HasShape for Tensor<S, E, D, T>

§

type WithShape<New: Shape> = Tensor<New, E, D, T>

§

type Shape = S

source§

fn shape(&self) -> &Self::Shape

source§

impl<S: Shape, E: Unit, D: DeviceStorage, T> HasUnitType for Tensor<S, E, D, T>

§

type Unit = E

source§

impl<S: Shape, E: Unit, T> Index<<S as Shape>::Concrete> for Tensor<S, E, Cpu, T>

§

type Output = E

The returned type after indexing.
source§

fn index(&self, index: S::Concrete) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<S: Shape, E: Unit, T> IndexMut<<S as Shape>::Concrete> for Tensor<S, E, Cpu, T>

source§

fn index_mut(&mut self, index: S::Concrete) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> LogSumExpTo for Tensor<S, E, D, T>

source§

fn try_logsumexp<Dst: Shape, Ax: Axes>( self ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: ReduceShapeTo<Dst, Ax>,

Fallible version of LogSumExpTo::logsumexp
source§

fn logsumexp<Dst: Shape, Ax: Axes>(self) -> Self::WithShape<Dst>where Self::Shape: ReduceShapeTo<Dst, Ax>,

LogSumExp reduction. Read more
source§

impl<S: Shape, E: Dtype, D: MaxReduceKernel<E>, T: Tape<E, D>> MaxTo for Tensor<S, E, D, T>

source§

fn try_max<Dst: Shape, Ax: Axes>( self ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: ReduceShapeTo<Dst, Ax>,

Fallible version of MaxTo::max
source§

fn max<Dst: Shape, Ax: Axes>(self) -> Self::WithShape<Dst>where Self::Shape: ReduceShapeTo<Dst, Ax>,

Max reduction. Pytorch equivalent: t.amax(Ax) Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> MeanTo for Tensor<S, E, D, T>

source§

fn try_mean<Dst: Shape, Ax: Axes>( self ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: HasAxes<Ax> + ReduceShapeTo<Dst, Ax>,

Fallible version of MeanTo::mean
source§

fn mean<Dst: Shape, Ax: Axes>(self) -> Self::WithShape<Dst>where Self::Shape: HasAxes<Ax> + ReduceShapeTo<Dst, Ax>,

Mean reduction. Pytorch equivalent: t.mean(Axes) Read more
source§

impl<S: Shape, E: Dtype, D: MinReduceKernel<E>, T: Tape<E, D>> MinTo for Tensor<S, E, D, T>

source§

fn try_min<Dst: Shape, Ax: Axes>( self ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: ReduceShapeTo<Dst, Ax>,

Fallible version of MinTo::min
source§

fn min<Dst: Shape, Ax: Axes>(self) -> Self::WithShape<Dst>where Self::Shape: ReduceShapeTo<Dst, Ax>,

Min reduction. Pytorch equivalent: t.amin(Ax) Read more
source§

impl<B: Dim, C: Dim, H: Dim, W: Dim, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(B, C, H, W), E, D, T>> for AvgPoolGlobal

§

type Output = Tensor<(B, C), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<(B, C, H, W), E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<B: Dim, C: Dim, H: Dim, W: Dim, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(B, C, H, W), E, D, T>> for MaxPoolGlobal

§

type Output = Tensor<(B, C), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<(B, C, H, W), E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<B: Dim, C: Dim, H: Dim, W: Dim, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(B, C, H, W), E, D, T>> for MinPoolGlobal

§

type Output = Tensor<(B, C), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<(B, C, H, W), E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<B: Dim, const C: usize, E: Dtype, D: Device<E>> Module<Tensor<(B, Const<C>), E, D, NoneTape>> for BatchNorm1D<C, E, D>

source§

fn try_forward( &self, x: Tensor<(B, Const<C>), E, D, NoneTape> ) -> Result<Self::Output, D::Err>

Inference 1d forward - does not update Self::running_mean and Self::running_var

§

type Output = Tensor<(B, Const<C>), E, D, NoneTape>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<B: Dim, const C: usize, H: Dim, W: Dim, E: Dtype, D: Device<E>> Module<Tensor<(B, Const<C>, H, W), E, D, NoneTape>> for BatchNorm2D<C, E, D>

source§

fn try_forward( &self, x: Tensor<(B, Const<C>, H, W), E, D, NoneTape> ) -> Result<Self::Output, D::Err>

Inference 4d forward - does not update Self::running_mean and Self::running_var

§

type Output = Tensor<(B, Const<C>, H, W), E, D, NoneTape>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<B: Dim, const C: usize, H: Dim, W: Dim, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(B, Const<C>, H, W), E, D, T>> for Bias2D<C, E, D>

§

type Output = Tensor<(B, Const<C>, H, W), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<(B, Const<C>, H, W), E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<B: Dim, const C: usize, L: Dim, E: Dtype, D: Device<E>> Module<Tensor<(B, Const<C>, L), E, D, NoneTape>> for BatchNorm1D<C, E, D>

source§

fn try_forward( &self, x: Tensor<(B, Const<C>, L), E, D, NoneTape> ) -> Result<Self::Output, D::Err>

Inference 2d forward - does not update Self::running_mean and Self::running_var

§

type Output = Tensor<(B, Const<C>, L), E, D, NoneTape>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<B: Dim, const M: usize, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(B, Const<M>), E, D, T>> for LayerNorm1D<M, E, D>

§

type Output = Tensor<(B, Const<M>), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, x: Tensor<(B, Const<M>), E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<B: Dim, S: Dim, const M: usize, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(B, S, Const<M>), E, D, T>> for LayerNorm1D<M, E, D>

§

type Output = Tensor<(B, S, Const<M>), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, x: Tensor<(B, S, Const<M>), E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<const VOCAB: usize, const DIM: usize, BATCH: Dim, SEQ: Dim, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(BATCH, SEQ), usize, D, T>> for Embedding<VOCAB, DIM, E, D>

§

type Output = Tensor<(BATCH, SEQ, Const<DIM>), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<(BATCH, SEQ), usize, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<C: Dim, H: Dim, W: Dim, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(C, H, W), E, D, T>> for AvgPoolGlobal

§

type Output = Tensor<(C,), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<(C, H, W), E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<C: Dim, H: Dim, W: Dim, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(C, H, W), E, D, T>> for MaxPoolGlobal

§

type Output = Tensor<(C,), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<(C, H, W), E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<C: Dim, H: Dim, W: Dim, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(C, H, W), E, D, T>> for MinPoolGlobal

§

type Output = Tensor<(C,), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<(C, H, W), E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<const B: usize, const C: usize, const H: usize, const W: usize, D, E: Dtype, T> Module<Tensor<(Const<B>, Const<C>, Const<H>, Const<W>), E, D, T>> for Flatten2Dwhere D: Device<E>, T: Tape<E, D>, Rank2<B, { _ }>: Sized,

§

type Output = Tensor<(Const<B>, Const<{ C * H * W }>), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<Rank4<B, C, H, W>, E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<const C: usize, const H: usize, const W: usize, D: Device<E>, E: Dtype, T: Tape<E, D>> Module<Tensor<(Const<C>, Const<H>, Const<W>), E, D, T>> for Flatten2Dwhere Rank1<{ _ }>: Sized,

§

type Output = Tensor<(Const<{ C * H * W }>,), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<Rank3<C, H, W>, E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<const C: usize, H: Dim, W: Dim, E: Dtype, D: Device<E>> Module<Tensor<(Const<C>, H, W), E, D, NoneTape>> for BatchNorm2D<C, E, D>

source§

fn try_forward( &self, x: Tensor<(Const<C>, H, W), E, D, NoneTape> ) -> Result<Self::Output, D::Err>

Inference 3d forward - does not update Self::running_mean and Self::running_var

§

type Output = Tensor<(Const<C>, H, W), E, D, NoneTape>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<const C: usize, H: Dim, W: Dim, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(Const<C>, H, W), E, D, T>> for Bias2D<C, E, D>

§

type Output = Tensor<(Const<C>, H, W), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<(Const<C>, H, W), E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<const M: usize, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(Const<M>,), E, D, T>> for LayerNorm1D<M, E, D>

§

type Output = Tensor<(Const<M>,), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, x: Tensor<Rank1<M>, E, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<const V: usize, const M: usize, SEQ: Dim, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(SEQ,), usize, D, T>> for Embedding<V, M, E, D>

§

type Output = Tensor<(SEQ, Const<M>), E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<(SEQ,), usize, D, T> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>> Module<Tensor<S, E, D, NoneTape>> for Dropout

source§

fn try_forward( &self, input: Tensor<S, E, D, NoneTape> ) -> Result<Self::Output, D::Err>

Does nothing.

§

type Output = Tensor<S, E, D, NoneTape>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<const N: usize, S: Shape, E: Dtype, D: Device<E>> Module<Tensor<S, E, D, NoneTape>> for DropoutOneIn<N>

§

type Error = <D as HasErr>::Err

Does nothing

§

type Output = Tensor<S, E, D, NoneTape>

The type that this unit produces given Input.
source§

fn try_forward( &self, input: Tensor<S, E, D, NoneTape> ) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for Abs

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for Cos

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for Exp

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for GeLU

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for Ln

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for ReLU

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for Sigmoid

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for Sin

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<Ax: Axes, S, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for Softmaxwhere S: Shape<LastAxis = Ax> + ReduceShape<Ax>,

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for Sqrt

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for Square

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for Tanh

§

type Output = Tensor<S, E, D, T>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward(&self, input: Tensor<S, E, D, T>) -> Result<Self::Output, D::Err>

source§

fn forward(&self, input: Input) -> Self::Output

Forward Input through the module and produce Module::Output. Read more
source§

impl<B: Dim, const C: usize, E: Dtype, D: Device<E>> ModuleMut<Tensor<(B, Const<C>), E, D, OwnedTape<E, D>>> for BatchNorm1D<C, E, D>

source§

fn try_forward_mut( &mut self, x: Tensor<(B, Const<C>), E, D, OwnedTape<E, D>> ) -> Result<Self::Output, D::Err>

Training 2d forward - updates Self::running_mean and Self::running_var

§

type Output = Tensor<(B, Const<C>), E, D, OwnedTape<E, D>>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn forward_mut(&mut self, input: Input) -> Self::Output

Forward Input through the module and produce ModuleMut::Output. Read more
source§

impl<B: Dim, const C: usize, H: Dim, W: Dim, E: Dtype, D: Device<E>> ModuleMut<Tensor<(B, Const<C>, H, W), E, D, OwnedTape<E, D>>> for BatchNorm2D<C, E, D>

source§

fn try_forward_mut( &mut self, x: Tensor<(B, Const<C>, H, W), E, D, OwnedTape<E, D>> ) -> Result<Self::Output, D::Err>

Training 4d forward - updates Self::running_mean and Self::running_var

§

type Output = Tensor<(B, Const<C>, H, W), E, D, OwnedTape<E, D>>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn forward_mut(&mut self, input: Input) -> Self::Output

Forward Input through the module and produce ModuleMut::Output. Read more
source§

impl<B: Dim, const C: usize, L: Dim, E: Dtype, D: Device<E>> ModuleMut<Tensor<(B, Const<C>, L), E, D, OwnedTape<E, D>>> for BatchNorm1D<C, E, D>

source§

fn try_forward_mut( &mut self, x: Tensor<(B, Const<C>, L), E, D, OwnedTape<E, D>> ) -> Result<Self::Output, D::Err>

Training 1d forward - updates Self::running_mean and Self::running_var

§

type Output = Tensor<(B, Const<C>, L), E, D, OwnedTape<E, D>>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn forward_mut(&mut self, input: Input) -> Self::Output

Forward Input through the module and produce ModuleMut::Output. Read more
source§

impl<const C: usize, H: Dim, W: Dim, E: Dtype, D: Device<E>> ModuleMut<Tensor<(Const<C>, H, W), E, D, OwnedTape<E, D>>> for BatchNorm2D<C, E, D>

source§

fn try_forward_mut( &mut self, x: Tensor<(Const<C>, H, W), E, D, OwnedTape<E, D>> ) -> Result<Self::Output, D::Err>

Training 3d forward - updates Self::running_mean and Self::running_var

§

type Output = Tensor<(Const<C>, H, W), E, D, OwnedTape<E, D>>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn forward_mut(&mut self, input: Input) -> Self::Output

Forward Input through the module and produce ModuleMut::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>> ModuleMut<Tensor<S, E, D, OwnedTape<E, D>>> for Dropout

source§

fn try_forward_mut( &mut self, input: Tensor<S, E, D, OwnedTape<E, D>> ) -> Result<Self::Output, D::Err>

Calls dropout()

§

type Output = Tensor<S, E, D, OwnedTape<E, D>>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn forward_mut(&mut self, input: Input) -> Self::Output

Forward Input through the module and produce ModuleMut::Output. Read more
source§

impl<const N: usize, S: Shape, E: Dtype, D: Device<E>> ModuleMut<Tensor<S, E, D, OwnedTape<E, D>>> for DropoutOneIn<N>

source§

fn try_forward_mut( &mut self, input: Tensor<S, E, D, OwnedTape<E, D>> ) -> Result<Self::Output, D::Err>

Calls dropout() with p=1/N using self.rng.

§

type Output = Tensor<S, E, D, OwnedTape<E, D>>

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn forward_mut(&mut self, input: Input) -> Self::Output

Forward Input through the module and produce ModuleMut::Output. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, LhsTape: Tape<E, D>, Rhs> Mul<Rhs> for Tensor<S, E, D, LhsTape>where Self: TryMul<Rhs>,

§

type Output = Tensor<S, E, D, LhsTape>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Rhs) -> Self::Output

Performs the * operation. Read more
source§

impl<S: Shape, E: Dtype, D: UnaryKernel<NegateKernelOp, E>, T: Tape<E, D>> Neg for Tensor<S, E, D, T>

§

type Output = Tensor<S, E, D, T>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<S: Shape, D: BooleanKernel> Not for &Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl<S: Shape, D: BooleanKernel> Not for Tensor<S, bool, D>

§

type Output = Tensor<S, bool, D, NoneTape>

The resulting type after applying the ! operator.
source§

fn not(self) -> Self

Performs the unary ! operation. Read more
source§

impl<S: Shape, E: Unit, D: DeviceStorage, T: Tape<E, D>> PermuteTo for Tensor<S, E, D, T>

source§

fn try_permute<Dst: Shape, Ax: Axes>( self ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: PermuteShapeTo<Dst, Ax>,

Fallible version of PermuteTo::permute
source§

fn permute<Dst: Shape, Ax: Axes>(self) -> Self::WithShape<Dst>where Self::Shape: PermuteShapeTo<Dst, Ax>,

Permutes the tensor: Read more
source§

impl<S: Shape, E: Unit, D: DeviceStorage, T> PutTape<T> for Tensor<S, E, D>

§

type Output = Tensor<S, E, D, T>

source§

fn put_tape(self, tape: T) -> Self::Output

source§

impl<S: Shape, E: Dtype, D: DeviceStorage, T: Tape<E, D>> RealizeTo for Tensor<S, E, D, T>

source§

fn realize<Dst: Shape<Concrete = S::Concrete>>( self ) -> Result<Self::WithShape<Dst>, Self>where Self::Shape: RealizeShapeTo<Dst>,

Realizes the concrete shape of the tensor as another compatable shape, or returns the original tensor if the new shape’s dimensions are incompatable. Read more
source§

impl<S: Shape, E: Dtype, D: ReshapeKernel<E>, T: Tape<E, D>> ReshapeTo for Tensor<S, E, D, T>

source§

fn try_reshape_like<Dst: Shape>( self, dst: &Dst ) -> Option<Result<Self::WithShape<Dst>, Self::Err>>

Reshapes a tensor to a different runtime shape.
source§

fn reshape_like<Dst: Shape>(self, dst: &Dst) -> Option<Self::WithShape<Dst>>

Reshapes a tensor to a different runtime shape.
source§

impl<Src: Shape, E: Dtype, D: RemoveDimKernel<E>, T: Tape<E, D>> SelectTo<D> for Tensor<Src, E, D, T>

source§

fn try_select<Dst: Shape, Idx: Shape>( self, idx: Tensor<Idx, usize, D> ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: RemoveDimTo<Dst, Idx>,

Fallible select
source§

fn select<Dst: Shape, Idx: Shape>( self, idx: Tensor<Idx, usize, D> ) -> Self::WithShape<Dst>where Self::Shape: RemoveDimTo<Dst, Idx>,

Select values given indices. Read more
source§

impl<S: Shape, E: Unit, D: DeviceStorage, T> SplitTape for Tensor<S, E, D, T>

§

type Tape = T

The type of tape the tensor has now
§

type NoTape = Tensor<S, E, D, NoneTape>

source§

fn split_tape(self) -> (Self::NoTape, Self::Tape)

Splits tape off of self Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> StddevTo<E> for Tensor<S, E, D, T>

source§

fn try_stddev<Dst: Shape, Ax: Axes>( self, epsilon: E ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: HasAxes<Ax> + ReduceShapeTo<Dst, Ax>,

Fallible version of StddevTo::stddev
source§

fn stddev<Dst: Shape, Ax: Axes>(self, epsilon: E) -> Self::WithShape<Dst>where Self::Shape: HasAxes<Ax> + ReduceShapeTo<Dst, Ax>,

Standard deviation reduction. Read more
source§

impl<S: Shape, E: Dtype, D: Device<E>, LTape: Tape<E, D>, Rhs> Sub<Rhs> for Tensor<S, E, D, LTape>where Self: TrySub<Rhs>,

§

type Output = Tensor<S, E, D, LTape>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Rhs) -> Self::Output

Performs the - operation. Read more
source§

impl<S: Shape, E: Dtype, D: SumKernel<E>, T: Tape<E, D>> SumTo for Tensor<S, E, D, T>

source§

fn try_sum<Dst: Shape, Ax: Axes>( self ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: ReduceShapeTo<Dst, Ax>,

Fallible version of SumTo::sum
source§

fn sum<Dst: Shape, Ax: Axes>(self) -> Self::WithShape<Dst>where Self::Shape: ReduceShapeTo<Dst, Ax>,

Sum reduction. Pytorch equivalent: t.sum(Ax) Read more
source§

impl<S: ConstShape, E: Dtype, D: Device<E>> TensorCollection<E, D> for Tensor<S, E, D>

§

type To<E2: Dtype, D2: Device<E2>> = Tensor<S, E2, D2, NoneTape>

Type alias that specifies the how a module’s type changes when using a different dtype and/or device.
source§

fn iter_tensors<V: ModuleVisitor<Self, E, D>>( visitor: &mut V ) -> Result<Option<Self::To<V::E2, V::D2>>, V::Err>

Specifies how to iterate through tensors or modules containted within this module, and how to contruct this module given values for its fields. Returns Err(_) to indicate an error, Ok(None) to indicate that there is no error and a module has not been built, and Ok(Some(_)) contains Self::Output<E2, D2>
source§

fn module<F1, F2, Field>( name: &str, get_ref: F1, get_mut: F2 ) -> ModuleField<'_, F1, F2, Self, Field>where F1: FnMut(&Self) -> &Field, F2: FnMut(&mut Self) -> &mut Field, Field: TensorCollection<E, D>,

Creates a ModuleFields that represents a field that may contain one or more tensors. Read more
source§

fn tensor<F1, F2, S>( name: &str, get_ref: F1, get_mut: F2, options: TensorOptions<S, E, D> ) -> TensorField<'_, F1, F2, Self, S, E, D>where F1: FnMut(&Self) -> &Tensor<S, E, D>, F2: FnMut(&mut Self) -> &mut Tensor<S, E, D>, S: Shape,

Creates a ModuleFields that represents a tensor field. Read more
source§

impl<S: Shape, E: Unit, F: Unit, D: DeviceStorage> Trace<E, D> for Tensor<S, F, D, NoneTape>

§

type Traced = Tensor<S, F, D, OwnedTape<E, D>>

source§

fn leaky_traced(self) -> Self::Traced

Start tracking gradients. The gradients will never free temporary gradients - See Gradients::leaky() for more info. Read more
source§

fn traced(self, gradients: Gradients<E, D>) -> Self::Traced

Accumulates gradients into gradients. Use crate::nn::ZeroGrads::alloc_grads() to create gradients.
source§

fn leaky_trace(&self) -> Self::Traced

Start tracking gradients, clones self. The gradients will never free temporary gradients - See Gradients::leaky() for more info. Read more
source§

fn trace(&self, gradients: Gradients<E, D>) -> Self::Traced

Accumulates gradients into gradients, clones self. Use crate::nn::ZeroGrads::alloc_grads() to create gradients.
source§

impl<S: Shape, E: Dtype, D: UnaryKernel<ScalarAddKernelOp<E>, E>, T: Tape<E, D>> TryAdd<E> for Tensor<S, E, D, T>

source§

fn try_add(self, rhs: E) -> Result<Self, Self::Err>

See add

source§

impl<S: Shape, E: Dtype, D, LhsTape, R> TryAdd<Tensor<S, E, D, R>> for Tensor<S, E, D, LhsTape>where D: BinaryKernel<BinaryAddKernelOp, E>, LhsTape: Merge<R> + Tape<E, D>,

source§

fn try_add(self, rhs: Tensor<S, E, D, R>) -> Result<Self, Self::Err>

See add

source§

impl<A, B: Shape, T, R, E: Dtype, D: ConcatKernel<E>> TryConcat<Tensor<B, E, D, R>> for Tensor<A, E, D, T>where A: ConcatShape<B> + Shape, T: Tape<E, D> + Merge<R>, R: Tape<E, D>,

§

type Output = Tensor<<A as ConcatShape<B>>::Catted, E, D, T>

source§

fn try_concat(self, rhs: Tensor<B, E, D, R>) -> Result<Self::Output, Self::Err>

Fallible version of TryConcat::concat.
source§

fn concat(self, rhs: Rhs) -> Self::Output

Concatenate two tensors along the first dimension.
source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> TryDiv<E> for Tensor<S, E, D, T>

source§

fn try_div(self, rhs: E) -> Result<Self, Self::Err>

See div

source§

impl<S: Shape, E: Dtype, D: Device<E>, LhsTape, R> TryDiv<Tensor<S, E, D, R>> for Tensor<S, E, D, LhsTape>where LhsTape: Merge<R> + Tape<E, D>,

source§

fn try_div(self, rhs: Tensor<S, E, D, R>) -> Result<Self, Self::Err>

See div

source§

impl<B: Dim, M: Dim, K: Dim, N: Dim, E: Dtype, D, T, R> TryMatMul<Tensor<(B, K, N), E, D, R>> for Tensor<(B, M, K), E, D, T>where D: MatMatBatch3Kernel<E>, T: Tape<E, D> + Merge<R>, R: Tape<E, D>,

source§

fn try_matmul( self, rhs: Tensor<(B, K, N), E, D, R> ) -> Result<Self::Output, Self::Err>

let x: Tensor<Rank3<1, 3, 2>, f32, _> = dev.zeros();
let y: Tensor<Rank3<1, 3, 4>, f32, _> = dev.zeros();
let _: Tensor<Rank3<1, 3, 4>, f32, _> = x.try_matmul(y);
§

type Output = Tensor<(B, M, N), E, D, T>

source§

fn matmul(self, rhs: Rhs) -> Self::Output

source§

impl<B: Dim, S: Dim, M: Dim, K: Dim, N: Dim, E: Dtype, D, T, R> TryMatMul<Tensor<(B, S, K, N), E, D, R>> for Tensor<(B, S, M, K), E, D, T>where D: MatMatBatch4Kernel<E>, T: Tape<E, D> + Merge<R>, R: Tape<E, D>,

source§

fn try_matmul( self, rhs: Tensor<(B, S, K, N), E, D, R> ) -> Result<Self::Output, Self::Err>

let x: Tensor<Rank4<1, 5, 3, 2>, f32, _> = dev.zeros();
let y: Tensor<Rank4<1, 5, 3, 4>, f32, _> = dev.zeros();
let _: Tensor<Rank3<1, 5, 3, 4>, f32, _> = x.try_matmul(y);
§

type Output = Tensor<(B, S, M, N), E, D, T>

source§

fn matmul(self, rhs: Rhs) -> Self::Output

source§

impl<B: Dim, M: Dim, K: Dim, N: Dim, E: Dtype, D: MatMatBrKernel<E>, T, R> TryMatMul<Tensor<(K, N), E, D, R>> for Tensor<(B, M, K), E, D, T>where T: Tape<E, D> + Merge<R>, R: Tape<E, D>,

source§

fn try_matmul( self, rhs: Tensor<(K, N), E, D, R> ) -> Result<Self::Output, Self::Err>

let x: Tensor<Rank3<1, 3, 2>, f32, _> = dev.zeros();
let y: Tensor<Rank2<3, 4>, f32, _> = dev.zeros();
let _: Tensor<Rank3<1, 3, 4>, f32, _> = x.try_matmul(y);
§

type Output = Tensor<(B, M, N), E, D, T>

source§

fn matmul(self, rhs: Rhs) -> Self::Output

source§

impl<K: Dim, N: Dim, E: Dtype, D: VecMatKernel<E>, T: Tape<E, D> + Merge<R>, R: Tape<E, D>> TryMatMul<Tensor<(K, N), E, D, R>> for Tensor<(K,), E, D, T>

§

type Output = Tensor<(N,), E, D, T>

source§

fn try_matmul( self, rhs: Tensor<(K, N), E, D, R> ) -> Result<Self::Output, Self::Err>

source§

fn matmul(self, rhs: Rhs) -> Self::Output

source§

impl<M: Dim, K: Dim, N: Dim, E: Dtype, D: MatMatKernel<E>, T, R> TryMatMul<Tensor<(K, N), E, D, R>> for Tensor<(M, K), E, D, T>where T: Tape<E, D> + Merge<R>, R: Tape<E, D>,

source§

fn try_matmul( self, rhs: Tensor<(K, N), E, D, R> ) -> Result<Self::Output, Self::Err>

let x: Tensor<Rank2<3, 2>, f32, _> = dev.zeros();
let y: Tensor<Rank2<3, 4>, f32, _> = dev.zeros();
let _: Tensor<Rank2<3, 4>, f32, _> = x.try_matmul(y);
§

type Output = Tensor<(M, N), E, D, T>

source§

fn matmul(self, rhs: Rhs) -> Self::Output

source§

impl<M: Dim, N: Dim, E: Dtype, D: VecVecKernel<E>, T: Tape<E, D> + Merge<R>, R: Tape<E, D>> TryMatMul<Tensor<(N,), E, D, R>> for Tensor<(M,), E, D, T>

§

type Output = Tensor<(M, N), E, D, T>

source§

fn try_matmul( self, rhs: Tensor<(N,), E, D, R> ) -> Result<Self::Output, Self::Err>

source§

fn matmul(self, rhs: Rhs) -> Self::Output

source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> TryMul<E> for Tensor<S, E, D, T>

source§

fn try_mul(self, rhs: E) -> Result<Self, Self::Err>

source§

impl<S: Shape, E: Dtype, D: Device<E>, LhsTape, R> TryMul<Tensor<S, E, D, R>> for Tensor<S, E, D, LhsTape>where LhsTape: Merge<R> + Tape<E, D>,

source§

fn try_mul(self, rhs: Tensor<S, E, D, R>) -> Result<Self, Self::Err>

source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> TrySub<E> for Tensor<S, E, D, T>

source§

fn try_sub(self, rhs: E) -> Result<Self, Self::Err>

source§

impl<S: Shape, E: Dtype, D: Device<E>, LTape, R> TrySub<Tensor<S, E, D, R>> for Tensor<S, E, D, LTape>where LTape: Merge<R> + Tape<E, D>,

source§

fn try_sub(self, rhs: Tensor<S, E, D, R>) -> Result<Self, Self::Err>

source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> VarTo for Tensor<S, E, D, T>

source§

fn try_var<Dst: Shape, Ax: Axes>( self ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: HasAxes<Ax> + ReduceShapeTo<Dst, Ax>,

Fallible version of VarTo::var
source§

fn var<Dst: Shape, Ax: Axes>(self) -> Self::WithShape<Dst>where Self::Shape: HasAxes<Ax> + ReduceShapeTo<Dst, Ax>,

Result Tensor has smaller number of dimensions. Read more
source§

impl<S: Shape, E: Dtype, D: DeviceStorage, T: Default> WithEmptyTape for Tensor<S, E, D, T>

source§

fn with_empty_tape(&self) -> Self

Clones self and inserts a new empty tape into the clone

Auto Trait Implementations§

§

impl<S, E, D, T> RefUnwindSafe for Tensor<S, E, D, T>where D: RefUnwindSafe, S: RefUnwindSafe, T: RefUnwindSafe, <S as Shape>::Concrete: RefUnwindSafe, <D as DeviceStorage>::Vec<E>: RefUnwindSafe,

§

impl<S, E, D, T> Send for Tensor<S, E, D, T>where D: Send, T: Send,

§

impl<S, E, D, T> Sync for Tensor<S, E, D, T>where D: Sync, T: Sync,

§

impl<S, E, D, T> Unpin for Tensor<S, E, D, T>where D: Unpin, S: Unpin, T: Unpin, <S as Shape>::Concrete: Unpin,

§

impl<S, E, D, T> UnwindSafe for Tensor<S, E, D, T>where D: UnwindSafe, S: UnwindSafe, T: UnwindSafe, <S as Shape>::Concrete: UnwindSafe, <D as DeviceStorage>::Vec<E>: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V