Trait burn_tensor::BasicOps

source ·
pub trait BasicOps<B: Backend>: TensorKind<B> {
    type Elem: 'static;

Show 13 methods // Required methods fn empty<const D: usize>( shape: Shape<D>, device: &B::Device ) -> Self::Primitive<D>; fn shape<const D: usize>(tensor: &Self::Primitive<D>) -> Shape<D>; fn reshape<const D1: usize, const D2: usize>( tensor: Self::Primitive<D1>, shape: Shape<D2> ) -> Self::Primitive<D2>; fn slice<const D1: usize, const D2: usize>( tensor: Self::Primitive<D1>, range: [Range<usize>; D2] ) -> Self::Primitive<D1>; fn slice_assign<const D1: usize, const D2: usize>( tensor: Self::Primitive<D1>, ranges: [Range<usize>; D2], value: Self::Primitive<D1> ) -> Self::Primitive<D1>; fn device<const D: usize>(tensor: &Self::Primitive<D>) -> B::Device; fn to_device<const D: usize>( tensor: Self::Primitive<D>, device: &B::Device ) -> Self::Primitive<D>; fn into_data<const D: usize>( tensor: Self::Primitive<D> ) -> Data<Self::Elem, D>; fn from_data<const D: usize>( data: Data<Self::Elem, D>, device: &B::Device ) -> Self::Primitive<D>; fn repeat<const D: usize>( tensor: Self::Primitive<D>, dim: usize, times: usize ) -> Self::Primitive<D>; fn cat<const D: usize>( vectors: Vec<Self::Primitive<D>>, dim: usize ) -> Self::Primitive<D>; fn equal<const D: usize>( lhs: Self::Primitive<D>, rhs: Self::Primitive<D> ) -> Tensor<B, D, Bool>; // Provided method fn elem_type_name() -> &'static str { ... }
}
Expand description

Trait that list all operations that can be applied on all tensors.

Warnings

This is an internal trait, use the public API provided by tensor struct.

Required Associated Types§

source

type Elem: 'static

The type of the tensor elements.

Required Methods§

source

fn empty<const D: usize>( shape: Shape<D>, device: &B::Device ) -> Self::Primitive<D>

Creates an empty tensor with the given shape.

Arguments
  • shape - The shape of the tensor.
  • device - The device on which the tensor will be allocated.
Returns

The empty tensor.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For creating empty tensors, users should prefer the Tensor::empty function, which is more high-level and designed for public use.

source

fn shape<const D: usize>(tensor: &Self::Primitive<D>) -> Shape<D>

Returns the shape of the tensor.

Arguments
  • tensor - The tensor.
Returns

The shape of the tensor.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For getting the shape of a tensor, users should prefer the Tensor::shape function, which is more high-level and designed for public use.

source

fn reshape<const D1: usize, const D2: usize>( tensor: Self::Primitive<D1>, shape: Shape<D2> ) -> Self::Primitive<D2>

Reshapes the tensor.

Arguments
  • tensor - The tensor.
  • shape - The new shape of the tensor.
Returns

The reshaped tensor.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For reshaping a tensor, users should prefer the Tensor::reshape function, which is more high-level and designed for public use.

source

fn slice<const D1: usize, const D2: usize>( tensor: Self::Primitive<D1>, range: [Range<usize>; D2] ) -> Self::Primitive<D1>

Select tensor elements corresponding for the given ranges.

Arguments
  • tensor - The tensor.
  • ranges - The ranges of the elements to select.
Returns

The selected elements.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For selecting elements of a tensor, users should prefer the Tensor::slice function, which is more high-level and designed for public use.

source

fn slice_assign<const D1: usize, const D2: usize>( tensor: Self::Primitive<D1>, ranges: [Range<usize>; D2], value: Self::Primitive<D1> ) -> Self::Primitive<D1>

Assigns the given value to the tensor elements corresponding for the given ranges.

Arguments
  • tensor - The tensor.
  • ranges - The ranges of the elements to select.
  • value - The value to assign.
Returns

The tensor with the assigned values.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For assigning values to elements of a tensor, users should prefer the Tensor::slice_assign function, which is more high-level and designed for public use.

source

fn device<const D: usize>(tensor: &Self::Primitive<D>) -> B::Device

Returns the device on which the tensor is allocated.

Arguments
  • tensor - The tensor.
Returns

The device on which the tensor is allocated.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For getting the device of a tensor, users should prefer the Tensor::device function, which is more high-level and designed for public use.

source

fn to_device<const D: usize>( tensor: Self::Primitive<D>, device: &B::Device ) -> Self::Primitive<D>

Moves the tensor to the given device.

Arguments
  • tensor - The tensor.
  • device - The device on which the tensor will be moved.
Returns

The tensor on the given device.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For moving a tensor to a device, users should prefer the Tensor::to_device function, which is more high-level and designed for public use.

source

fn into_data<const D: usize>(tensor: Self::Primitive<D>) -> Data<Self::Elem, D>

Extracts the data from the tensor.

Arguments
  • tensor - The tensor.
Returns

The data of the tensor.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For extracting the data of a tensor, users should prefer the Tensor::into_data function, which is more high-level and designed for public use.

source

fn from_data<const D: usize>( data: Data<Self::Elem, D>, device: &B::Device ) -> Self::Primitive<D>

Creates a tensor from the given data.

Arguments
  • data - The data of the tensor.
  • device - The device on which the tensor will be allocated.
Returns

The tensor.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For creating a tensor from data, users should prefer the Tensor::from_data function, which is more high-level and designed for public use.

source

fn repeat<const D: usize>( tensor: Self::Primitive<D>, dim: usize, times: usize ) -> Self::Primitive<D>

Repeat the tensor along the given dimension.

Arguments
  • tensor - The tensor.
  • dim - The dimension along which the tensor will be repeated.
  • times - The number of times the tensor will be repeated.
Returns

The repeated tensor.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For repeating a tensor, users should prefer the Tensor::repeat function, which is more high-level and designed for public use.

source

fn cat<const D: usize>( vectors: Vec<Self::Primitive<D>>, dim: usize ) -> Self::Primitive<D>

Concatenates the given tensors along the given dimension.

Arguments
  • vectors - The tensors to concatenate.
  • dim - The dimension along which the tensors will be concatenated.
Returns

The concatenated tensor.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For concatenating tensors, users should prefer the Tensor::cat function, which is more high-level and designed for public use.

source

fn equal<const D: usize>( lhs: Self::Primitive<D>, rhs: Self::Primitive<D> ) -> Tensor<B, D, Bool>

Equates the given tensors.

Arguments
  • lhs - The left hand side tensor.
  • rhs - The right hand side tensor.
Returns

The tensor of booleans indicating whether the corresponding elements are equal.

Remarks

This is a low-level function used internally by the library to call different backend functions with static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.

For equating tensors, users should prefer the Tensor::equal function, which is more high-level and designed for public use.

Provided Methods§

source

fn elem_type_name() -> &'static str

Returns the name of the element type.

Implementors§

source§

impl<B: Backend> BasicOps<B> for Bool

§

type Elem = bool

source§

impl<B: Backend> BasicOps<B> for Float

§

type Elem = <B as Backend>::FloatElem

source§

impl<B: Backend> BasicOps<B> for Int

§

type Elem = <B as Backend>::IntElem