pub trait TensorOps<B: Backend> {
Show 78 methods // Required methods fn from_data<const D: usize>( data: Data<FloatElem<B>, D>, device: &Device<B> ) -> FloatTensor<B, D>; fn random<const D: usize>( shape: Shape<D>, distribution: Distribution, device: &Device<B> ) -> FloatTensor<B, D>; fn shape<const D: usize>(tensor: &FloatTensor<B, D>) -> Shape<D>; fn into_data<const D: usize>( tensor: FloatTensor<B, D> ) -> Reader<Data<FloatElem<B>, D>>; fn device<const D: usize>(tensor: &FloatTensor<B, D>) -> Device<B>; fn to_device<const D: usize>( tensor: FloatTensor<B, D>, device: &Device<B> ) -> FloatTensor<B, D>; fn into_int<const D: usize>(tensor: FloatTensor<B, D>) -> IntTensor<B, D>; fn empty<const D: usize>( shape: Shape<D>, device: &Device<B> ) -> FloatTensor<B, D>; fn add<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> FloatTensor<B, D>; fn add_scalar<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> FloatTensor<B, D>; fn sub<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> FloatTensor<B, D>; fn sub_scalar<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> FloatTensor<B, D>; fn mul<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> FloatTensor<B, D>; fn mul_scalar<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> FloatTensor<B, D>; fn div<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> FloatTensor<B, D>; fn div_scalar<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> FloatTensor<B, D>; fn matmul<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> FloatTensor<B, D>; fn recip<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>; fn swap_dims<const D: usize>( tensor: FloatTensor<B, D>, dim1: usize, dim2: usize ) -> FloatTensor<B, D>; fn reshape<const D1: usize, const D2: usize>( tensor: FloatTensor<B, D1>, shape: Shape<D2> ) -> FloatTensor<B, D2>; fn gather<const D: usize>( dim: usize, tensor: FloatTensor<B, D>, indices: IntTensor<B, D> ) -> FloatTensor<B, D>; fn scatter<const D: usize>( dim: usize, tensor: FloatTensor<B, D>, indices: IntTensor<B, D>, value: FloatTensor<B, D> ) -> FloatTensor<B, D>; fn select<const D: usize>( tensor: FloatTensor<B, D>, dim: usize, indices: IntTensor<B, 1> ) -> FloatTensor<B, D>; fn select_assign<const D: usize>( tensor: FloatTensor<B, D>, dim: usize, indices: IntTensor<B, 1>, value: FloatTensor<B, D> ) -> FloatTensor<B, D>; fn slice<const D1: usize, const D2: usize>( tensor: FloatTensor<B, D1>, ranges: [Range<usize>; D2] ) -> FloatTensor<B, D1>; fn slice_assign<const D1: usize, const D2: usize>( tensor: FloatTensor<B, D1>, ranges: [Range<usize>; D2], value: FloatTensor<B, D1> ) -> FloatTensor<B, D1>; fn mask_where<const D: usize>( tensor: FloatTensor<B, D>, mask: BoolTensor<B, D>, value: FloatTensor<B, D> ) -> FloatTensor<B, D>; fn mask_fill<const D: usize>( tensor: FloatTensor<B, D>, mask: BoolTensor<B, D>, value: FloatElem<B> ) -> FloatTensor<B, D>; fn equal<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> BoolTensor<B, D>; fn equal_elem<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> BoolTensor<B, D>; fn greater<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> BoolTensor<B, D>; fn greater_elem<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> BoolTensor<B, D>; fn greater_equal<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> BoolTensor<B, D>; fn greater_equal_elem<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> BoolTensor<B, D>; fn lower<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> BoolTensor<B, D>; fn lower_elem<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> BoolTensor<B, D>; fn lower_equal<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> BoolTensor<B, D>; fn lower_equal_elem<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> BoolTensor<B, D>; fn sum<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, 1>; fn sum_dim<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> FloatTensor<B, D>; fn mean_dim<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> FloatTensor<B, D>; fn to_full_precision<const D: usize>( tensor: &FloatTensor<B, D> ) -> FloatTensor<FullPrecisionBackend<B>, D>; fn from_full_precision<const D: usize>( tensor: FloatTensor<FullPrecisionBackend<B>, D> ) -> FloatTensor<B, D>; fn exp<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>; fn log<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>; fn log1p<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>; fn powf<const D: usize>( tensor: FloatTensor<B, D>, value: f32 ) -> FloatTensor<B, D>; fn sqrt<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>; fn abs<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>; fn cos<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>; fn sin<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>; fn tanh<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>; fn erf<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>; fn cat<const D: usize>( tensors: Vec<FloatTensor<B, D>>, dim: usize ) -> FloatTensor<B, D>; fn argmax<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> IntTensor<B, D>; fn argmin<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> IntTensor<B, D>; // Provided methods fn zeros<const D: usize>( shape: Shape<D>, device: &Device<B> ) -> FloatTensor<B, D> { ... } fn ones<const D: usize>( shape: Shape<D>, device: &Device<B> ) -> FloatTensor<B, D> { ... } fn full<const D: usize>( shape: Shape<D>, fill_value: FloatElem<B>, device: &Device<B> ) -> FloatTensor<B, D> { ... } fn to_data<const D: usize>( tensor: &FloatTensor<B, D> ) -> Reader<Data<FloatElem<B>, D>> { ... } fn arange(range: Range<usize>, device: &Device<B>) -> IntTensor<B, 1> { ... } fn arange_step( range: Range<usize>, step: usize, device: &Device<B> ) -> IntTensor<B, 1> { ... } fn repeat<const D: usize>( tensor: FloatTensor<B, D>, dim: usize, times: usize ) -> FloatTensor<B, D> { ... } fn clamp_min<const D: usize>( tensor: FloatTensor<B, D>, min: FloatElem<B> ) -> FloatTensor<B, D> { ... } fn clamp_max<const D: usize>( tensor: FloatTensor<B, D>, max: FloatElem<B> ) -> FloatTensor<B, D> { ... } fn clamp<const D: usize>( tensor: FloatTensor<B, D>, min: FloatElem<B>, max: FloatElem<B> ) -> FloatTensor<B, D> { ... } fn neg<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D> { ... } fn transpose<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D> { ... } fn detach<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D> { ... } fn set_require_grad<const D: usize>( tensor: FloatTensor<B, D>, _require_grad: bool ) -> FloatTensor<B, D> { ... } fn is_require_grad<const D: usize>(_tensor: &FloatTensor<B, D>) -> bool { ... } fn mean<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, 1> { ... } fn max<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, 1> { ... } fn max_dim<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> FloatTensor<B, D> { ... } fn max_dim_with_indices<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> (FloatTensor<B, D>, IntTensor<B, D>) { ... } fn min<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, 1> { ... } fn min_dim<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> FloatTensor<B, D> { ... } fn min_dim_with_indices<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> (FloatTensor<B, D>, IntTensor<B, D>) { ... }
}
Expand description

