Struct dfdx::tensor::Tensor

source ·
pub struct Tensor<S: Shape, E, D: Storage<E>, 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. Storage - 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, D: Storage<E>, T> Tensor<S, E, D, T>

source

pub fn ghost(&self) -> GhostTensor<S, E, D>

Creates a ghost tensor that doesn’t hold a reference to the tensor’s data.

source§

impl<S: Shape, E: Dtype + NumpyDtype, D: 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, 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, D: Storage<E>, T> Tensor<S, E, D, T>

source

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

source§

impl<S: Shape, E, D: Storage<E>, T> Tensor<S, E, D, T>

source

pub fn to_device<Dst: TensorFromVec<E>>( &self, device: &Dst ) -> Tensor<S, E, Dst>

Clones the tensor onto a different device.

source

pub fn try_to_device<Dst: TensorFromVec<E>>( &self, device: &Dst ) -> Result<Tensor<S, E, Dst>, Dst::Err>

Fallibly clones the tensor onto a different device.

source§

impl<S: Shape, E, D: Storage<E>, 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

pub fn device(&self) -> &D

Get a reference to the tensor’s Storage

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: Dtype, D: UnaryKernel<AccurateGeLUKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn accurate_gelu(self) -> Self

source

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

source§

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

source

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

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

source

pub fn try_axpy<T>( &mut self, alpha: impl Into<f64>, b: &Tensor<S, E, D, T>, beta: impl Into<f64> ) -> 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: impl Into<f64>, max: impl Into<f64>) -> Self

See clamp

source

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

See clamp

source§

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

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

See eq

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

See eq

source§

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

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

See ne

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

See ne

source§

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

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

See gt

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

See gt

source§

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

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

See ge

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

See ge

source§

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

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

See lt

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

See lt

source§

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

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

See le

source

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

👎Deprecated: You can now use the non-scalar method for both tensors & scalars.

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: impl Into<f64>) -> Self

See dropout

source

pub fn try_dropout(self, prob: impl Into<f64>) -> 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<FastGeLUKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn fast_gelu(self) -> Self

source

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

source

pub fn gelu(self) -> Self

👎Deprecated since 0.12.0: Use Tensor::fast_gelu instead

Use Tensor::fast_gelu instead

source

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

👎Deprecated since 0.12.0: Use Tensor::try_fast_gelu instead
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: impl Into<f64> ) -> Selfwhere T: Merge<R>,

source

pub fn try_huber_error<R: Tape<E, D>>( self, rhs: Tensor<S, E, D, R>, delta: impl Into<f64> ) -> 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: impl Into<f64>) -> Self

See nans_to

source

pub fn try_nans_to(self, value: impl Into<f64>) -> 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: impl Into<f64>) -> Selfwhere S: ReduceShape<Ax>,

source

pub fn try_normalize<Ax: Axes>( self, epsilon: impl Into<f64> ) -> 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: impl Into<f64>) -> Self

See powf

source

pub fn try_powf(self, exponent: impl Into<f64>) -> 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<RecipKernelOp, E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn recip(self) -> Self

See recip

source

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

See recip

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: Unit, D: SliceKernel<E>, T: Tape<E, D>> Tensor<S, E, D, T>

source

pub fn try_slice<Slice>( self, slice: Slice ) -> Result<Tensor<S::Sliced, E, D, T>, D::Err>where S: SliceShape<Slice>, Slice: 'static,

Fallible version of Tensor::slice

source

pub fn slice<Slice>(self, slice: Slice) -> Tensor<S::Sliced, E, D, T>where S: SliceShape<Slice>, Slice: 'static,

Calls slice().

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>,

source

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

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

source§

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

source

pub fn try_to_dtype<E2: Unit>(self) -> Result<Tensor<S, E2, D>, D::Err>where D: ToDtypeKernel<E, E2>,

source

pub fn to_dtype<E2: Unit>(self) -> Tensor<S, E2, D>where D: ToDtypeKernel<E, E2>,

source§

impl<S: Shape, E: Dtype, D: TriangleTensor<E>, T: Tape<E, D>> Tensor<S, E, D, T>where Self: TryMul<Tensor<S, E, D>> + HasErr<Err = D::Err>,

