pub struct NdArrayBackend<E> { /* private fields */ }
Expand description

The ndarray backend.

Trait Implementations§

source§

impl<E: FloatNdArrayElement> ActivationOps<NdArrayBackend<E>> for NdArrayBackend<E>

source§

fn relu<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, D>

Applies the ReLU activation function. Read more
source§

fn relu_backward<const D: usize>( output: <B as Backend>::TensorPrimitive<D>, grad: <B as Backend>::TensorPrimitive<D> ) -> <B as Backend>::TensorPrimitive<D>

Applies the ReLU activation function backward. Read more
source§

fn gelu<const D: usize>( tensor: <B as Backend>::TensorPrimitive<D> ) -> <B as Backend>::TensorPrimitive<D>

Applies the Gelu activation function. Read more
source§

fn gelu_backward<const D: usize>( x: <B as Backend>::TensorPrimitive<D>, grad: <B as Backend>::TensorPrimitive<D> ) -> <B as Backend>::TensorPrimitive<D>

Applies the Gelu activation function backward. Read more
source§

impl<E: FloatNdArrayElement> Backend for NdArrayBackend<E>

§

type Device = NdArrayDevice

Device type.
§

type FullPrecisionElem = f32

Full precision float element type.
§

type FullPrecisionBackend = NdArrayBackend<f32>

Pointer to another backend that have a full precision float element type
§

type TensorPrimitive<const D: usize> = NdArrayTensor<E, D>

Tensor primitive to be used for all float operations.
§

type FloatElem = E

Float element type.
§

type IntTensorPrimitive<const D: usize> = NdArrayTensor<i64, D>

Tensor primitive to be used for all int operations.
§

type IntElem = i64

Int element type.
§

type BoolTensorPrimitive<const D: usize> = NdArrayTensor<bool, D>

Tensor primitive to be used for all bool operations.
source§

fn ad_enabled() -> bool

If autodiff is enabled.
source§

fn name() -> String

Name of the backend.
source§

fn seed(seed: u64)

Seed the backend.
source§

impl<E: FloatNdArrayElement> BoolTensorOps<NdArrayBackend<E>> for NdArrayBackend<E>

source§

fn bool_from_data<const D: usize>( data: Data<bool, D>, _device: &NdArrayDevice ) -> NdArrayTensor<bool, D>

Creates a tensor from the data structure. Read more
source§

fn bool_shape<const D: usize>( tensor: &<NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D> ) -> Shape<D>

Returns the shape of the tensor. Read more
source§

fn bool_to_data<const D: usize>( tensor: &<NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D> ) -> Data<bool, D>

Gets the data from the tensor. Read more
source§

fn bool_into_data<const D: usize>( tensor: <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D> ) -> Data<bool, D>

Converts the tensor to a data structure. Read more
source§

fn bool_to_device<const D: usize>( tensor: NdArrayTensor<bool, D>, _device: &NdArrayDevice ) -> NdArrayTensor<bool, D>

Moves the tensor to the device.
source§

fn bool_reshape<const D1: usize, const D2: usize>( tensor: NdArrayTensor<bool, D1>, shape: Shape<D2> ) -> NdArrayTensor<bool, D2>

Reshapes the tensor. Read more
source§

fn bool_slice<const D1: usize, const D2: usize>( tensor: NdArrayTensor<bool, D1>, ranges: [Range<usize>; D2] ) -> NdArrayTensor<bool, D1>

Gets the values from the tensor for the given ranges. Read more
source§

fn bool_into_int<const D: usize>( tensor: <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D> ) -> NdArrayTensor<i64, D>

Converts bool tensor to int tensor. Read more
source§

fn bool_device<const D: usize>( _tensor: &<NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D> ) -> <NdArrayBackend<E> as Backend>::Device

Gets the device of the tensor. Read more
source§

fn bool_empty<const D: usize>( shape: Shape<D>, _device: &<NdArrayBackend<E> as Backend>::Device ) -> <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D>

Creates a new bool tensor. Read more
source§

fn bool_slice_assign<const D1: usize, const D2: usize>( tensor: <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D1>, ranges: [Range<usize>; D2], value: <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D1> ) -> <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D1>

Sets the values in the tensor for the given ranges. Read more
source§

