Struct burn_tensor::Tensor

source ·
pub struct Tensor<B, const D: usize, K = Float>where
    B: Backend,
    K: TensorKind<B>,{ /* private fields */ }
Expand description

A tensor with a given backend, shape and data type.

Implementations§

source§

impl<B, const D: usize, K> Tensor<B, D, K>where B: Backend, K: TensorKind<B>,

source

pub fn new(primitive: K::Primitive<D>) -> Self

Constructs a new Tensor.

source§

impl<B, const D: usize, K> Tensor<B, D, K>where B: Backend, K: BasicOps<B>,

source

pub fn into_primitive(self) -> K::Primitive<D>

Converts the tensor into a primitive tensor.

source

pub fn from_primitive(tensor: K::Primitive<D>) -> Self

Converts from a primitive tensor into a tensor.

source

pub fn empty<S: Into<Shape<D>>>(shape: S) -> Self

Create an empty tensor of the given shape.

source

pub fn empty_device<S: Into<Shape<D>>>(shape: S, device: &B::Device) -> Self

Create an empty tensor of the given shape.

source

pub fn dims(&self) -> [usize; D]

Returns the dimensions of the current tensor.

Equivalent to tensor.shape().dims.

source

pub fn shape(&self) -> Shape<D>

Returns the shape of the current tensor.

source

pub fn reshape<const D2: usize, S: Into<Shape<D2>>>( self, shape: S ) -> Tensor<B, D2, K>

Reshape the tensor to have the given shape.

Panics

If the tensor can not be reshape to the given shape.

source

pub fn flatten<const D2: usize>( self, start_dim: usize, end_dim: usize ) -> Tensor<B, D2, K>

Flatten the tensor along a given range of dimensions.

This function collapses the specified range of dimensions into a single dimension, effectively flattening the tensor in that range.

Arguments
  • start_dim: The starting dimension of the range to be flattened.
  • end_dim: The ending dimension of the range to be flattened (inclusive).
Type Parameters
  • D2: The resulting number of dimensions in the flattened tensor.
Returns

A new Tensor<B, D2, K> instance with the specified range of dimensions flattened.

Example

use burn_tensor::backend::Backend;
use burn_tensor::{Tensor, Shape};

fn example<B: Backend>() {
    let tensor = Tensor::<B, 3>::ones(Shape::new([2, 3, 4]));

    // Given a 3D tensor with dimensions (2, 3, 4), flatten the dimensions between indices 1 and 2:
    let flattened_tensor: Tensor::<B, 2> = tensor.flatten(1, 2);

    // The resulting tensor will have dimensions (2, 12).
   println!("{:?}", flattened_tensor.shape());
}
source

pub fn squeeze<const D2: usize>(self, dim: usize) -> Tensor<B, D2, K>

Squeeze the tensor along the given dimension, removing the specified dimension of size one, and effectively reducing the rank of the tensor by one.

Arguments
  • dim: The dimension to be squeezed.
Type Parameters
  • ‘D2’: The resulting number of dimensions in the squeezed tensor.
Returns

A new Tensor<B, D2, K> instance with the specified dimenension removed.

Example

use burn_tensor::backend::Backend;
use burn_tensor::{Tensor, Shape};

fn example<B: Backend>() {
    let tensor = Tensor::<B, 3>::ones(Shape::new([2, 1, 4]));

    // Given a 3D tensor with dimensions (2, 1, 4), squeeze the dimension 1
    let squeezed_tensor: Tensor::<B, 2> = tensor.squeeze(1);

    // Resulting tensor will have dimensions (2, 4)
    println!("{:?}", squeezed_tensor.shape());
}
source

pub fn unsqueeze<const D2: usize>(self) -> Tensor<B, D2, K>

Unsqueeze the current tensor. Create new dimensions to fit the given size.

Panics

If the output size is higher than the current tensor.

Example
use burn_tensor::backend::Backend;
use burn_tensor::{Tensor, Shape};