source

pub fn try_lower_tri( self, diagonal: impl Into<Option<isize>> ) -> Result<Self, <Self as HasErr>::Err>

source

pub fn lower_tri(self, diagonal: impl Into<Option<isize>>) -> Self

source

pub fn try_upper_tri( self, diagonal: impl Into<Option<isize>> ) -> Result<Self, <Self as HasErr>::Err>

source

pub fn upper_tri(self, diagonal: impl Into<Option<isize>>) -> Self

Trait Implementations§

source§

impl<S: Shape, E: Dtype, D: Storage<E>, 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, 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: 'static + Clone, 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, D: Storage<E>, T: Tape<E, D>> BroadcastTo for Tensor<S, E, D, T>

source§

fn try_broadcast_like<Dst: HasShape, Ax: Axes>( self, dst: &Dst ) -> Result<Self::WithShape<Dst::Shape>, Self::Err>where Self::Shape: BroadcastShapeTo<Dst::Shape, 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.
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: HasShape, Ax: Axes>( self, dst: &Dst ) -> Self::WithShape<Dst::Shape>where Self::Shape: BroadcastShapeTo<Dst::Shape, 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, D: Clone + Storage<E>, T: Clone> Clone for Tensor<S, E, D, T>where D::Vec: 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, D: Debug + Storage<E>, T: Debug> Debug for Tensor<S, E, D, T>where D::Vec: 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: Storage<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<E, 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.
source§

impl<B: Dim, C: Dim, H: Dim, W: Dim, E: Dtype, M: UpscaleMethod, D: Upscale2DKernel<E, M> + ZerosTensor<E>, T: 'static + Tape<E, D>> GenericUpscale2D<M> for Tensor<(B, C, H, W), E, D, T>

§

type Output<OH: Dim, OW: Dim> = Tensor<(B, C, OH, OW), E, D, T>

source§

fn generic_upscale2d_like<OH: Dim, OW: Dim>( self, _method: M, out_height: OH, out_width: OW ) -> Result<Self::Output<OH, OW>, Self::Err>

source§

impl<C: Dim, H: Dim, W: Dim, E: Dtype, M: UpscaleMethod, D: Upscale2DKernel<E, M> + ZerosTensor<E>, T: 'static + Tape<E, D>> GenericUpscale2D<M> for Tensor<(C, H, W), E, D, T>

§

type Output<OH: Dim, OW: Dim> = Tensor<(C, OH, OW), E, D, T>

source§

fn generic_upscale2d_like<OH: Dim, OW: Dim>( self, _method: M, out_height: OH, out_width: OW ) -> Result<Self::Output<OH, OW>, Self::Err>

source§

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

§

type Dtype = E

source§

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

§

type Err = <D as HasErr>::Err

source§

impl<S: Shape, E, D: Storage<E>, 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: Storage<E>, 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<E: Dtype, D: Device<E>, T: Tape<E, D> + Merge<NoneTape>, B: ConstDim, C: ConstDim> Module<Tensor<(B, C), E, D, T>> for PReLU1D<C, E, D>where (B, C): ReduceShapeTo<(C,), Axis<0>>, Tensor<(B, C), E, D, T>: TryPReLU<Tensor<(B, C), E, D, NoneTape>>,

§

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

The type that this unit produces given Input.
§

type Error = <Tensor<(B, C), E, D, T> as HasErr>::Err

source§

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

source§

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

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

impl<const H: usize, const W: usize, const IH: usize, const IW: usize, B: Dim, C: Dim, E: Dtype, M: UpscaleMethod, D: Upscale2DKernel<E, M> + ZerosTensor<E>, T: 'static + Tape<E, D>> Module<Tensor<(B, C, Const<IH>, Const<IW>), E, D, T>> for Upscale2DBy<H, W, M>where Tensor<(B, C, Const<{ _ }>, Const<{ _ }>), E, D, T>: Sized,

§

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

The type that this unit produces given Input.
§

type Error = <<Upscale2DBy<H, W, M> as Module<Tensor<(B, C, Const<IH>, Const<IW>), E, D, T>>>::Output as HasErr>::Err

source§