fn bool_cat<const D: usize>( tensors: Vec<<NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D>>, dim: usize ) -> <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D>

Concatenates the tensors along the given dimension. Read more
source§

fn bool_equal<const D: usize>( lhs: <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D>, rhs: <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D> ) -> <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D>

Equates the two tensors. Read more
source§

fn bool_equal_elem<const D: usize>( lhs: <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D>, rhs: bool ) -> <NdArrayBackend<E> as Backend>::BoolTensorPrimitive<D>

Equates the tensor with the element. Read more
source§

fn bool_repeat<const D: usize>( tensor: <B as Backend>::BoolTensorPrimitive<D>, dim: usize, times: usize ) -> <B as Backend>::BoolTensorPrimitive<D>

Repeats one dimension of the tensor a given number of times along that dimension. Read more
source§

impl<E: Clone> Clone for NdArrayBackend<E>

source§

fn clone(&self) -> NdArrayBackend<E>

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<E: Debug> Debug for NdArrayBackend<E>

source§

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

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

impl<E: Default> Default for NdArrayBackend<E>

source§

fn default() -> NdArrayBackend<E>

Returns the “default value” for a type. Read more
source§

impl<E: FloatNdArrayElement> IntTensorOps<NdArrayBackend<E>> for NdArrayBackend<E>

source§

fn int_from_data<const D: usize>( data: Data<i64, D>, _device: &NdArrayDevice ) -> NdArrayTensor<i64, D>

Creates a tensor from the data structure. Read more
source§

fn int_shape<const D: usize>(tensor: &NdArrayTensor<i64, D>) -> Shape<D>

Returns the shape of the tensor. Read more
source§

fn int_to_data<const D: usize>(tensor: &NdArrayTensor<i64, D>) -> Data<i64, D>

Gets the data from the tensor. Read more
source§

fn int_into_data<const D: usize>(tensor: NdArrayTensor<i64, D>) -> Data<i64, D>

Converts the tensor to a data structure. Read more
source§

fn int_to_device<const D: usize>( tensor: NdArrayTensor<i64, D>, _device: &NdArrayDevice ) -> NdArrayTensor<i64, D>

Moves the tensor to the given device.
source§

fn int_reshape<const D1: usize, const D2: usize>( tensor: NdArrayTensor<i64, D1>, shape: Shape<D2> ) -> NdArrayTensor<i64, D2>

Reshapes the tensor. Read more
source§

fn int_slice<const D1: usize, const D2: usize>( tensor: NdArrayTensor<i64, D1>, ranges: [Range<usize>; D2] ) -> NdArrayTensor<i64, D1>

Gets the element at the given indices. Read more
source§

fn int_device<const D: usize>( _tensor: &NdArrayTensor<i64, D> ) -> <NdArrayBackend<E> as Backend>::Device

Gets the device of the tensor. Read more
source§

fn int_empty<const D: usize>( shape: Shape<D>, _device: &<NdArrayBackend<E> as Backend>::Device ) -> NdArrayTensor<i64, D>

Creates a new int tensor. Read more
source§

fn int_mask_where<const D: usize>( tensor: NdArrayTensor<i64, D>, mask: NdArrayTensor<bool, D>, source: NdArrayTensor<i64, D> ) -> NdArrayTensor<i64, D>

Fills the tensor with values from the source tensor if the mask is true at the given indices. Read more
source§

fn int_mask_fill<const D: usize>( tensor: NdArrayTensor<i64, D>, mask: NdArrayTensor<bool, D>, value: i64 ) -> NdArrayTensor<i64, D>

Fills the tensor with the given value if the mask is true at the given indices. Read more
source§

fn int_slice_assign<const D1: usize, const D2: usize>( tensor: NdArrayTensor<i64, D1>, ranges: [Range<usize>; D2], value: NdArrayTensor<i64, D1> ) -> NdArrayTensor<i64, D1>

Sets the element at the given indices. Read more
source§

fn int_cat<const D: usize>( tensors: Vec<NdArrayTensor<i64, D>>, dim: usize ) -> NdArrayTensor<i64, D>

Concatenates the given tensors along the given dimension. Read more
source§

fn int_equal<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: NdArrayTensor<i64, D> ) -> NdArrayTensor<bool, D>

Elementwise equality comparison. Read more
source§