Operations on float tensors.

Required Methods§

source

fn from_data<const D: usize>( data: Data<FloatElem<B>, D>, device: &Device<B> ) -> FloatTensor<B, D>

Creates a new tensor from the data structure.

Arguments
  • data - The data structure.
  • device - The device to create the tensor on.
Returns

The tensor with the given data.

source

fn random<const D: usize>( shape: Shape<D>, distribution: Distribution, device: &Device<B> ) -> FloatTensor<B, D>

Creates a new tensor with random values.

Arguments
  • shape - The shape of the tensor.
  • distribution - The distribution to sample from.
  • device - The device to create the tensor on.
Returns

The tensor with the given shape and random values.

source

fn shape<const D: usize>(tensor: &FloatTensor<B, D>) -> Shape<D>

Gets the shape of the tensor.

Arguments
  • tensor - The tensor.
Returns

The shape of the tensor.

source

fn into_data<const D: usize>( tensor: FloatTensor<B, D> ) -> Reader<Data<FloatElem<B>, D>>

Converts the tensor to a data structure.

Arguments
  • tensor - The tensor.
Returns

The data structure with the tensor’s data.

source

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

Gets the device of the tensor.

Arguments
  • tensor - The tensor.
Returns

The device of the tensor.

source

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

Moves the tensor to the given device.