fn try_forward( &self, x: Tensor<(B, C, Const<IH>, Const<IW>), E, D, T> ) -> Result<Self::Output, Self::Error>

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 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<E: Dtype, D: Device<E>, T: Tape<E, D> + Merge<NoneTape>, B: ConstDim, C: ConstDim, M: ConstDim> Module<Tensor<(B, C, M), E, D, T>> for PReLU1D<C, E, D>where (B, C, M): ReduceShapeTo<(C,), Axes2<0, 2>>, Tensor<(B, C, M), E, D, T>: TryPReLU<Tensor<(B, C, M), E, D, NoneTape>>,

§

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

The type that this unit produces given Input.
§

type Error = <Tensor<(B, C, M), E, D, T> as HasErr>::Err

source§

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

source§

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

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

impl<E: Dtype, D: Device<E>, T: Tape<E, D> + Merge<NoneTape>, B: ConstDim, C: ConstDim, M: ConstDim, N: ConstDim> Module<Tensor<(B, C, M, N), E, D, T>> for PReLU1D<C, E, D>where (B, C, M, N): ReduceShapeTo<(C,), Axes3<0, 2, 3>>, Tensor<(B, C, M, N), E, D, T>: TryPReLU<Tensor<(B, C, M, N), E, D, NoneTape>>,

§

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

The type that this unit produces given Input.
§

type Error = <Tensor<(B, C, M, N), E, D, T> as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<(B, C, M, N), E, D, T> ) -> Result<Self::Output, Self::Error>

source§

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

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

impl<const H: usize, const W: usize, B: Dim, C: Dim, E: Dtype, M: UpscaleMethod, D: Upscale2DKernel<E, M> + ZerosTensor<E>, T: 'static + Tape<E, D>> Module<Tensor<(B, C, usize, usize), E, D, T>> for Upscale2DBy<H, W, M>where Tensor<(B, C, usize, usize), E, D, T>: Sized,

§

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

The type that this unit produces given Input.
§

type Error = <<Upscale2DBy<H, W, M> as Module<Tensor<(B, C, usize, usize), E, D, T>>>::Output as HasErr>::Err

source§

fn try_forward( &self, x: Tensor<(B, C, usize, usize), E, D, T> ) -> Result<Self::Output, Self::Error>

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, const H: usize, const W: usize, D, E: Dtype, T> Module<Tensor<(B, Const<C>, Const<H>, Const<W>), E, D, T>> for Flatten2Dwhere D: Device<E>, T: Tape<E, D>, (B, Const<{ _ }>): Sized,

§

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>, Const<H>, Const<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, 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: ConstDim, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<(C,), E, D, T>> for PReLU1D<C, E, D>where Tensor<(C,), E, D, T>: TryPReLU<Tensor<(C,), E, D, NoneTape>>,

§

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

The type that this unit produces given Input.
§

type Error = <Tensor<(C,), E, D, T> as HasErr>::Err

source§

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

source§

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

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

impl<const H: usize, const W: usize, const IH: usize, const IW: usize, C: Dim, E: Dtype, M: UpscaleMethod, D: Upscale2DKernel<E, M> + ZerosTensor<E>, T: 'static + Tape<E, D>> Module<Tensor<(C, Const<IH>, Const<IW>), E, D, T>> for Upscale2DBy<H, W, M>where Tensor<(C, Const<{ _ }>, Const<{ _ }>), E, D, T>: Sized,

§

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

The type that this unit produces given Input.
§

type Error = <<Upscale2DBy<H, W, M> as Module<Tensor<(C, Const<IH>, Const<IW>), E, D, T>>>::Output as HasErr>::Err

source§

fn try_forward( &self, x: Tensor<(C, Const<IH>, Const<IW>), E, D, T> ) -> Result<Self::Output, Self::Error>

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 H: usize, const W: usize, C: Dim, E: Dtype, M: UpscaleMethod, D: Upscale2DKernel<E, M> + ZerosTensor<E>, T: 'static + Tape<E, D>> Module<Tensor<(C, usize, usize), E, D, T>> for Upscale2DBy<H, W, M>

§

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

The type that this unit produces given Input.
§

type Error = <<Upscale2DBy<H, W, M> as Module<Tensor<(C, usize, usize), E, D, T>>>::Output as HasErr>::Err