fn int_equal_elem<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: i64 ) -> NdArrayTensor<bool, D>

Elementwise equality comparison with a scalar. Read more
source§

fn int_greater<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: NdArrayTensor<i64, D> ) -> NdArrayTensor<bool, D>

Elementwise greater than comparison. Read more
source§

fn int_greater_elem<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: i64 ) -> NdArrayTensor<bool, D>

Elementwise greater than comparison with a scalar. Read more
source§

fn int_greater_equal<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: NdArrayTensor<i64, D> ) -> NdArrayTensor<bool, D>

Elementwise greater than or equal comparison. Read more
source§

fn int_greater_equal_elem<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: i64 ) -> NdArrayTensor<bool, D>

Elementwise greater than or equal comparison with a scalar. Read more
source§

fn int_lower<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: NdArrayTensor<i64, D> ) -> NdArrayTensor<bool, D>

Elementwise less than comparison. Read more
source§

fn int_lower_elem<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: i64 ) -> NdArrayTensor<bool, D>

Elementwise less than comparison with a scalar. Read more
source§

fn int_lower_equal<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: NdArrayTensor<i64, D> ) -> NdArrayTensor<bool, D>

Elementwise less than or equal comparison. Read more
source§

fn int_lower_equal_elem<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: i64 ) -> NdArrayTensor<bool, D>

Elementwise less than or equal comparison with a scalar. Read more
source§

fn int_add<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: NdArrayTensor<i64, D> ) -> NdArrayTensor<i64, D>

Elementwise addition. Read more
source§

fn int_add_scalar<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: i64 ) -> NdArrayTensor<i64, D>

Elementwise addition with a scalar. Read more
source§

fn int_sub<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: NdArrayTensor<i64, D> ) -> NdArrayTensor<i64, D>

Elementwise subtraction. Read more
source§

fn int_sub_scalar<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: i64 ) -> NdArrayTensor<i64, D>

Elementwise subtraction with a scalar. Read more
source§

fn int_mul<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: NdArrayTensor<i64, D> ) -> NdArrayTensor<i64, D>

Elementwise multiplication. Read more
source§

fn int_mul_scalar<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: i64 ) -> NdArrayTensor<i64, D>

Elementwise multiplication with a scalar. Read more
source§

fn int_div<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: NdArrayTensor<i64, D> ) -> NdArrayTensor<i64, D>

Elementwise division. Read more
source§

fn int_div_scalar<const D: usize>( lhs: NdArrayTensor<i64, D>, rhs: i64 ) -> NdArrayTensor<i64, D>

Elementwise division with a scalar. Read more
source§

fn int_neg<const D: usize>( tensor: NdArrayTensor<i64, D> ) -> NdArrayTensor<i64, D>

Elementwise negation. Read more
source§

fn int_zeros<const D: usize>( shape: Shape<D>, device: &<NdArrayBackend<E> as Backend>::Device ) -> NdArrayTensor<i64, D>

Creates a tensor of zeros. Read more
source§

fn int_ones<const D: usize>( shape: Shape<D>, device: &<NdArrayBackend<E> as Backend>::Device ) -> NdArrayTensor<i64, D>

Creates a tensor of ones. Read more
source§

fn int_full<const D: usize>( shape: Shape<D>, fill_value: i64, device: &<NdArrayBackend<E> as Backend>::Device ) -> NdArrayTensor<i64, D>

Creates a tensor filled with given value. Read more
source§

fn int_sum<const D: usize>( tensor: NdArrayTensor<i64, D> ) -> NdArrayTensor<i64, 1>

Sums all elements in the tensor. Read more
source§

fn int_sum_dim<const D: usize>( tensor: NdArrayTensor<i64, D>, dim: usize ) -> NdArrayTensor<i64, D>

Sums all elements in the tensor along a dimension. Read more
source§

fn int_mean<const D: usize>( tensor: NdArrayTensor<i64, D> ) -> NdArrayTensor<i64, 1>

Computes the mean of all elements in the tensor. Read more
source§

fn int_mean_dim<const D: usize>( tensor: NdArrayTensor<i64, D>, dim: usize ) -> NdArrayTensor<i64, D>

Computes the mean of all elements in the tensor along a dimension. Read more
source§

