Struct rai_core::Tensor

source ·
pub struct Tensor(/* private fields */);

Implementations§

source§

impl Tensor

source

pub fn new( device: impl AsDevice, dtype: impl AsDType, shape: impl Shape, primitive: impl Into<Box<dyn Primitive>>, inputs: impl Into<Vec<Tensor>> ) -> Self

source

pub fn id(&self) -> usize

source

pub fn device(&self) -> &dyn Device

source

pub fn dtype(&self) -> &dyn DType

source

pub fn primitive(&self) -> &dyn Primitive

source

pub fn inputs(&self) -> impl Deref<Target = [Tensor]> + '_

source

pub fn full<T: ElemType>( val: T, shape: impl Shape, device: impl AsDevice ) -> Tensor

source

pub fn full_like<T: ElemType>(&self, val: T) -> Tensor

source

pub fn ones( shape: impl Shape, dtype: impl AsDType, device: impl AsDevice ) -> Tensor

source

pub fn ones_like(&self) -> Tensor

source

pub fn zeros( shape: impl Shape, dtype: impl AsDType, device: impl AsDevice ) -> Tensor

source

pub fn zeros_like(&self) -> Tensor

source

pub fn rand<T: Type>( shape: impl Shape, dtype: T, device: impl AsDevice ) -> Tensor

source

pub fn rand_with<T: ElemType>( from: T, to: T, shape: impl Shape, device: impl AsDevice ) -> Tensor

source

pub fn rand_like(&self) -> Tensor

source

pub fn randn<T: Type>( shape: impl Shape, dtype: T, device: impl AsDevice ) -> Tensor

source

pub fn randn_with<T: ElemType>( mean: T, std: T, shape: impl Shape, device: impl AsDevice ) -> Tensor

source

pub fn randn_like(&self) -> Tensor

source

pub fn arange<D: Type, T: ArangeArgs<D>>( args: T, device: impl AsDevice ) -> Tensor
where D::Repr: Sub<D::Repr, Output = D::Repr> + Div<D::Repr, Output = D::Repr> + Into<f64> + Copy,

source

pub fn from_array<T: ElemType>( data: impl Into<Vec<T>> + Debug, shape: impl Shape, device: impl AsDevice ) -> Tensor

source