source§

fn try_forward( &self, x: Tensor<(C, usize, usize), E, D, T> ) -> Result<Self::Output, Self::Error>

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 AccurateGeLU

§

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 FastGeLU

§

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 LeakyReLU<E>

§

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

The type that this unit produces given Input.
§

type Error = <Tensor<S, E, D, T> as HasErr>::Err

source§

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

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 LogSoftmax

§

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: ConstShape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for PReLU<E, D>where Tensor<S, E, D, T>: TryPReLU<Tensor<S, E, D, NoneTape>>,

§

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

The type that this unit produces given Input.
§

type Error = <Tensor<S, E, D, T> as HasErr>::Err

source§

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

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<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> Module<Tensor<S, E, D, T>> for Softmax

§

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<Src: Shape, Dst: ConstShape, D: Device<E>, E: Dtype, T: Tape<E, D>> Module<Tensor<Src, E, D, T>> for Reshape<Dst>

§

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

The type that this unit produces given Input.
§

type Error = <D as HasErr>::Err

source§

fn try_forward( &self, input: Tensor<Src, 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: Storage<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, D: Storage<E>, 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.
source§

impl<S: Shape, E, D: Storage<E>, 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, D: Storage<E>, T: Tape<E, D>> RealizeTo for Tensor<S, E, D, T>

source§

fn try_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.
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 ) -> Result<Self::WithShape<Dst>, Self::Err>

Reshapes a tensor to a different runtime shape.
source§

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

Reshapes a tensor to a different runtime shape.
source§

fn contiguous(self) -> Self::WithShape<Self::Shape>

Ensures the tensor’s memory is contiguous. Read more
source§

fn try_contiguous(self) -> Result<Self::WithShape<Self::Shape>, Self::Err>

source§

impl<S: Shape, E: Dtype, D: RollKernel<E>, T: Tape<E, D>> Roll for Tensor<S, E, D, T>

source§

fn try_roll<Ax: Axes<Array = [isize; 1]>>( self, amount: usize ) -> Result<Self, D::Err>where S: HasAxes<Ax>,

Shifts data along an axis by a specified amount.
source§

fn roll<Ax: Axes<Array = [isize; 1]>>(self, amount: usize) -> Selfwhere Self::Shape: HasAxes<Ax>,

Shifts data along an axis by a specified amount.
source§

impl<Src: Shape, E: Dtype, D: RemoveDimKernel<E>, T: Tape<E, D>> SelectTo<E, 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.
source§

impl<S: Shape, E: Clone, D: Storage<E>, 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: impl Into<f64> ) -> 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: impl Into<f64> ) -> Self::WithShape<Dst>where Self::Shape: HasAxes<Ax> + ReduceShapeTo<Dst, Ax>,

Standard deviation reduction. Read more
source§

impl<S: Shape, E: Dtype, D: Storage<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§

fn scalar<F1, F2, N>( name: &str, get_ref: F1, get_mut: F2, options: ScalarOptions<N> ) -> ScalarField<'_, F1, F2, Self, N>where F1: FnMut(&Self) -> &N, F2: FnMut(&mut Self) -> &mut N, N: NumCast,

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

impl<S: Shape, E: Unit, F: Unit, D: Storage<F> + Storage<E>> 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>

👎Deprecated: Use TryConcatAlong instead
source§

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

👎Deprecated: Use TryConcatAlong::try_concat_along instead
Fallible version of TryConcat::concat.
source§

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

👎Deprecated: Use TryConcatAlong::concat_along instead
Concatenate two tensors along the first dimension.
source§

impl<S: Shape, E: Dtype, D: UnaryKernel<ScalarDivKernelOp<E>, 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, LhsTape, R> TryDiv<Tensor<S, E, D, R>> for Tensor<S, E, D, LhsTape>where D: BinaryKernel<BinaryDivKernelOp, E>, 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<S: Shape, E, D: CmpKernel<EqKernelOp, E>, T: Tape<E, D>> TryEq<&Tensor<S, E, D, T>> for Tensor<S, E, D, T>

source§

fn try_eq(&self, other: &Self) -> Result<Self::Output, D::Err>

See eq

§

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

source§

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

See eq
source§

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