Arguments
  • tensor - The tensor.
  • device - The device to move the tensor to.
Returns

The tensor on the given device.

source

fn into_int<const D: usize>(tensor: FloatTensor<B, D>) -> IntTensor<B, D>

Converts float tensor to int tensor.

Arguments
  • tensor - The tensor.
Returns

The int tensor with the same data as the float tensor.

source

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

Creates an empty tensor with the given shape.

Arguments
  • shape - The shape of the tensor.
  • device - The device to create the tensor on.
Returns

The empty tensor with the given shape.

source

fn add<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> FloatTensor<B, D>

Adds two tensors together.

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

The result of adding the two tensors together.

source

fn add_scalar<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> FloatTensor<B, D>

Adds a scalar to a tensor.

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

The result of adding the scalar to the tensor.

source

fn sub<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> FloatTensor<B, D>

Subtracts two tensors.

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

The result of subtracting the two tensors.

source

fn sub_scalar<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> FloatTensor<B, D>

Subtracts a scalar from a tensor.

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

The result of subtracting the scalar from the tensor.

source

fn mul<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> FloatTensor<B, D>

Multiplies two tensors together element-wise.

source

fn mul_scalar<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> FloatTensor<B, D>

Multiplies a tensor by a scalar.

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

The result of multiplying the tensor by the scalar.

source

fn div<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> FloatTensor<B, D>

Divides two tensors element-wise.

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

The result of dividing the two tensors.

source

fn div_scalar<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> FloatTensor<B, D>

Divides a tensor by a scalar.

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

The result of dividing the tensor by the scalar.

source

fn matmul<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> FloatTensor<B, D>

Multiplies two tensors together using matrix multiplication.

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

The result of multiplying the two tensors together using matrix multiplication.

source

fn recip<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Calculates the reciprocals elementwise

source

fn swap_dims<const D: usize>( tensor: FloatTensor<B, D>, dim1: usize, dim2: usize ) -> FloatTensor<B, D>

Swaps two dimensions of a tensor.

Arguments
  • tensor - The tensor to swap the dimensions of.
  • dim1 - The first dimension to swap.
  • dim2 - The second dimension to swap.
Returns

The tensor with the dimensions swapped.

source

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

Reshapes a tensor.

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

The tensor with the new shape.

source

fn gather<const D: usize>( dim: usize, tensor: FloatTensor<B, D>, indices: IntTensor<B, D> ) -> FloatTensor<B, D>

Gather elements from a tensor.

Arguments
  • dim - The dimension to gather from.
  • tensor - The tensor to gather from.
  • indices - The indices to gather.
Returns

The gathered elements.

source

fn scatter<const D: usize>( dim: usize, tensor: FloatTensor<B, D>, indices: IntTensor<B, D>, value: FloatTensor<B, D> ) -> FloatTensor<B, D>

Scatter elements into a tensor.

Arguments
  • dim - The dimension to scatter into.
  • tensor - The tensor to scatter into.
  • indices - The indices to scatter into.
  • value - The value to scatter.
Returns

The tensor with the scattered elements.

source

fn select<const D: usize>( tensor: FloatTensor<B, D>, dim: usize, indices: IntTensor<B, 1> ) -> FloatTensor<B, D>

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

Arguments
  • tensor - The tensor to select from.
  • dim - The dimension to select from.
  • indices - The indices to select.
Returns

The selected elements.

source

fn select_assign<const D: usize>( tensor: FloatTensor<B, D>, dim: usize, indices: IntTensor<B, 1>, value: FloatTensor<B, D> ) -> FloatTensor<B, D>

Assign the selected elements along the given dimension corresponding for the given indices to the given value.

Arguments
  • tensor - The tensor to select from.
  • dim - The dimension to select from.
  • indices - The indices to select.
  • value - The value to assign.