fn example<B: Backend>() {
    let tensor = Tensor::<B, 2>::ones(Shape::new([3, 3]));
    let tensor = tensor.unsqueeze::<4>();
    println!("{:?}", tensor.shape());
    // Shape { dims: [1, 1, 3, 3] }
}
source

pub fn slice<const D2: usize>(self, ranges: [Range<usize>; D2]) -> Self

Returns a tensor containing the elements selected from the given ranges.

Panics

If a range exceeds the number of elements on a dimension.

Example
use burn_tensor::backend::Backend;
use burn_tensor::{Tensor, Shape};

fn example<B: Backend>() {
    let tensor = Tensor::<B, 3>::ones(Shape::new([2, 3, 3]));
    let tensor_slices = tensor.slice([0..1, 0..3, 1..2]);
    println!("{:?}", tensor_slices.dims()); // [1, 3, 2]
     
}
source

pub fn slice_assign<const D2: usize>( self, ranges: [Range<usize>; D2], values: Self ) -> Self

Returns a copy of the current tensor with the selected elements changed to the new ones at the selected indices.

Panics
  • If a range exceeds the number of elements on a dimension.
  • If the given values don’t match the given ranges.
Example
use burn_tensor::backend::Backend;
use burn_tensor::Tensor;

fn example<B: Backend>() {
    let tensor = Tensor::<B, 3>::ones([2, 3, 3]);
    let values = Tensor::<B, 3>::zeros([1, 1, 1]);
    let tensor_sliced = tensor.slice_assign([0..1, 0..1, 0..1], values);
    println!("{:?}", tensor_sliced.dims()); // [2, 3, 3]
}
source

pub fn device(&self) -> B::Device

Returns the device of the current tensor.

source

pub fn to_device(self, device: &B::Device) -> Self

Returns a new tensor on the given device.

source

pub fn into_data(self) -> Data<K::Elem, D>

Returns the data of the current tensor.

source

pub fn to_data(&self) -> Data<K::Elem, D>

Returns the data of the current tensor without taking ownership.

source

pub fn from_data<T>(data: T) -> Selfwhere T: Into<Data<K::Elem, D>>,

Create a tensor from the given data.

source

pub fn from_data_device<T>(data: T, device: &B::Device) -> Selfwhere T: Into<Data<K::Elem, D>>,

Create a tensor from the given data on the given device.

source

pub fn repeat(self, dim: usize, times: usize) -> Self

Repeat the tensor along the given dimension.

Panics

If the selected dimension more than one item.

source

pub fn equal(self, other: Self) -> Tensor<B, D, Bool>

Applies element wise equal comparison and returns a boolean tensor.

Panics

If the two tensors don’t have the same shape.

source

pub fn cat(tensors: Vec<Self>, dim: usize) -> Self

Concatenates all tensors into a new one along the given dimension.

Panics

If all tensors don’t have the same shape.

source§

impl<B, const D: usize> Tensor<B, D, Bool>where B: Backend,

source

pub fn from_bool(data: Data<bool, D>) -> Self

Create a boolean tensor from data.

source

pub fn from_bool_device(data: Data<bool, D>, device: &B::Device) -> Self

Create a boolean tensor from data on the given device.

source

pub fn into_int(self) -> Tensor<B, D, Int>

Convert the bool tensor into an int tensor.

source§

impl<const D: usize, B> Tensor<B, D>where B: Backend,

source

pub fn inplace<F: FnOnce(Self) -> Self>(&mut self, func: F)

Executes an operation on the tensor and modifies its value.

Notes

This won’t necessary reuse the same tensor data/buffer, but it should if there is no other reference pointing to the same tensor.

Wrapping operations with inplace is not an optimization, it’s mainly there if you want to mutate a tensor by using owned operations. A plausible usage would be to update the weights of a mutable model reference.

source

pub fn exp(self) -> Self

Applies element wise exponential operation.

y = e^x

source

pub fn log(self) -> Self

Applies element wise natural log operation ln.

y = log(x)