source§

fn try_eq(&self, other: E) -> Result<Self::Output, D::Err>

See eq

§

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

source§

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

See eq
source§

impl<S: Shape, E, D: CmpKernel<GeKernelOp, E>, T: Tape<E, D>> TryGe<&Tensor<S, E, D, T>> for Tensor<S, E, D, T>

source§

fn try_ge(&self, other: &Self) -> Result<Self::Output, D::Err>

See ge

§

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

source§

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

See ge
source§

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

source§

fn try_ge(&self, other: E) -> Result<Self::Output, D::Err>

See ge

§

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

source§

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

See ge
source§

impl<S: Shape, E, D: CmpKernel<GtKernelOp, E>, T: Tape<E, D>> TryGt<&Tensor<S, E, D, T>> for Tensor<S, E, D, T>

source§

fn try_gt(&self, other: &Self) -> Result<Self::Output, D::Err>

See gt

§

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

source§

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

See gt
source§

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

source§

fn try_gt(&self, other: E) -> Result<Self::Output, D::Err>

See gt

§

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

source§

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

See gt
source§

impl<S: Shape, E, D: CmpKernel<LeKernelOp, E>, T: Tape<E, D>> TryLe<&Tensor<S, E, D, T>> for Tensor<S, E, D, T>

source§

fn try_le(&self, other: &Self) -> Result<Self::Output, D::Err>

See le

§

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

source§

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

See le
source§

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

source§

fn try_le(&self, other: E) -> Result<Self::Output, D::Err>

See le

§

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

source§

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

See le
source§

impl<S: Shape, E, D: CmpKernel<LtKernelOp, E>, T: Tape<E, D>> TryLt<&Tensor<S, E, D, T>> for Tensor<S, E, D, T>

source§

fn try_lt(&self, other: &Self) -> Result<Self::Output, D::Err>

See lt

§

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

source§

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

See lt
source§

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

source§

fn try_lt(&self, other: E) -> Result<Self::Output, D::Err>

See lt

§

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

source§

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

See lt
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<M: Dim, K: Dim, E: Dtype, D, T: Tape<E, D> + Merge<R>, R: Tape<E, D>> TryMatMul<Tensor<(K,), E, D, R>> for Tensor<(M, K), E, D, T>where D: MatMatKernel<E> + ReshapeKernel<E>,

§

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

source§

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

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, T: Tape<E, D> + Merge<R>, R: Tape<E, D>> TryMatMul<Tensor<(K, N), E, D, R>> for Tensor<(K,), E, D, T>where D: MatMatKernel<E> + ReshapeKernel<E>,

§

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, T: Tape<E, D> + Merge<R>, R: Tape<E, D>> TryMatMul<Tensor<(N,), E, D, R>> for Tensor<(M,), E, D, T>where D: MatMatKernel<E> + ReshapeKernel<E>,

§

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: UnaryKernel<ScalarMulKernelOp<E>, 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: BinaryKernel<BinaryMulKernelOp, 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, D: CmpKernel<NeKernelOp, E>, T: Tape<E, D>> TryNe<&Tensor<S, E, D, T>> for Tensor<S, E, D, T>

source§

fn try_ne(&self, other: &Self) -> Result<Self::Output, D::Err>

See ne

§

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

source§

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

See ne
source§

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

source§

fn try_ne(&self, other: E) -> Result<Self::Output, D::Err>

See ne

§

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

source§

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

See ne
source§

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

source§

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

See prelu

source§

fn prelu(self, rhs: T) -> Self

source§

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

source§

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

See prelu

source§

fn prelu(self, rhs: T) -> Self

source§

impl<Chan, Kernel, Stride, Padding, Dilation, Batch, H, W, E, D, T> TryPool2D<Kernel, Stride, Padding, Dilation> for Tensor<(Batch, Chan, H, W), E, D, T>where Chan: Dim, Kernel: Dim, Stride: Dim, Padding: Dim, Dilation: Dim, Batch: Dim, H: Dim + TryPool2D<Kernel, Stride, Padding, Dilation>, H::Pooled: Dim, W: Dim + TryPool2D<Kernel, Stride, Padding, Dilation>, W::Pooled: Dim, E: Dtype, D: Pool2DKernel<E>, T: Tape<E, D>,