fn int_gather<const D: usize>( dim: usize, tensor: NdArrayTensor<i64, D>, indices: NdArrayTensor<i64, D> ) -> NdArrayTensor<i64, D>

Gather elements from the tensor at the given indices. Read more
source§

fn int_scatter<const D: usize>( dim: usize, tensor: NdArrayTensor<i64, D>, indices: NdArrayTensor<i64, D>, value: NdArrayTensor<i64, D> ) -> NdArrayTensor<i64, D>

Scatter a given value to the tensor at the given indices. Read more
source§

fn int_select<const D: usize>( tensor: NdArrayTensor<i64, D>, dim: usize, indices: NdArrayTensor<i64, 1> ) -> NdArrayTensor<i64, D>

Select tensor elements along the given dimension corresponding to the given indices. Read more
source§

fn int_select_assign<const D: usize>( tensor: NdArrayTensor<i64, D>, dim: usize, indices: NdArrayTensor<i64, 1>, value: NdArrayTensor<i64, D> ) -> NdArrayTensor<i64, D>

Assign the selected elements along the given dimension corresponding to the given indices to the given value. Read more
source§

fn int_argmax<const D: usize>( tensor: NdArrayTensor<i64, D>, dim: usize ) -> NdArrayTensor<i64, D>

Gets the indices of the maximum elements along a dimension. Read more
source§

fn int_argmin<const D: usize>( tensor: NdArrayTensor<i64, D>, dim: usize ) -> NdArrayTensor<i64, D>

Gets the indices of the minimum elements along a dimension. Read more
source§

fn int_repeat<const D: usize>( tensor: <B as Backend>::IntTensorPrimitive<D>, dim: usize, times: usize ) -> <B as Backend>::IntTensorPrimitive<D>

Repeats the tensor along the given dimension the given number of times. Read more
source§

fn int_max<const D: usize>( tensor: <B as Backend>::IntTensorPrimitive<D> ) -> <B as Backend>::IntTensorPrimitive<1>

Gets the maximum element in the tensor. Read more
source§

fn int_max_dim<const D: usize>( tensor: <B as Backend>::IntTensorPrimitive<D>, dim: usize ) -> <B as Backend>::IntTensorPrimitive<D>

Gets the maximum element in the tensor along a dimension. Read more
source§

fn int_max_dim_with_indices<const D: usize>( tensor: <B as Backend>::IntTensorPrimitive<D>, dim: usize ) -> (<B as Backend>::IntTensorPrimitive<D>, <B as Backend>::IntTensorPrimitive<D>)

Gets the maximum elements and corresponding indices along a dimension. Read more
source§

fn int_min<const D: usize>( tensor: <B as Backend>::IntTensorPrimitive<D> ) -> <B as Backend>::IntTensorPrimitive<1>

Gets the minimum element in the tensor. Read more
source§

fn int_min_dim<const D: usize>( tensor: <B as Backend>::IntTensorPrimitive<D>, dim: usize ) -> <B as Backend>::IntTensorPrimitive<D>

Gets the minimum elements in the tensor along a dimension. Read more
source§

fn int_min_dim_with_indices<const D: usize>( tensor: <B as Backend>::IntTensorPrimitive<D>, dim: usize ) -> (<B as Backend>::IntTensorPrimitive<D>, <B as Backend>::IntTensorPrimitive<D>)

Gets the minimum elements and corresponding indices along a dimension. Read more
source§

impl<E: FloatNdArrayElement> ModuleOps<NdArrayBackend<E>> for NdArrayBackend<E>

source§

fn conv2d( x: NdArrayTensor<E, 4>, weight: NdArrayTensor<E, 4>, bias: Option<NdArrayTensor<E, 1>>, options: ConvOptions<2> ) -> NdArrayTensor<E, 4>

Two dimensional convolution. Read more
source§

fn conv_transpose2d( x: NdArrayTensor<E, 4>, weight: NdArrayTensor<E, 4>, bias: Option<NdArrayTensor<E, 1>>, options: ConvTransposeOptions<2> ) -> NdArrayTensor<E, 4>

Two dimensional transposed convolution. Read more
source§

fn avg_pool2d( x: NdArrayTensor<E, 4>, kernel_size: [usize; 2], stride: [usize; 2], padding: [usize; 2] ) -> NdArrayTensor<E, 4>