source

pub fn log1p(self) -> Self

Applies the natural logarithm of one plus the input tensor, element-wise.

y = log(x+1)

source

pub fn erf(self) -> Self

Applies the error function element wise.

y = erf(x)

source

pub fn powf(self, value: f32) -> Self

Applies element wise power operation.

y = x^a

source

pub fn sqrt(self) -> Self

Applies element wise root square operation.

source

pub fn cos(self) -> Self

Applies element wise cosine operation.

source

pub fn sin(self) -> Self

Applies element wise sine operation.

source

pub fn tanh(self) -> Self

Applies element wise hyperbolic tangent operation.

source

pub fn from_floats<A: Into<Data<f32, D>>>(floats: A) -> Self

Create a tensor from floats (f32).

Example
use burn_tensor::backend::Backend;
use burn_tensor::Tensor;

fn example<B: Backend>() {
    let _ = Tensor::<B, 1>::from_floats([1.0, 2.0]);
    let _ = Tensor::<B, 2>::from_floats([[1.0, 2.0], [3.0, 4.0]]);
}
source

pub fn zeros_like(&self) -> Self

Returns a new tensor with the same shape and device as the current tensor filled with zeros.

source

pub fn ones_like(&self) -> Self

Returns a new tensor with the same shape and device as the current tensor filled with ones.

source

pub fn random_like(&self, distribution: Distribution<B::FloatElem>) -> Self

Returns a new tensor with the same shape and device as the current tensor filled random values sampled from the given distribution.

source

pub fn one_hot(index: usize, num_classes: usize) -> Self

Create a one hot tensor.

Example
use burn_tensor::backend::Backend;
use burn_tensor::Tensor;

fn example<B: Backend>() {
    let one_hot = Tensor::<B, 1>::one_hot(2, 10);
    println!("{}", one_hot.to_data());
    // [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
}
source

pub fn transpose(self) -> Self

Applies the transpose operation.

On matrix and higher dimension tensor, it swap the last two dimensions.

Panics

If the tensor is of 1 dimension or less.

source

pub fn swap_dims(self, dim1: usize, dim2: usize) -> Self

Swap two dimensions.

Panics

If the dimensions exceed the shape of than the tensor.

source

pub fn matmul(self, other: Self) -> Self

Applies the matrix multiplication operation.

C = AB

Panics

If the two tensors dont’ have a compatible shape.

source

pub fn var(self, dim: usize) -> Self

Calculate the variance along the given dimension.

source

pub fn var_bias(self, dim: usize) -> Self

Calculate the variance along the given dimension without applying the Bessel’s correction.

source

pub fn var_mean(self, dim: usize) -> (Self, Self)

Calculate the variance along the given dimension and also returns the mean.

source

pub fn var_mean_bias(self, dim: usize) -> (Self, Self)

Calculate the variance along the given dimension without applying the Bessel’s correction and also returns the mean.

source

pub fn random<S: Into<Shape<D>>>( shape: S, distribution: Distribution<B::FloatElem> ) -> Self

Create a random tensor of the given shape where each element is sampled from the given distribution.

source

pub fn to_full_precision(&self) -> Tensor<B::FullPrecisionBackend, D>

Returns a tensor with full precision based on the selected backend.

source

pub fn from_full_precision(tensor: Tensor<B::FullPrecisionBackend, D>) -> Self

Returns a tensor on the selected backend from a full precision tensor.

source

pub fn detach(self) -> Self

Detach the current tensor from the autodiff graph. This function does nothing when autodiff is not enabled. This can be used in batchers or elsewere to ensure that previous operations are not considered in the autodiff graph.

source

pub fn require_grad(self) -> Self

Mark the tensor to keep gradients during the backward pass. This function does nothing when autodiff is not enabled.

source

pub fn is_require_grad(&self) -> bool

Returns true if the tensor requires gradients during the backward pass.

source

pub fn set_require_grad(self, require_grad: bool) -> Self