§

type Pooled = Tensor<(Batch, Chan, <H as TryPool2D<Kernel, Stride, Padding, Dilation>>::Pooled, <W as TryPool2D<Kernel, Stride, Padding, Dilation>>::Pooled), E, D, T>

§

type Error = <D as HasErr>::Err

source§

fn try_pool2d( self, kind: Pool2DKind, kernel: Kernel, stride: Stride, padding: Padding, dilation: Dilation ) -> Result<Self::Pooled, Self::Error>

source§

fn pool2d( self, kind: Pool2DKind, kernel: Kernel, stride: Stride, padding: Padding, dilation: Dilation ) -> Self::Pooled

source§

impl<Chan, Kernel, Stride, Padding, Dilation, H, W, E, D, T> TryPool2D<Kernel, Stride, Padding, Dilation> for Tensor<(Chan, H, W), E, D, T>where Chan: Dim, Kernel: Dim, Stride: Dim, Padding: Dim, Dilation: Dim, H: Dim + TryPool2D<Kernel, Stride, Padding, Dilation>, H::Pooled: Dim, W: Dim + TryPool2D<Kernel, Stride, Padding, Dilation>, W::Pooled: Dim, E: Dtype, D: Pool2DKernel<E> + ReshapeKernel<E>, T: Tape<E, D>,

§

type Pooled = Tensor<(Chan, <H as TryPool2D<Kernel, Stride, Padding, Dilation>>::Pooled, <W as TryPool2D<Kernel, Stride, Padding, Dilation>>::Pooled), E, D, T>

§

type Error = <D as HasErr>::Err

source§

fn try_pool2d( self, kind: Pool2DKind, kernel: Kernel, stride: Stride, padding: Padding, dilation: Dilation ) -> Result<Self::Pooled, Self::Error>

source§

fn pool2d( self, kind: Pool2DKind, kernel: Kernel, stride: Stride, padding: Padding, dilation: Dilation ) -> Self::Pooled

source§

impl<S: Shape, E: Dtype, D: UnaryKernel<ScalarSubKernelOp<E>, 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: BinaryKernel<BinarySubKernelOp, 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: Storage<E>, T> TryUpscale2D for Tensor<S, E, D, T>

source§

fn upscale2d<const OH: usize, const OW: usize, M: UpscaleMethod>( self, method: M ) -> <Self as GenericUpscale2D<M>>::Output<Const<OH>, Const<OW>>where Self: GenericUpscale2D<M>,

Upscale to compile time known dimensions.
source§

fn try_upscale2d<const OH: usize, const OW: usize, M: UpscaleMethod>( self, method: M ) -> Result<<Self as GenericUpscale2D<M>>::Output<Const<OH>, Const<OW>>, Self::Err>where Self: GenericUpscale2D<M>,

Fallibly upscale to compile time known dimensions.
source§

fn upscale2d_like<OH: Dim, OW: Dim, M: UpscaleMethod>( self, method: M, height: OH, width: OW ) -> <Self as GenericUpscale2D<M>>::Output<OH, OW>where Self: GenericUpscale2D<M>,

Upscale to runtime known dimensions.
source§

fn try_upscale2d_like<OH: Dim, OW: Dim, M: UpscaleMethod>( self, method: M, height: OH, width: OW ) -> Result<<Self as GenericUpscale2D<M>>::Output<OH, OW>, Self::Err>where Self: GenericUpscale2D<M>,

Fallibly upscale to runtime known dimensions.
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, D: Storage<E>, 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 Storage<E>>::Vec: 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 Storage<E>>::Vec: 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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<D, E, M> BuildModule<D, E> for Mwhere D: Device<E>, E: Dtype, M: TensorCollection<E, D, To<E, D> = M>,

source§

fn build(device: &D) -> Self

Construct it on the device
source§

fn try_build(device: &D) -> Result<Self, D::Err>

Fallible version of BuildModule::build
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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<E, D, T> LoadFromNpz<E, D> for Twhere E: Dtype + NumpyDtype, D: Device<E>, T: TensorCollection<E, D>,

source§

fn load<P: AsRef<Path>>(&mut self, path: P) -> Result<(), NpzError>