Two dimensional avg pooling. Read more
source§

fn avg_pool2d_backward( x: NdArrayTensor<E, 4>, grad: NdArrayTensor<E, 4>, kernel_size: [usize; 2], stride: [usize; 2], padding: [usize; 2] ) -> NdArrayTensor<E, 4>

Backward pass for the avg pooling 2d operation.
source§

fn max_pool2d( x: NdArrayTensor<E, 4>, kernel_size: [usize; 2], stride: [usize; 2], padding: [usize; 2] ) -> NdArrayTensor<E, 4>

Two dimensional max pooling. Read more
source§

fn max_pool2d_with_indices( x: NdArrayTensor<E, 4>, kernel_size: [usize; 2], stride: [usize; 2], padding: [usize; 2] ) -> MaxPool2dWithIndices<NdArrayBackend<E>>

Two dimensional max pooling with indices. Read more
source§

fn max_pool2d_with_indices_backward( x: NdArrayTensor<E, 4>, kernel_size: [usize; 2], stride: [usize; 2], padding: [usize; 2], output_grad: NdArrayTensor<E, 4>, indices: NdArrayTensor<i64, 4> ) -> MaxPool2dBackward<NdArrayBackend<E>>

Backward pass for the max pooling 2d operation.
source§

fn embedding( weights: <B as Backend>::TensorPrimitive<2>, indices: <B as Backend>::IntTensorPrimitive<2> ) -> <B as Backend>::TensorPrimitive<3>

Embedding operation. Read more
source§

fn embedding_backward( weights: <B as Backend>::TensorPrimitive<2>, output_grad: <B as Backend>::TensorPrimitive<3>, indices: <B as Backend>::IntTensorPrimitive<2> ) -> <B as Backend>::TensorPrimitive<2>

Embedding backward operation. Read more
source§

fn conv2d_backward( x: <B as Backend>::TensorPrimitive<4>, weight: <B as Backend>::TensorPrimitive<4>, bias: Option<<B as Backend>::TensorPrimitive<1>>, output_grad: <B as Backend>::TensorPrimitive<4>, options: ConvOptions<2> ) -> Conv2dBackward<B>

Backward pass for the conv2d operation.
source§

fn conv1d( x: <B as Backend>::TensorPrimitive<3>, weight: <B as Backend>::TensorPrimitive<3>, bias: Option<<B as Backend>::TensorPrimitive<1>>, options: ConvOptions<1> ) -> <B as Backend>::TensorPrimitive<3>

One dimensional convolution. Read more
source§

fn conv_transpose1d( x: <B as Backend>::TensorPrimitive<3>, weight: <B as Backend>::TensorPrimitive<3>, bias: Option<<B as Backend>::TensorPrimitive<1>>, options: ConvTransposeOptions<1> ) -> <B as Backend>::TensorPrimitive<3>

One dimensional transposed convolution. Read more
source§

fn conv1d_backward( x: <B as Backend>::TensorPrimitive<3>, weight: <B as Backend>::TensorPrimitive<3>, bias: Option<<B as Backend>::TensorPrimitive<1>>, output_grad: <B as Backend>::TensorPrimitive<3>, options: ConvOptions<1> ) -> Conv1dBackward<B>

Backward pass for the conv1d operation.
source§

fn avg_pool1d( x: <B as Backend>::TensorPrimitive<3>, kernel_size: usize, stride: usize, padding: usize ) -> <B as Backend>::TensorPrimitive<3>

One dimensional avg pooling. Read more
source§

fn avg_pool1d_backward( x: <B as Backend>::TensorPrimitive<3>, grad: <B as Backend>::TensorPrimitive<3>, kernel_size: usize, stride: usize, padding: usize ) -> <B as Backend>::TensorPrimitive<3>

Backward pass for the avg pooling 1d operation.
source§

impl<E: FloatNdArrayElement> TensorOps<NdArrayBackend<E>> for NdArrayBackend<E>

source§

fn from_data<const D: usize>( data: Data<E, D>, _device: &NdArrayDevice ) -> NdArrayTensor<E, D>

Creates a new tensor from the data structure. Read more
source§