Returns

The tensor with the selected elements assigned to the given value.

source

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

Select tensor elements corresponding for the given ranges.

Arguments
  • tensor - The tensor to select from.
  • ranges - The ranges to select.
Returns

The selected elements in a new tensor.

source

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

Assign the selected elements corresponding for the given ranges to the given value.

Arguments
  • tensor - The tensor to select from.
  • ranges - The ranges to select.
  • value - The value to assign.
Returns

The tensor with the selected elements assigned to the given value.

source

fn mask_where<const D: usize>( tensor: FloatTensor<B, D>, mask: BoolTensor<B, D>, value: FloatTensor<B, D> ) -> FloatTensor<B, D>

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

Arguments
  • tensor - The tensor to select from.
  • mask - The boolean mask to select with.
  • value - The value to assign to the selected elements from the value tensor.
Returns

The tensor with the selected elements assigned to the given value.

source

fn mask_fill<const D: usize>( tensor: FloatTensor<B, D>, mask: BoolTensor<B, D>, value: FloatElem<B> ) -> FloatTensor<B, D>

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

Arguments
  • tensor - The tensor to select from.
  • mask - The boolean mask to select with.
  • value - The value to assign to the selected elements.
Returns

The tensor with the selected elements assigned to the given value.

source

fn equal<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> BoolTensor<B, D>

Equal comparison of two tensors.

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

A boolean tensor with the result of the comparison.

source

fn equal_elem<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> BoolTensor<B, D>

Equal comparison of a tensor and a scalar.

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

A boolean tensor with the result of the comparison.

source

fn greater<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> BoolTensor<B, D>

Greater than comparison of two tensors.

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

A boolean tensor with the result of the comparison.

source

fn greater_elem<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> BoolTensor<B, D>

Greater than comparison of a tensor and a scalar.

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

A boolean tensor with the result of the comparison.

source

fn greater_equal<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> BoolTensor<B, D>

Greater than or equal comparison of two tensors.

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

A boolean tensor with the result of the comparison.

source

fn greater_equal_elem<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> BoolTensor<B, D>

Greater than or equal comparison of a tensor and a scalar.

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

A boolean tensor with the result of the comparison.

source

fn lower<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> BoolTensor<B, D>

Less than comparison of two tensors.

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

A boolean tensor with the result of the comparison.

source

fn lower_elem<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> BoolTensor<B, D>

Less than comparison of a tensor and a scalar.

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

A boolean tensor with the result of the comparison.

source

fn lower_equal<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatTensor<B, D> ) -> BoolTensor<B, D>

Less than or equal comparison of two tensors.

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

A boolean tensor with the result of the comparison.

source

fn lower_equal_elem<const D: usize>( lhs: FloatTensor<B, D>, rhs: FloatElem<B> ) -> BoolTensor<B, D>

Less than or equal comparison of a tensor and a scalar.

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

A boolean tensor with the result of the comparison.

source

fn sum<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, 1>

Sum of all elements in a tensor.

Arguments
  • tensor - The tensor to sum.
Returns

A scalar tensor with the sum of all elements in tensor.

source

fn sum_dim<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> FloatTensor<B, D>

Sum of all elements in a tensor along a dimension.

Arguments
  • tensor - The tensor to sum.
  • dim - The dimension along which to sum.
Returns

A tensor with the sum of all elements in tensor along dim.

source

fn mean_dim<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> FloatTensor<B, D>

Mean of all elements in a tensor along a dimension.

Arguments
  • tensor - The tensor to mean.
  • dim - The dimension along which to mean.
Returns

A tensor with the mean of all elements in tensor along dim.

source

fn to_full_precision<const D: usize>( tensor: &FloatTensor<B, D> ) -> FloatTensor<FullPrecisionBackend<B>, D>

Converts a tensor to full precision.

Arguments
  • tensor - The tensor to convert.
Returns

A tensor with the same values as tensor but with full precision.

source