Mark the tensor as tracked or untracked depending on the require grad argument. When tracked, the gradients will be available after the backward pass.

This function does nothing when autodiff is not enabled.

source§

impl<const D: usize, B: ADBackend> Tensor<B, D>

source

pub fn backward(&self) -> B::Gradients

Backward pass of the tensor.

source

pub fn grad(&self, grads: &B::Gradients) -> Option<Tensor<B::InnerBackend, D>>

Get the gradients of a tensor if it exist.

Returns a new reference to the same tensor. Therefore the same grad tensor can be accessed multiple times. If you only need to get the gradients one time, consider using grad_remove for better performance.

source

pub fn grad_remove( &self, grads: &mut B::Gradients ) -> Option<Tensor<B::InnerBackend, D>>

Remove the grad tensor from the grads struct returning the result.

source

pub fn inner(self) -> Tensor<B::InnerBackend, D>

Returns the inner tensor without the autodiff information.

source

pub fn from_inner(inner: Tensor<B::InnerBackend, D>) -> Self

Convert a tensor to the autodiff backend.

Arguments
  • inner - The tensor to convert.
Returns

The tensor converted to the autodiff backend.

source§

impl<B> Tensor<B, 1, Int>where B: Backend,

source

pub fn arange(range: Range<usize>) -> Self

Returns a new integer tensor on the default device.

Arguments
  • range - The range of values to generate.
source

pub fn arange_step(range: Range<usize>, step: usize) -> Self

Returns a new integer tensor on the default device.

Arguments
  • range - The range of values to generate.
  • step - The step between each value.
source

pub fn arange_device(range: Range<usize>, device: &B::Device) -> Self

Returns a new integer tensor on the specified device.

Arguments
  • range - The range of values to generate.
  • device - The device to create the tensor on.
source

pub fn arange_step_device( range: Range<usize>, step: usize, device: &B::Device ) -> Self

Returns a new integer tensor on the specified device.

Arguments
  • range - The range of values to generate.
  • step - The step between each value.
source§

impl<const D: usize, B> Tensor<B, D, Int>where B: Backend,

source

pub fn from_ints<A: Into<Data<i32, D>>>(ints: A) -> Self

Create a tensor from integers (i32).

Example
use burn_tensor::backend::Backend;
use burn_tensor::{Tensor, Int};

fn example<B: Backend>() {
    let _x: Tensor<B, 1, Int> = Tensor::from_ints([1, 2]);
    let _y: Tensor<B, 2, Int> = Tensor::from_ints([[1, 2], [3, 4]]);
}
source§

impl<B, const D: usize, K> Tensor<B, D, K>where B: Backend, K: Numeric<B>, K::Elem: Element,

source

pub fn into_scalar(self) -> K::Elem

Convert the tensor into a scalar.

Panics

If the tensor doesn’t have one element.

source

pub fn add(self, other: Self) -> Self

Applies element wise addition operation.

y = x2 + x1

source

pub fn add_scalar<E: ElementConversion>(self, other: E) -> Self

Applies element wise addition operation with a scalar.

y = x + s

source

pub fn sub(self, other: Self) -> Self

Applies element wise substraction operation.

y = x2 - x1

source

pub fn sub_scalar<E: ElementConversion>(self, other: E) -> Self

Applies element wise substraction operation with a scalar.

y = x - s

source

pub fn div(self, other: Self) -> Self

Applies element wise division operation.

y = x2 / x1

source

pub fn div_scalar<E: ElementConversion>(self, other: E) -> Self

Applies element wise division operation with a scalar.

y = x / s

source

pub fn mul(self, other: Self) -> Self

Applies element wise multiplication operation.

y = x2 * x1

source

pub fn mul_scalar<E: ElementConversion>(self, other: E) -> Self

Applies element wise multiplication operation with a scalar.

y = x * s

source

pub fn neg(self) -> Self

Switch sign of each element in the tensor.

y = -x

source

pub fn zeros<S: Into<Shape<D>>>(shape: S) -> Self