fn random<const D: usize>( shape: Shape<D>, distribution: Distribution<E>, device: &NdArrayDevice ) -> NdArrayTensor<E, D>

Creates a new tensor with random values. Read more
source§

fn shape<const D: usize>(tensor: &NdArrayTensor<E, D>) -> Shape<D>

Gets the shape of the tensor. Read more
source§

fn to_data<const D: usize>( tensor: &NdArrayTensor<E, D> ) -> Data<<NdArrayBackend<E> as Backend>::FloatElem, D>

Converts the tensor to a data structure. Read more
source§

fn into_data<const D: usize>( tensor: NdArrayTensor<E, D> ) -> Data<<NdArrayBackend<E> as Backend>::FloatElem, D>

Converts the tensor to a data structure. Read more
source§

fn device<const D: usize>(_tensor: &NdArrayTensor<E, D>) -> NdArrayDevice

Gets the device of the tensor. Read more
source§

fn to_device<const D: usize>( tensor: NdArrayTensor<E, D>, _device: &NdArrayDevice ) -> NdArrayTensor<E, D>

Moves the tensor to the given device. Read more
source§

fn empty<const D: usize>( shape: Shape<D>, device: &<NdArrayBackend<E> as Backend>::Device ) -> NdArrayTensor<E, D>

Creates an empty tensor with the given shape. Read more
source§

fn add<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: NdArrayTensor<E, D> ) -> NdArrayTensor<E, D>

Adds two tensors together. Read more
source§

fn add_scalar<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: E ) -> NdArrayTensor<E, D>

Adds a scalar to a tensor. Read more
source§

fn sub<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: NdArrayTensor<E, D> ) -> NdArrayTensor<E, D>

Subtracts two tensors. Read more
source§

fn sub_scalar<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: E ) -> NdArrayTensor<E, D>

Subtracts a scalar from a tensor. Read more
source§

fn mul<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: NdArrayTensor<E, D> ) -> NdArrayTensor<E, D>

Multiplies two tensors together element-wise.
source§

fn mul_scalar<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: E ) -> NdArrayTensor<E, D>

Multiplies a tensor by a scalar. Read more
source§

fn div<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: NdArrayTensor<E, D> ) -> NdArrayTensor<E, D>

Divides two tensors element-wise. Read more
source§

fn div_scalar<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: E ) -> NdArrayTensor<E, D>

Divides a tensor by a scalar. Read more
source§

fn matmul<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: NdArrayTensor<E, D> ) -> NdArrayTensor<E, D>

Multiplies two tensors together using matrix multiplication. Read more
source§

fn neg<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, D>

Negates a tensor element-wise.
source§

fn swap_dims<const D: usize>( tensor: NdArrayTensor<E, D>, dim1: usize, dim2: usize ) -> NdArrayTensor<E, D>

Swaps two dimensions of a tensor. Read more
source§

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

Reshapes a tensor. Read more
source§

fn gather<const D: usize>( dim: usize, tensor: NdArrayTensor<E, D>, indices: NdArrayTensor<i64, D> ) -> NdArrayTensor<E, D>

Gather elements from a tensor. Read more
source§

fn scatter<const D: usize>( dim: usize, tensor: NdArrayTensor<E, D>, indices: NdArrayTensor<i64, D>, value: NdArrayTensor<E, D> ) -> NdArrayTensor<E, D>

Scatter elements into a tensor. Read more
source§

fn select<const D: usize>( tensor: NdArrayTensor<E, D>, dim: usize, indices: NdArrayTensor<i64, 1> ) -> NdArrayTensor<E, D>

Select tensor elements along the given dimension corresponding for the given indices. Read more
source§

fn select_assign<const D: usize>( tensor: NdArrayTensor<E, D>, dim: usize, indices: NdArrayTensor<i64, 1>, value: NdArrayTensor<E, D> ) -> NdArrayTensor<E, D>

Assign the selected elements along the given dimension corresponding for the given indices to the given value. Read more
source§

fn slice<const D1: usize, const D2: usize>( tensor: NdArrayTensor<E, D1>, ranges: [Range<usize>; D2] ) -> NdArrayTensor<E, D1>

Select tensor elements corresponding for the given ranges. Read more
source§

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

Assign the selected elements corresponding for the given ranges to the given value. Read more
source§