fn from_full_precision<const D: usize>( tensor: FloatTensor<FullPrecisionBackend<B>, D> ) -> FloatTensor<B, D>

Converts a tensor from full precision.

Arguments
  • tensor - The tensor to convert.
Returns

A tensor with the same values as tensor but with the precision of the backend.

source

fn exp<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Returns a new tensor with exponential values.

Arguments
  • tensor - The tensor to exponentiate.
Returns

A tensor with the same shape as tensor with exponential values.

source

fn log<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Returns a new tensor with natural logarithm values.

Arguments
  • tensor - The tensor to take the logarithm of.
Returns

A tensor with the same shape as tensor with natural logarithm values.

source

fn log1p<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Returns a new tensor with logarithm values of (1 + Xi).

Arguments
  • tensor - The tensor to take the logarithm of.
Returns

A tensor with the same shape as tensor with logarithm values of (1 + Xi).

source

fn powf<const D: usize>( tensor: FloatTensor<B, D>, value: f32 ) -> FloatTensor<B, D>

Returns a new tensor with values raised to the power of value.

Arguments
  • tensor - The tensor to exponentiate.
  • value - The exponent.
Returns

A tensor with the same shape as tensor with values raised to the power of value.

source

fn sqrt<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Returns a new tensor with square root values.

Arguments
  • tensor - The tensor to take the square root of.
Returns

A tensor with the same shape as tensor with square root values.

source

fn abs<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Returns a new tensor with absolute values.

Arguments
  • tensor - The tensor to take absolute value of.
Returns

A tensor with the same shape as tensor with absolute values.

source

fn cos<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Returns a new tensor with cosine values.

Arguments
  • tensor - The tensor to take the cosine of.
Returns

A tensor with the same shape as tensor with cosine values.

source

fn sin<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Returns a new tensor with sine values.

Arguments
  • tensor - The tensor to take the sine of.
Returns

A tensor with the same shape as tensor with sine values.

source

fn tanh<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Returns a new tensor with tangent values.

Arguments
  • tensor - The tensor to take the tangent of.
Returns

A tensor with the same shape as tensor with tangent values.

source

fn erf<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Returns a new tensor with the error function values.

Arguments
  • tensor - The tensor to take the error function of.
Returns

A tensor with the same shape as tensor with error function values.

source

fn cat<const D: usize>( tensors: Vec<FloatTensor<B, D>>, dim: usize ) -> FloatTensor<B, D>

Catcatenates tensors along a dimension.

Arguments
  • tensors - The tensors to catcatenate.
  • dim - The dimension along which to catcatenate.
Returns

A tensor with the catcatenated tensors along dim.

source

fn argmax<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> IntTensor<B, D>

Gets the indices of the maximum elements of a tensor along an axis.

Arguments
  • tensor - The tensor to get the maximum elements of.
  • dim - The dimension along which to get the maximum elements.
Returns

A tensor with the indices of the maximum elements of tensor along dim.

source

fn argmin<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> IntTensor<B, D>

Gets the indices of the minimum elements of a tensor along an axis.

Arguments
  • tensor - The tensor to get the minimum elements of.
  • dim - The dimension along which to get the minimum elements.
Returns

A tensor with the indices of the minimum elements of tensor along dim.

Provided Methods§

source

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

Creates a new tensor with zeros.

Arguments
  • shape - The shape of the tensor.
  • device - The device to create the tensor on.
Returns

The tensor with the given shape and zeros.

source

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

Creates a new tensor with ones.

Arguments
  • shape - The shape of the tensor.
  • device - The device to create the tensor on.
Returns

The tensor with the given shape and ones.

source

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

Creates a tensor filled with given value.

Arguments
  • shape - The shape of the tensor.
  • fill_value - The value with which to fill the tensor.
  • device - The device to create the tensor on.
Returns

The tensor filled with given value

source

fn to_data<const D: usize>( tensor: &FloatTensor<B, D> ) -> Reader<Data<FloatElem<B>, D>>

Converts the tensor to a data structure.

Arguments
  • tensor - The tensor.
Returns

The data structure with the tensor’s data.