Loads data from a .npz zip archive at the specified path. Read more
source§

fn read<R>(&mut self, r: &mut ZipArchive<R>) -> Result<(), NpzError>where R: Read + Seek,

Reads this object from a ZipArchive. r with a base filename of filename_prefix. Read more
source§

impl<E, D, T> LoadFromSafetensors<E, D> for Twhere E: Dtype + SafeDtype, D: Device<E>, T: TensorCollection<E, D>,

source§

fn load_safetensors<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>

Loads data from a .safetensors at the specified path. Read more
source§

impl<E, D, M> ModelEMA<E, D> for Mwhere E: Dtype, D: Device<E>, M: TensorCollection<E, D>,

source§

fn ema(&mut self, other: &Self, decay: impl Into<f64>)

Does `self = self * decay + other * (1 - decay), using crate::tensor_ops::axpy() on parameters. Read more
source§

fn try_ema(&mut self, other: &Self, decay: impl Into<f64>) -> Result<(), D::Err>

source§

impl<E, D, M> NumParams<E, D> for Mwhere E: Dtype, D: Device<E>, M: TensorCollection<E, D>,

source§

fn num_trainable_params(&self) -> usize

Returns the number of trainable params in any model.
§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<E, D, M> ResetParams<E, D> for Mwhere E: Dtype, D: Device<E>, M: TensorCollection<E, D>,

source§

fn reset_params(&mut self)

Reset all a model’s parameters.
source§

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

Reset all a model’s parameters.
source§

impl<E, D, T> SaveToNpz<E, D> for Twhere E: Dtype + NumpyDtype, D: Device<E>, T: TensorCollection<E, D>,

source§

fn save<P: AsRef<Path>>(&self, path: P) -> ZipResult<()>

Save this object into the .npz file determined located at path. Read more
source§

fn write<W>(&self, w: &mut ZipWriter<W>) -> ZipResult<()>where W: Write + Seek,

Write this object into ZipWriter w with a base filename of filename_prefix. Read more
source§

impl<E, D, T> SaveToSafetensors<E, D> for Twhere E: Dtype + SafeDtype, D: Device<E>, T: TensorCollection<E, D>,

source§

fn save_safetensors<P: AsRef<Path>>( &self, path: P ) -> Result<(), SafeTensorError>

Save this object into the .safetensors file determined located at path. Read more
source§

impl<E, D1, D2, T> ToDevice<E, D1, D2> for Twhere E: Dtype, D1: Device<E>, D2: Device<E>, T: TensorCollection<E, D1>,

source§

fn try_to_device(&self, device: &D2) -> Result<Self::To<E, D2>, D2::Err>

Fallible version of ToDevice::to_device
source§

fn to_device(&self, device: &D2) -> Self::To<E, D2>

Copy self from D1 to D2
source§

impl<E1, D, T> ToDtype<E1, D> for Twhere E1: Dtype, D: Device<E1>, T: TensorCollection<E1, D>,

source§

fn try_to_dtype<E2: Dtype>(&self) -> Result<Self::To<E2, D>, D::Err>where D: Device<E2> + ToDtypeKernel<E1, E2>,

Fallible version of ToDtype::to_dtype
source§

fn to_dtype<E2: Dtype>(&self) -> Self::To<E2, D>where D: Device<E2> + ToDtypeKernel<E1, E2>,

Create a copy of self with dtype E2
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.
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.
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

source§

impl<E, D, M> ZeroGrads<E, D> for Mwhere E: Dtype, D: Device<E>, M: TensorCollection<E, D>,

source§

fn alloc_grads(&self) -> Gradients<E, D>

Allocates gradients for this tensor collection. This marks all other gradients as temporary, so they are dropped after .backward()
source§

fn try_alloc_grads(&self) -> Result<Gradients<E, D>, D::Err>

Allocates gradients for this tensor collection. This marks all other gradients as temporary, so they are dropped after .backward()
source§

fn zero_grads(&self, gradients: &mut Gradients<E, D>)

Zero’s any gradients associated with self.
source§

fn try_zero_grads(&self, gradients: &mut Gradients<E, D>) -> Result<(), D::Err>

Zero’s any gradients associated with self.