fn mask_where<const D: usize>( tensor: NdArrayTensor<E, D>, mask: NdArrayTensor<bool, D>, value: NdArrayTensor<E, D> ) -> NdArrayTensor<E, D>

Update the given tensor with the value tensor where the mask is true. Read more
source§

fn mask_fill<const D: usize>( tensor: NdArrayTensor<E, D>, mask: NdArrayTensor<bool, D>, value: E ) -> NdArrayTensor<E, D>

Update the given tensor with the value where the mask is true. Read more
source§

fn equal<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: NdArrayTensor<E, D> ) -> NdArrayTensor<bool, D>

Equal comparison of two tensors. Read more
source§

fn equal_elem<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: E ) -> NdArrayTensor<bool, D>

Equal comparison of a tensor and a scalar. Read more
source§

fn greater<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: NdArrayTensor<E, D> ) -> NdArrayTensor<bool, D>

Greater than comparison of two tensors. Read more
source§

fn greater_elem<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: E ) -> NdArrayTensor<bool, D>

Greater than comparison of a tensor and a scalar. Read more
source§

fn greater_equal<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: NdArrayTensor<E, D> ) -> NdArrayTensor<bool, D>

Greater than or equal comparison of two tensors. Read more
source§

fn greater_equal_elem<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: E ) -> NdArrayTensor<bool, D>

Greater than or equal comparison of a tensor and a scalar. Read more
source§

fn lower<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: NdArrayTensor<E, D> ) -> NdArrayTensor<bool, D>

Less than comparison of two tensors. Read more
source§

fn lower_elem<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: E ) -> NdArrayTensor<bool, D>

Less than comparison of a tensor and a scalar. Read more
source§

fn lower_equal<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: NdArrayTensor<E, D> ) -> NdArrayTensor<bool, D>

Less than or equal comparison of two tensors. Read more
source§

fn lower_equal_elem<const D: usize>( lhs: NdArrayTensor<E, D>, rhs: E ) -> NdArrayTensor<bool, D>

Less than or equal comparison of a tensor and a scalar. Read more
source§

fn detach<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, D>

Detaches a tensor from the computation graph.
source§

fn mean<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, 1>

Mean of all elements in a tensor. Read more
source§

fn sum<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, 1>

Sum of all elements in a tensor. Read more
source§

fn mean_dim<const D: usize>( tensor: NdArrayTensor<E, D>, dim: usize ) -> NdArrayTensor<E, D>

Mean of all elements in a tensor along a dimension. Read more
source§

fn sum_dim<const D: usize>( tensor: NdArrayTensor<E, D>, dim: usize ) -> NdArrayTensor<E, D>

Sum of all elements in a tensor along a dimension. Read more
source§

fn to_full_precision<const D: usize>( tensor: &NdArrayTensor<E, D> ) -> NdArrayTensor<f32, D>

Converts a tensor to full precision. Read more
source§

fn from_full_precision<const D: usize>( tensor: NdArrayTensor<f32, D> ) -> NdArrayTensor<E, D>

Converts a tensor from full precision. Read more
source§

fn argmax<const D: usize>( tensor: NdArrayTensor<E, D>, dim: usize ) -> NdArrayTensor<i64, D>

Gets the indices of the maximum elements of a tensor along an axis. Read more
source§

fn argmin<const D: usize>( tensor: NdArrayTensor<E, D>, dim: usize ) -> NdArrayTensor<i64, D>

Gets the indices of the minimum elements of a tensor along an axis. Read more
source§

fn exp<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, D>

Returns a new tensor with exponential values. Read more
source§

fn log<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, D>

Returns a new tensor with natural logarithm values. Read more
source§

fn log1p<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, D>

Returns a new tensor with logarithm values of (1 + Xi). Read more
source§

fn powf<const D: usize>( tensor: NdArrayTensor<E, D>, value: f32 ) -> NdArrayTensor<E, D>

Returns a new tensor with values raised to the power of value. Read more
source§

fn sqrt<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, D>

Returns a new tensor with square root values. Read more
source§

fn cos<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, D>

Returns a new tensor with cosine values. Read more
source§

fn sin<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, D>

Returns a new tensor with sine values. Read more
source§

fn tanh<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, D>

Returns a new tensor with tangent values. Read more
source§