source

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

Creates a new tensor with values from the given range.

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

The tensor with the given values.

Remarks

Uses arange_step with a step size of 1 under the hood.

source

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

Creates a new tensor with values from the given range with the given step size.

Arguments
  • range - The range of values.
  • step - The step size.
  • device - The device to create the tensor on.
Returns

The tensor with the given values.

source

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

Repeat the tensor along the given dimension.

Arguments
  • tensor - The tensor.
  • dim - The dimension to repeat.
  • times - The number of times to repeat the dimension.
Returns

The tensor with the given dimension repeated.

source

fn clamp_min<const D: usize>( tensor: FloatTensor<B, D>, min: FloatElem<B> ) -> FloatTensor<B, D>

Clamps a tensor under a minimum value.

Arguments
  • tensor - The tensor to clamp.
  • min - The minimum value.
Returns

The clamped tensor.

source

fn clamp_max<const D: usize>( tensor: FloatTensor<B, D>, max: FloatElem<B> ) -> FloatTensor<B, D>

Clamps a tensor over a maximum value.

Arguments
  • tensor - The tensor to clamp.
  • max - The maximum value.
Returns

The clamped tensor.

source

fn clamp<const D: usize>( tensor: FloatTensor<B, D>, min: FloatElem<B>, max: FloatElem<B> ) -> FloatTensor<B, D>

Clamps a tensor between a minimum and maximum value.

Arguments
  • tensor - The tensor to clamp.
  • min - The minimum value.
  • max - The maximum value.
Returns

The clamped tensor.

source

fn neg<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Negates a tensor element-wise.

source

fn transpose<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Transposes a tensor.

Arguments
  • tensor - The tensor to transpose.
Returns

The transposed tensor.

source

fn detach<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, D>

Detaches a tensor from the computation graph.

source

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

Sets the require_grad flag of a tensor.

source

fn is_require_grad<const D: usize>(_tensor: &FloatTensor<B, D>) -> bool

Returns the require_grad flag of a tensor.

source

fn mean<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, 1>

Mean of all elements in a tensor.

Arguments
  • tensor - The tensor to mean.
Returns

A scalar tensor with the mean of all elements in tensor.

source

fn max<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, 1>

Gets the maximum element of a tensor.

Arguments
  • tensor - The tensor to get the maximum elements of.
Returns

A tensor with the maximum element of tensor.

source

fn max_dim<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> FloatTensor<B, D>

Gets the maximum elements of a tensor along an axis.

Arguments
  • tensor - The tensor to get the maximum elements of.
  • dim - The dimension along which to get the maximum elements.
Returns

A tensor with the maximum elements of tensor along dim.

source

fn max_dim_with_indices<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> (FloatTensor<B, D>, IntTensor<B, D>)

Gets the maximum elements of a tensor along an axis and their indices.

Arguments
  • tensor - The tensor to get the maximum elements of.
  • dim - The dimension along which to get the maximum elements.
Returns

A tuple with the maximum elements of tensor along dim and their indices.

source

fn min<const D: usize>(tensor: FloatTensor<B, D>) -> FloatTensor<B, 1>

Gets the minimum element of a tensor.

Arguments
  • tensor - The tensor to get the minimum elements of.
Returns

A tensor with the minimum element of tensor.

source

fn min_dim<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> FloatTensor<B, D>

Gets the minimum elements of a tensor along an axis.

Arguments
  • tensor - The tensor to get the minimum elements of.
  • dim - The dimension along which to get the minimum elements.
Returns

A tensor with the minimum elements of tensor along dim.

source

fn min_dim_with_indices<const D: usize>( tensor: FloatTensor<B, D>, dim: usize ) -> (FloatTensor<B, D>, IntTensor<B, D>)

Gets the minimum elements of a tensor along an axis and their indices.

Arguments
  • tensor - The tensor to get the minimum elements of.
  • dim - The dimension along which to get the minimum elements.
Returns

A tuple with the minimum elements of tensor along dim and their indices.

Object Safety§

This trait is not object safe.

Implementors§