Create a tensor of the given shape where each element is zero.

source

pub fn zeros_device<S: Into<Shape<D>>>(shape: S, device: &B::Device) -> Self

Create a tensor of the given shape where each element is zero.

source

pub fn ones<S: Into<Shape<D>>>(shape: S) -> Self

Create a tensor of the given shape where each element is one.

source

pub fn ones_device<S: Into<Shape<D>>>(shape: S, device: &B::Device) -> Self

Create a tensor of the given shape where each element is one.

source

pub fn full<S: Into<Shape<D>>, E: ElementConversion>( shape: S, fill_value: E ) -> Self

Create a tensor of the given shape where each element is equal to the provided value.

source

pub fn full_device<S: Into<Shape<D>>, E: ElementConversion>( shape: S, fill_value: E, device: &B::Device ) -> Self

Create a tensor of the given shape where each element is equal to the provided value.

source

pub fn mean(self) -> Tensor<B, 1, K>

Aggregate all elements in the tensor with the mean operation.

source

pub fn sum(self) -> Tensor<B, 1, K>

Aggregate all elements in the tensor with the sum operation.

source

pub fn mean_dim(self, dim: usize) -> Self

Aggregate all elements along the given dimension or axis in the tensor with the mean operation.

source

pub fn sum_dim(self, dim: usize) -> Self

Aggregate all elements along the given dimension or axis in the tensor with the sum operation.

source

pub fn equal_elem<E: Element>(self, other: E) -> Tensor<B, D, Bool>

Applies element wise equal comparison and returns a boolean tensor.

source

pub fn greater(self, other: Self) -> Tensor<B, D, Bool>

Applies element wise greater comparison and returns a boolean tensor.

Panics

If the two tensors don’t have the same shape.

source

pub fn greater_equal(self, other: Self) -> Tensor<B, D, Bool>

Applies element wise greater-equal comparison and returns a boolean tensor.

Panics

If the two tensors don’t have the same shape.

source

pub fn lower(self, other: Self) -> Tensor<B, D, Bool>

Applies element wise lower comparison and returns a boolean tensor.

Panics

If the two tensors don’t have the same shape.

source

pub fn lower_equal(self, other: Self) -> Tensor<B, D, Bool>

Applies element wise lower-equal comparison and returns a boolean tensor.

Panics

If the two tensors don’t have the same shape.

source

pub fn greater_elem<E: ElementConversion>(self, other: E) -> Tensor<B, D, Bool>

Applies element wise greater comparison and returns a boolean tensor.

source

pub fn greater_equal_elem<E: ElementConversion>( self, other: E ) -> Tensor<B, D, Bool>

Applies element wise greater-equal comparison and returns a boolean tensor.

source

pub fn lower_elem<E: ElementConversion>(self, other: E) -> Tensor<B, D, Bool>

Applies element wise lower comparison and returns a boolean tensor.

source

pub fn lower_equal_elem<E: ElementConversion>( self, other: E ) -> Tensor<B, D, Bool>

Applies element wise lower-equal comparison and returns a boolean tensor.

source

pub fn mask_where(self, mask: Tensor<B, D, Bool>, value: Self) -> Self

Update the given tensor with the value tensor where the mask is true.

This is similar to mask_fill, however the value is a tensor instead of a scalar.

source

pub fn mask_fill<E: ElementConversion>( self, mask: Tensor<B, D, Bool>, value: E ) -> Self

Update the given tensor with the value where the mask is true.

This is similar to mask_where, however the value is a scalar instead of a tensor.

source

pub fn gather(self, dim: usize, indices: Tensor<B, D, Int>) -> Self

Gather tensor elements corresponding to the given indices from the specified dim.

Example using a 3D tensor:

output[i, j, k] = input[indices[i, j, k], j, k]; // dim = 0 output[i, j, k] = input[i, indices[i, j, k], k]; // dim = 1 output[i, j, k] = input[i, j, indices[i, j, k]]; // dim = 2