pub fn from_safetensor(view: &TensorView<'_>, device: impl AsDevice) -> Tensor

source

pub fn neg(&self) -> Tensor

source

pub fn cat<T: AsRef<Tensor> + Debug>(tensors: &[T], dim: impl Dim) -> Tensor

source

pub fn matmul<T: AsRef<Tensor>>(&self, rhs: T) -> Tensor

source

pub fn eq<T: AsRef<Tensor>>(&self, rhs: T) -> Tensor

source

pub fn ne<T: AsRef<Tensor>>(&self, rhs: T) -> Tensor

source

pub fn gt<T: AsRef<Tensor>>(&self, rhs: T) -> Tensor

source

pub fn ge<T: AsRef<Tensor>>(&self, rhs: T) -> Tensor

source

pub fn lt<T: AsRef<Tensor>>(&self, rhs: T) -> Tensor

source

pub fn le<T: AsRef<Tensor>>(&self, rhs: T) -> Tensor

source

pub fn maximum<T: AsRef<Tensor>>(&self, rhs: T) -> Tensor

source

pub fn minimum<T: AsRef<Tensor>>(&self, rhs: T) -> Tensor

source

pub fn t(&self) -> Tensor

source

pub fn transpose(&self, dim0: impl Dim, dim1: impl Dim) -> Tensor

source

pub fn broadcast_to(&self, shape: impl Shape) -> Tensor

source

pub fn broadcast_to_unchecked(&self, shape: impl Shape) -> Tensor

source

pub fn broadcast_left(&self, shape: impl Shape) -> Tensor

source

pub fn broadcast_right(&self, shape: impl Shape) -> Tensor

source

pub fn reshape(&self, shape: impl Shape) -> Tensor

source

pub fn add<T>(&self, rhs: T) -> Tensor
where for<'a> &'a Self: Add<T, Output = Tensor>,

source

pub fn mul<T>(&self, rhs: T) -> Tensor
where for<'a> &'a Self: Mul<T, Output = Tensor>,

source

pub fn sin(&self) -> Tensor

source

pub fn cos(&self) -> Tensor

source

pub fn tanh(&self) -> Tensor

source

pub fn square(&self) -> Tensor

source

pub fn powf(&self, exponent: f64) -> Tensor

source

pub fn sqrt(&self) -> Tensor

source

pub fn rsqrt(&self) -> Tensor

source

pub fn sign(&self) -> Tensor

source

pub fn abs(&self) -> Tensor

source

pub fn exp(&self) -> Tensor

source

pub fn log(&self) -> Tensor

source

pub fn log2(&self) -> Tensor

source

pub fn log10(&self) -> Tensor

source

pub fn sum<T: ReduceArgs>(&self, args: T) -> Tensor

source

pub fn max<T: ReduceArgs>(&self, args: T) -> Tensor

source

pub fn min<T: ReduceArgs>(&self, args: T) -> Tensor

source

pub fn mean<T: ReduceArgs>(&self, args: T) -> Tensor

source

pub fn var<T: VarArgs>(&self, args: T) -> Tensor

source

pub fn argmax<T: ArgReduceArgs>(&self, args: T) -> Tensor

source

pub fn argmin<T: ArgReduceArgs>(&self, args: T) -> Tensor

source

pub fn gather(&self, dim: impl Dim, index: impl AsRef<Tensor>) -> Tensor

source

pub fn index_add( &self, dim: impl Dim, index: &Tensor, source: &Tensor ) -> Tensor

source

pub fn index_select(&self, dim: impl Dim, index: impl AsRef<Tensor>) -> Tensor

source

pub fn to_dtype(&self, dtype: impl AsDType) -> Tensor

source

pub fn to_device(&self, device: impl AsDevice) -> Tensor

source

pub fn softmax<D: Dim>(&self, d: D) -> Tensor

source

pub fn log_softmax<D: Dim>(&self, d: D) -> Tensor

source

pub fn erf(&self) -> Tensor

source

pub fn clamp(&self, min: impl ClampBound, max: impl ClampBound) -> Tensor

source

pub fn relu(&self) -> Tensor

source

pub fn relu2(&self) -> Tensor

source

pub fn relu6(&self) -> Tensor

source

pub fn gelu(&self) -> Tensor

source

pub fn silu(&self) -> Tensor

source

pub fn new_gelu(&self) -> Tensor

source

pub fn dropout(&self, p: f32) -> Tensor

source

pub fn flatten<T: FlattenArgs>(&self, args: T) -> Tensor

source

pub fn to_contiguous(&self) -> Tensor

source

pub fn squeeze(&self, d: impl Dims) -> Tensor

source

pub fn unsqueeze(&self, d: impl Dim) -> Tensor

source

pub fn permute(&self, d: impl Dims) -> Tensor

source

pub fn narrow(&self, dim: impl Dim, start: usize, len: usize) -> Tensor

source

pub fn chunk(&self, chunks: usize, dim: impl Dim) -> Vec<Tensor>

source

pub fn where_cond( &self, input: impl AsRef<Tensor>, other: impl AsRef<Tensor> ) -> Tensor

source

pub fn conv1d( &self, kernel: impl AsRef<Tensor>, padding: usize, stride: usize, dilation: usize, groups: usize ) -> Tensor

source

pub fn conv_transpose1d( &self, kernel: impl AsRef<Tensor>, padding: usize, output_padding: usize, stride: usize, dilation: usize, groups: usize ) -> Tensor

source

pub fn conv2d( &self, kernel: impl AsRef<Tensor>, padding: [usize; 2], stride: [usize; 2], dilation: [usize; 2], groups: usize ) -> Tensor

source

pub fn conv_transpose2d( &self, kernel: impl AsRef<Tensor>, padding: [usize; 2], output_padding: [usize; 2], stride: [usize; 2], dilation: [usize; 2], groups: usize ) -> Tensor

source

pub fn max_pool1d(&self, args: impl MaxPool1dArgs) -> Tensor

source

pub fn max_pool2d(&self, args: impl MaxPool2dArgs) -> Tensor

source

pub fn avg_pool1d(&self, args: impl AvgPool1dArgs) -> Tensor

source

pub fn avg_pool2d(&self, args: impl AvgPool2dArgs) -> Tensor

source

pub fn upsample_nearest1d(&self, size: usize) -> Tensor

source

pub fn upsample_nearest2d(&self, size: impl ToPair<usize>) -> Tensor

source

pub fn scatter_add( &self, dim: impl Dim, index: impl AsRef<Tensor>, source: impl AsRef<Tensor> ) -> Tensor

source

pub fn jvp(&self, tangent_cache: &mut HashMap<usize, Tensor>) -> Tensor

source

pub fn vjp(&self, cotangent: &Tensor, grads_sum: &mut HashMap<usize, Tensor>)

source

pub fn dot_graph(&self) -> String

source

pub fn detach(&self)

source

pub fn replace_data(&self, rhs: Tensor)

source

pub fn set_data<T: TensorLike + 'static>(&self, data: T)

source

pub fn get_data<T>(&self) -> Option<impl Deref<Target = T> + '_>
where T: 'static,

source

pub fn as_scalar<T: Type>(&self, dtype: T) -> T::Repr

source

pub fn as_vec<T: Type>(&self, dtype: T) -> Vec<T::Repr>

source

pub fn apply<M>(&self, module: M) -> M::Output
where M: Module<Input = Self>, Self: ApplyModule<M>,

source

pub fn is_evaluated(&self) -> bool

source

pub fn to_safetensors( &self, name: impl Into<String>, filename: impl AsRef<Path> )

Trait Implementations§

source§

impl<'a, 'b> Add<&'b Tensor> for &'a Tensor

§

type Output = Tensor

The resulting type after applying the + operator.
source§

fn add(self, rhs: &'b Tensor) -> Tensor

Performs the + operation. Read more
source§

impl<'a> Add<&'a Tensor> for Tensor

§

type Output = Tensor

The resulting type after applying the + operator.
source§

fn add(self, rhs: &'a Tensor) -> Tensor

Performs the + operation. Read more
source§

impl<'a> Add<&'a Tensor> for f32

§

type Output = Tensor

The resulting type after applying the + operator.
source§

fn add(self, rhs: &'a Tensor) -> Self::Output

Performs the + operation. Read more
source§

impl<'a> Add<&'a Tensor> for f64

§

type Output = Tensor

The resulting type after applying the + operator.
source§

fn add(self, rhs: &'a Tensor) -> Self::Output

Performs the + operation. Read more
source§

impl<'a> Add<&'a Tensor> for u8

§

type Output = Tensor

The resulting type after applying the + operator.
source§

fn add(self, rhs: &'a Tensor) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, T> Add<T> for &'a Tensor
where T: ElemType,

§

type Output = Tensor

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T> Add<T> for Tensor
where T: ElemType,

§

type Output = Tensor

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<'a> Add<Tensor> for &'a Tensor

§

type Output = Tensor

The resulting type after applying the + operator.
source§

fn add(self, rhs: Tensor) -> Tensor

Performs the + operation. Read more
source§

impl Add<Tensor> for f32

§

type Output = Tensor

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add<Tensor> for f64

§

type Output = Tensor

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add<Tensor> for u8

§

type Output = Tensor

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add for Tensor

§

type Output = Tensor

The resulting type after applying the + operator.
source§

fn add(self, rhs: Tensor) -> Tensor

Performs the + operation. Read more
source§

impl<'a> AsDType for &'a Tensor

source§

fn dtype(&self) -> &dyn DType

source§

fn into_boxed_dtype(self) -> Box<dyn DType>

source§

impl AsDType for Tensor

source§

fn dtype(&self) -> &dyn DType

source§

fn into_boxed_dtype(self) -> Box<dyn DType>

source§

impl<'a> AsDevice for &'a Tensor

source§

fn device(&self) -> &dyn Device

source§

fn into_boxed_device(self) -> Box<dyn Device>

source§

impl AsDevice for Tensor

source§

fn device(&self) -> &dyn Device

source§

fn into_boxed_device(self) -> Box<dyn Device>

source§

impl AsRef<Tensor> for Tensor

source§

fn as_ref(&self) -> &Tensor

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl ClampBound for &Tensor

source§

fn bound(&self, input: &Tensor) -> Tensor

source§

impl ClampBound for Tensor

source§

fn bound(&self, input: &Tensor) -> Tensor

source§

impl Clone for Tensor

source§

fn clone(&self) -> Tensor

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 Debug for Tensor

source§

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

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

impl Display for Tensor

source§

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

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

impl<'a, 'b> Div<&'b Tensor> for &'a Tensor

§

type Output = Tensor

The resulting type after applying the / operator.
source§

fn div(self, rhs: &'b Tensor) -> Tensor

Performs the / operation. Read more
source§

impl<'a> Div<&'a Tensor> for Tensor

§

type Output = Tensor

The resulting type after applying the / operator.
source§

fn div(self, rhs: &'a Tensor) -> Tensor

Performs the / operation. Read more
source§

impl<'a> Div<&'a Tensor> for f32

§

type Output = Tensor

The resulting type after applying the / operator.
source§

fn div(self, rhs: &'a Tensor) -> Self::Output

Performs the / operation. Read more
source§

impl<'a> Div<&'a Tensor> for f64

§

type Output = Tensor

The resulting type after applying the / operator.
source§

fn div(self, rhs: &'a Tensor) -> Self::Output

Performs the / operation. Read more
source§

impl<'a> Div<&'a Tensor> for u8

§

type Output = Tensor

The resulting type after applying the / operator.
source§

fn div(self, rhs: &'a Tensor) -> Self::Output

Performs the / operation. Read more
source§

impl<'a, T> Div<T> for &'a Tensor
where T: ElemType,

§

type Output = Tensor

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<T> Div<T> for Tensor
where T: ElemType,

§

type Output = Tensor

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<'a> Div<Tensor> for &'a Tensor

§

type Output = Tensor

The resulting type after applying the / operator.
source§

fn div(self, rhs: Tensor) -> Tensor

Performs the / operation. Read more
source§

impl Div<Tensor> for f32

§

type Output = Tensor

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl Div<Tensor> for f64

§

type Output = Tensor

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl Div<Tensor> for u8

§

type Output = Tensor

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl Div for Tensor

§

type Output = Tensor

The resulting type after applying the / operator.
source§

fn div(self, rhs: Tensor) -> Tensor

Performs the / operation. Read more
source§

impl GenericValue<Basic, Tensor, Tensor> for Tensor

source§

fn gv_tensors(&self) -> Tensor

source§

fn gv_grad(tensor: &Tensor, grad_map: &HashMap<usize, Tensor>) -> Tensor

source§

fn gv_grad_map(tensor: &Tensor, grad: Tensor, out: &mut HashMap<usize, Tensor>)

source§

impl Hash for Tensor

source§

fn hash<H>(&self, hasher: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, 'b> Mul<&'b Tensor> for &'a Tensor

§

type Output = Tensor

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &'b Tensor) -> Tensor

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Tensor> for Tensor

§

type Output = Tensor

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &'a Tensor) -> Tensor

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Tensor> for f32

§

type Output = Tensor

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &'a Tensor) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Tensor> for f64

§

type Output = Tensor

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &'a Tensor) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Tensor> for u8

§

type Output = Tensor

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &'a Tensor) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, T> Mul<T> for &'a Tensor
where T: ElemType,

§

type Output = Tensor

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T> Mul<T> for Tensor
where T: ElemType,

§

type Output = Tensor

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a> Mul<Tensor> for &'a Tensor

§

type Output = Tensor

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Tensor) -> Tensor

Performs the * operation. Read more
source§

impl Mul<Tensor> for f32

§

type Output = Tensor

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<Tensor> for f64

§

type Output = Tensor

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<Tensor> for u8

§

type Output = Tensor

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul for Tensor

§

type Output = Tensor

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Tensor) -> Tensor

Performs the * operation. Read more
source§

impl<'a> Neg for &'a Tensor

§

type Output = Tensor

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl Neg for Tensor

§

type Output = Tensor

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl Ord for Tensor

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Tensor

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Tensor

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Shape for Tensor

source§

fn shape(&self) -> &[usize]

source§

fn size(&self) -> usize

source§

fn shape_at<I: Dim>(&self, i: I) -> usize

source§

fn shape_before<const N: usize>(&self) -> [usize; N]

source§

fn shape_of<D: Dims>(&self, d: D) -> Vec<usize>

source§

fn size_of<D: Dims>(&self, d: D) -> usize

source§

fn ndim(&self) -> usize

source§

fn dim<I: Dim>(&self, i: I) -> usize

source§

fn dims<D: Dims>(&self, d: D) -> Vec<usize>

source§

fn shape_transpose(&self, dim0: usize, dim1: usize) -> Vec<usize>

source§

fn shape_eq<S: Shape + ?Sized>(&self, rhs: &S) -> bool

source§

fn shape_ndim_eq<S: Shape + ?Sized>(&self, rhs: &S) -> bool

source§

fn shape_size_eq<S: Shape + ?Sized>(&self, rhs: &S) -> bool

source§

fn shape_expand_left<T: Shape + ?Sized>(&self, rhs: &T) -> Vec<usize>

source§

fn shape_expand_right<T: Shape + ?Sized>(&self, rhs: &T) -> Vec<usize>

source§

fn shape_broadcast_to<T: Shape + ?Sized>( &self, rhs: &T ) -> Result<(Vec<usize>, bool, bool)>

source§

fn shape_broadcast_matmul<S: Shape + ?Sized>( &self, rhs: &S ) -> Result<(Vec<usize>, Vec<usize>, Vec<usize>, bool, bool)>

source§

fn shape_reduce<T: AsRef<[usize]>>(&self, dims: T, keep_dim: bool) -> Vec<usize>

source§

fn shape_conv1d<S: Shape + ?Sized>( &self, kernel: &S, padding: usize, stride: usize, dilation: usize ) -> Vec<usize>

source§

fn shape_conv2d<S: Shape + ?Sized>( &self, kernel: &S, padding: &[usize; 2], stride: &[usize; 2], dilation: &[usize; 2] ) -> Vec<usize>

source§

fn shape_conv_transpose1d<S: Shape + ?Sized>( &self, kernel: &S, padding: usize, output_padding: usize, stride: usize, dilation: usize ) -> Vec<usize>

source§

fn shape_conv_transpose2d<S: Shape + ?Sized>( &self, kernel: &S, padding: &[usize; 2], output_padding: &[usize; 2], stride: &[usize; 2], dilation: &[usize; 2] ) -> Vec<usize>

source§

fn shape_avg_pool1d( &self, kernel_size: usize, stride: usize, padding: usize ) -> Vec<usize>

source§

fn shape_avg_pool2d( &self, kernel_size: &(usize, usize), stride: &(usize, usize), padding: &(usize, usize) ) -> Vec<usize>

source§

fn shape_max_pool1d( &self, kernel_size: usize, stride: usize, padding: usize, dialation: usize ) -> Vec<usize>

source§

fn shape_max_pool2d( &self, kernel_size: &(usize, usize), stride: &(usize, usize), padding: &(usize, usize), dialation: &(usize, usize) ) -> Vec<usize>

source§

fn shape_upsample_nearest1d(&self, size: usize) -> Vec<usize>

source§

fn shape_upsample_nearest2d(&self, size: &(usize, usize)) -> Vec<usize>

source§

impl<'a, 'b> Sub<&'b Tensor> for &'a Tensor

§

type Output = Tensor

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &'b Tensor) -> Tensor

Performs the - operation. Read more
source§

impl<'a> Sub<&'a Tensor> for Tensor

§

type Output = Tensor

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &'a Tensor) -> Tensor

Performs the - operation. Read more
source§

impl<'a> Sub<&'a Tensor> for f32

§

type Output = Tensor

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &'a Tensor) -> Self::Output

Performs the - operation. Read more
source§

impl<'a> Sub<&'a Tensor> for f64

§

type Output = Tensor

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &'a Tensor) -> Self::Output

Performs the - operation. Read more
source§

impl<'a> Sub<&'a Tensor> for u8

§

type Output = Tensor

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &'a Tensor) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, T> Sub<T> for &'a Tensor
where T: ElemType,

§

type Output = Tensor

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T> Sub<T> for Tensor
where T: ElemType,

§

type Output = Tensor

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<'a> Sub<Tensor> for &'a Tensor

§

type Output = Tensor

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Tensor) -> Tensor

Performs the - operation. Read more
source§

impl Sub<Tensor> for f32

§

type Output = Tensor

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Sub<Tensor> for f64

§

type Output = Tensor

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Sub<Tensor> for u8

§

type Output = Tensor

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Sub for Tensor

§

type Output = Tensor

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Tensor) -> Tensor

Performs the - operation. Read more
source§

impl TensorIter for Tensor

source§

fn tensor_iter(&self) -> impl Iterator<Item = &Tensor>

source§

impl ValueSpec for Tensor

source§

impl<'a> View for &'a Tensor

source§

fn dtype(&self) -> Dtype

The Dtype of the tensor
source§

fn shape(&self) -> &[usize]

The shape of the tensor
source§

fn data(&self) -> Cow<'_, [u8]>

The data of the tensor
source§

fn data_len(&self) -> usize

The length of the data, in bytes. This is necessary as this might be faster to get than data().len() for instance for tensors residing in GPU.
source§

impl WithParams for Tensor

source§

fn gather_by_id(&self, params: &mut HashMap<usize, Tensor>)

source§

fn update_by_id(&self, params: &mut HashMap<usize, Tensor>)

source§

fn gather_by_name( &self, params: &mut HashMap<String, Tensor>, prefix: &str, name: &str )

source§

fn update_by_name( &self, params: &mut HashMap<String, Tensor>, prefix: &str, name: &str )

source§

impl Eq for Tensor

Auto Trait Implementations§

§

impl Freeze for Tensor

§

impl !RefUnwindSafe for Tensor

§

impl !Send for Tensor

§

impl !Sync for Tensor

§

impl Unpin for Tensor

§

impl !UnwindSafe for Tensor

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T, M> ApplyModule<M> for T
where M: Module<Input = T>,

source§

fn apply(&self, module: M) -> M::Output

source§

impl<'short, T, Target> AsGeneralizedRef<'short, &'short Target> for T
where T: AsRef<Target> + ?Sized, Target: ?Sized,

source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

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

Initializes a with the given initializer. Read more
source§

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

Dereferences the given pointer. Read more
source§

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

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

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

impl<T> ToOwned for T
where 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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> Value for T
where T: ValueSpec + GenericValue<<T as ValueSpec>::Kind, <T as ValueSpec>::Tensors, <T as ValueSpec>::Gradient>,

source§

fn tensors(&self) -> <T as ValueSpec>::Tensors

source§

fn grad( tensors: &<T as ValueSpec>::Tensors, grad_map: &HashMap<usize, Tensor> ) -> <T as ValueSpec>::Gradient

source§

fn grad_map( tensors: &<T as ValueSpec>::Tensors, grad: <T as ValueSpec>::Gradient, out: &mut HashMap<usize, Tensor> )

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,