fn erf<const D: usize>(tensor: NdArrayTensor<E, D>) -> NdArrayTensor<E, D>

Returns a new tensor with the error function values. Read more
source§

fn cat<const D: usize>( tensors: Vec<NdArrayTensor<E, D>>, dim: usize ) -> NdArrayTensor<E, D>

Catcatenates tensors along a dimension. Read more
source§

fn zeros<const D: usize>( shape: Shape<D>, device: &<B as Backend>::Device ) -> <B as Backend>::TensorPrimitive<D>

Creates a new tensor with zeros. Read more
source§

fn ones<const D: usize>( shape: Shape<D>, device: &<B as Backend>::Device ) -> <B as Backend>::TensorPrimitive<D>

Creates a new tensor with ones. Read more
source§

fn full<const D: usize>( shape: Shape<D>, fill_value: <B as Backend>::FloatElem, device: &<B as Backend>::Device ) -> <B as Backend>::TensorPrimitive<D>

Creates a tensor filled with given value. Read more
source§

fn arange( range: Range<usize>, device: &<B as Backend>::Device ) -> <B as Backend>::IntTensorPrimitive<1>

Creates a new tensor with values from the given range. Read more
source§

fn arange_step( range: Range<usize>, step: usize, device: &<B as Backend>::Device ) -> <B as Backend>::IntTensorPrimitive<1>

Creates a new tensor with values from the given range with the given step size. Read more
source§

fn repeat<const D: usize>( tensor: <B as Backend>::TensorPrimitive<D>, dim: usize, times: usize ) -> <B as Backend>::TensorPrimitive<D>

Repeat the tensor along the given dimension. Read more
source§

fn transpose<const D: usize>( tensor: <B as Backend>::TensorPrimitive<D> ) -> <B as Backend>::TensorPrimitive<D>

Transposes a tensor. Read more
source§

fn set_require_grad<const D: usize>( tensor: <B as Backend>::TensorPrimitive<D>, _require_grad: bool ) -> <B as Backend>::TensorPrimitive<D>

Sets the require_grad flag of a tensor.
source§

fn is_require_grad<const D: usize>( _tensor: &<B as Backend>::TensorPrimitive<D> ) -> bool

Returns the require_grad flag of a tensor.
source§

fn max<const D: usize>( tensor: <B as Backend>::TensorPrimitive<D> ) -> <B as Backend>::TensorPrimitive<1>

Gets the maximum element of a tensor. Read more
source§

fn max_dim<const D: usize>( tensor: <B as Backend>::TensorPrimitive<D>, dim: usize ) -> <B as Backend>::TensorPrimitive<D>

Gets the maximum elements of a tensor along an axis. Read more
source§

fn max_dim_with_indices<const D: usize>( tensor: <B as Backend>::TensorPrimitive<D>, dim: usize ) -> (<B as Backend>::TensorPrimitive<D>, <B as Backend>::IntTensorPrimitive<D>)

Gets the maximum elements of a tensor along an axis and their indices. Read more
source§

fn min<const D: usize>( tensor: <B as Backend>::TensorPrimitive<D> ) -> <B as Backend>::TensorPrimitive<1>

Gets the minimum element of a tensor. Read more
source§

fn min_dim<const D: usize>( tensor: <B as Backend>::TensorPrimitive<D>, dim: usize ) -> <B as Backend>::TensorPrimitive<D>

Gets the minimum elements of a tensor along an axis. Read more
source§

fn min_dim_with_indices<const D: usize>( tensor: <B as Backend>::TensorPrimitive<D>, dim: usize ) -> (<B as Backend>::TensorPrimitive<D>, <B as Backend>::IntTensorPrimitive<D>)

Gets the minimum elements of a tensor along an axis and their indices. Read more
source§

impl<E: Copy> Copy for NdArrayBackend<E>

Auto Trait Implementations§

§

impl<E> RefUnwindSafe for NdArrayBackend<E>where E: RefUnwindSafe,

§

impl<E> Send for NdArrayBackend<E>where E: Send,

§

impl<E> Sync for NdArrayBackend<E>where E: Sync,

§

impl<E> Unpin for NdArrayBackend<E>where E: Unpin,

§

impl<E> UnwindSafe for NdArrayBackend<E>where E: 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.

§

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