Notes

The index tensor shoud have the same shape as the original tensor except for the dim specified.

source

pub fn scatter( self, dim: usize, indices: Tensor<B, D, Int>, values: Self ) -> Self

Assign the gathered elements corresponding to the given indices along the speficied dimension from the value tensor to the original tensor using sum reduction.

Example using a 3D tensor:

input[indices[i, j, k], j, k] += values[i, j, k]; // dim = 0 input[i, indices[i, j, k], k] += values[i, j, k]; // dim = 1 input[i, j, indices[i, j, k]] += values[i, j, k]; // dim = 2

Notes

The index tensor shoud have the same shape as the original tensor except for the speficied dimension. The value and index tensors should have the same shape.

Other references to the input tensor will not be modified by this operation.

source

pub fn select(self, dim: usize, indices: Tensor<B, 1, Int>) -> Self

Select the tensor elements along the given dimension corresponding to the given indices.

Example using a 3D tensor:

output[i, j, k] = input[indices[i], j, k]; // dim = 0 output[i, j, k] = input[i, indices[j], k]; // dim = 1 output[i, j, k] = input[i, j, indices[k]]; // dim = 2

source

pub fn select_assign( self, dim: usize, indices: Tensor<B, 1, Int>, values: Tensor<B, D, K> ) -> Self

Assign the selected elements along the given dimension corresponding to the given indices from the value tensor to the original tensor using sum reduction.

Example using a 3D tensor:

input[indices[i], j, k] += values[i, j, k]; // dim = 0 input[i, indices[j], k] += values[i, j, k]; // dim = 1 input[i, j, indices[k]] += values[i, j, k]; // dim = 2

source

pub fn argmax(self, dim: usize) -> Tensor<B, D, Int>

Applies the argmax function along the given dimension and returns an integer tensor.

Example
use burn_tensor::backend::Backend;
use burn_tensor::{Tensor, Shape};

fn example<B: Backend>() {
    let tensor = Tensor::<B, 3>::ones(Shape::new([2, 3, 3]));
    let tensor = tensor.argmax(1);
    println!("{:?}", tensor.shape());
    // Shape { dims: [2, 1, 3] }
}
source

pub fn max(self) -> Tensor<B, 1, K>

Find the maximum value.

source

pub fn max_dim(self, dim: usize) -> Tensor<B, D, K>

Find the maximum value along the given dimension.

source

pub fn max_dim_with_indices( self, dim: usize ) -> (Tensor<B, D, K>, Tensor<B, D, Int>)

Find the maximum value along the given dimension.

Also returns the indices.

source

pub fn argmin(self, dim: usize) -> Tensor<B, D, Int>

Applies the argmin function along the given dimension and returns an integer tensor.

Example
use burn_tensor::backend::Backend;
use burn_tensor::{Tensor, Shape};

fn example<B: Backend>() {
    let tensor = Tensor::<B, 3>::ones(Shape::new([2, 3, 3]));
    let tensor = tensor.argmin(1);
    println!("{:?}", tensor.shape());
    // Shape { dims: [2, 1, 3] }
}
source

pub fn min(self) -> Tensor<B, 1, K>

Find the minimum value.

source

pub fn min_dim(self, dim: usize) -> Tensor<B, D, K>

Find the minimum value along the given dimension.

source

pub fn min_dim_with_indices( self, dim: usize ) -> (Tensor<B, D, K>, Tensor<B, D, Int>)

Find the minimum value along the given dimension.

Also returns the indices.

Trait Implementations§

source§

impl<E, const D: usize, B, K> Add<E> for Tensor<B, D, K>where E: ElementConversion, B: Backend, K: Numeric<B>, K::Elem: Element,

§

type Output = Tensor<B, D, K>

The resulting type after applying the + operator.
source§

fn add(self, other: E) -> Self

Performs the + operation. Read more
source§

impl<B, const D: usize, K> Add<Tensor<B, D, K>> for Tensor<B, D, K>where B: Backend, K: Numeric<B>, K::Elem: Element,

§

type Output = Tensor<B, D, K>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Tensor<B, D, K>) -> Self

Performs the + operation. Read more
source§

impl<B: Backend, const D: usize> BitXor<T> for Tensor<B, D>

§

type Output = Tensor<B, D, Float>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, _: T) -> Self::Output

Performs the ^ operation. Read more
source§

impl<B, const D: usize, K> Clone for Tensor<B, D, K>where B: Backend + Clone, K: TensorKind<B> + Clone, K::Primitive<D>: Clone,

source§

fn clone(&self) -> Tensor<B, D, K>

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<B, const D: usize, K> Debug for Tensor<B, D, K>where B: Backend + Debug, K: TensorKind<B> + Debug, K::Primitive<D>: Debug,

source§

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

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

impl<B, const D: usize, K> Display for Tensor<B, D, K>where B: Backend, B::IntElem: Display, K: BasicOps<B>, <K as BasicOps<B>>::Elem: Debug,

Pretty print tensors

source§

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

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

impl<E, const D: usize, B, K> Div<E> for Tensor<B, D, K>where E: ElementConversion, B: Backend, K: Numeric<B>, K::Elem: Element,

§

type Output = Tensor<B, D, K>

The resulting type after applying the / operator.
source§

fn div(self, other: E) -> Self

Performs the / operation. Read more
source§

impl<B, const D: usize, K> Div<Tensor<B, D, K>> for Tensor<B, D, K>where B: Backend, K: Numeric<B>, K::Elem: Element,

§

type Output = Tensor<B, D, K>

The resulting type after applying the / operator.
source§

fn div(self, rhs: Tensor<B, D, K>) -> Self

Performs the / operation. Read more
source§

impl<E, const D: usize, B, K> Mul<E> for Tensor<B, D, K>where E: ElementConversion, B: Backend, K: Numeric<B>, K::Elem: Element,

§

type Output = Tensor<B, D, K>

The resulting type after applying the * operator.
source§

fn mul(self, other: E) -> Self

Performs the * operation. Read more
source§

impl<B, const D: usize, K> Mul<Tensor<B, D, K>> for Tensor<B, D, K>where B: Backend, K: Numeric<B>, K::Elem: Element,

§

type Output = Tensor<B, D, K>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Tensor<B, D, K>) -> Self

Performs the * operation. Read more
source§

impl<B, const D: usize, K> Neg for Tensor<B, D, K>where B: Backend, K: Numeric<B>, K::Elem: Element,

§

type Output = Tensor<B, D, K>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl<E, const D: usize, B, K> Sub<E> for Tensor<B, D, K>where E: ElementConversion, B: Backend, K: Numeric<B>, K::Elem: Element,

§

type Output = Tensor<B, D, K>

The resulting type after applying the - operator.
source§

fn sub(self, other: E) -> Self

Performs the - operation. Read more
source§

impl<B, const D: usize, K> Sub<Tensor<B, D, K>> for Tensor<B, D, K>where B: Backend, K: Numeric<B>, K::Elem: Element,

§

type Output = Tensor<B, D, K>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Tensor<B, D, K>) -> Self

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<B, const D: usize, K> RefUnwindSafe for Tensor<B, D, K>where <K as TensorKind<B>>::Primitive<D>: RefUnwindSafe,

§

impl<B, const D: usize, K> Send for Tensor<B, D, K>where <K as TensorKind<B>>::Primitive<D>: Send,

§

impl<B, const D: usize, K> Sync for Tensor<B, D, K>where <K as TensorKind<B>>::Primitive<D>: Sync,

§

impl<B, const D: usize, K> Unpin for Tensor<B, D, K>where <K as TensorKind<B>>::Primitive<D>: Unpin,

§

impl<B, const D: usize, K> UnwindSafe for Tensor<B, D, K>where <K as TensorKind<B>>::Primitive<D>: UnwindSafe,

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<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<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> ToString for Twhere 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 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