Trait burn_tensor::ops::BoolTensorOps

source ·
pub trait BoolTensorOps<B: Backend> {
Show 29 methods // Required methods fn bool_empty<const D: usize>( shape: Shape<D>, device: &Device<B>, ) -> BoolTensor<B, D>; fn bool_shape<const D: usize>(tensor: &BoolTensor<B, D>) -> Shape<D>; fn bool_into_data<const D: usize>( tensor: BoolTensor<B, D>, ) -> impl Future<Output = TensorData> + Send; fn bool_from_data<const D: usize>( data: TensorData, device: &Device<B>, ) -> BoolTensor<B, D>; fn bool_into_int<const D: usize>( tensor: BoolTensor<B, D>, ) -> IntTensor<B, D>; fn bool_into_float<const D: usize>( tensor: BoolTensor<B, D>, ) -> FloatTensor<B, D>; fn bool_device<const D: usize>(tensor: &BoolTensor<B, D>) -> Device<B>; fn bool_to_device<const D: usize>( tensor: BoolTensor<B, D>, device: &Device<B>, ) -> BoolTensor<B, D>; fn bool_reshape<const D1: usize, const D2: usize>( tensor: BoolTensor<B, D1>, shape: Shape<D2>, ) -> BoolTensor<B, D2>; fn bool_slice<const D1: usize, const D2: usize>( tensor: BoolTensor<B, D1>, ranges: [Range<usize>; D2], ) -> BoolTensor<B, D1>; fn bool_slice_assign<const D1: usize, const D2: usize>( tensor: BoolTensor<B, D1>, ranges: [Range<usize>; D2], value: BoolTensor<B, D1>, ) -> BoolTensor<B, D1>; fn bool_equal<const D: usize>( lhs: BoolTensor<B, D>, rhs: BoolTensor<B, D>, ) -> BoolTensor<B, D>; fn bool_not<const D: usize>(tensor: BoolTensor<B, D>) -> BoolTensor<B, D>; fn bool_swap_dims<const D: usize>( tensor: BoolTensor<B, D>, dim1: usize, dim2: usize, ) -> BoolTensor<B, D>; fn bool_permute<const D: usize>( tensor: BoolTensor<B, D>, axes: [usize; D], ) -> BoolTensor<B, D>; fn bool_flip<const D: usize>( tensor: BoolTensor<B, D>, axes: &[usize], ) -> BoolTensor<B, D>; fn bool_expand<const D1: usize, const D2: usize>( tensor: BoolTensor<B, D1>, shape: Shape<D2>, ) -> BoolTensor<B, D2>; // Provided methods fn bool_repeat_dim<const D: usize>( tensor: BoolTensor<B, D>, dim: usize, times: usize, ) -> BoolTensor<B, D> { ... } fn bool_cat<const D: usize>( tensors: Vec<BoolTensor<B, D>>, dim: usize, ) -> BoolTensor<B, D> { ... } fn bool_not_equal<const D: usize>( lhs: BoolTensor<B, D>, rhs: BoolTensor<B, D>, ) -> BoolTensor<B, D> { ... } fn bool_transpose<const D: usize>( tensor: BoolTensor<B, D>, ) -> BoolTensor<B, D> { ... } fn bool_narrow<const D: usize>( tensor: BoolTensor<B, D>, dim: usize, start: usize, length: usize, ) -> BoolTensor<B, D> { ... } fn bool_chunk<const D: usize>( tensor: BoolTensor<B, D>, chunks: usize, dim: usize, ) -> Vec<BoolTensor<B, D>> { ... } fn bool_any<const D: usize>(tensor: BoolTensor<B, D>) -> BoolTensor<B, 1> { ... } fn bool_any_dim<const D: usize>( tensor: BoolTensor<B, D>, dim: usize, ) -> BoolTensor<B, D> { ... } fn bool_all<const D: usize>(tensor: BoolTensor<B, D>) -> BoolTensor<B, 1> { ... } fn bool_all_dim<const D: usize>( tensor: BoolTensor<B, D>, dim: usize, ) -> BoolTensor<B, D> { ... } fn bool_argwhere<const D: usize>( tensor: BoolTensor<B, D>, ) -> impl Future<Output = IntTensor<B, 2>> + Send { ... } fn bool_nonzero<const D: usize>( tensor: BoolTensor<B, D>, ) -> impl Future<Output = Vec<IntTensor<B, 1>>> + Send { ... }
}
Expand description

Bool Tensor API for basic operations, see tensor for documentation on each function.

Required Methods§

source

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

Creates a new bool tensor.

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

The boolean tensor with the given shape.

source

fn bool_shape<const D: usize>(tensor: &BoolTensor<B, D>) -> Shape<D>

Returns the shape of the tensor.

§Arguments
  • tensor - The tensor.
§Returns

The shape of the tensor.

source

fn bool_into_data<const D: usize>( tensor: BoolTensor<B, D>, ) -> impl Future<Output = TensorData> + Send

Converts the tensor to a data structure.

§Arguments
  • tensor - The tensor.
§Returns

The data structure with the tensor’s data.

source

fn bool_from_data<const D: usize>( data: TensorData, device: &Device<B>, ) -> BoolTensor<B, D>

Creates a tensor from the data structure.

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

The tensor with the data.

source

fn bool_into_int<const D: usize>(tensor: BoolTensor<B, D>) -> IntTensor<B, D>

Converts bool tensor to int tensor.

§Arguments
  • tensor - The tensor.
§Returns

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

source

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

Converts bool tensor to float tensor.

§Arguments
  • tensor - The tensor.
§Returns

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

source

fn bool_device<const D: usize>(tensor: &BoolTensor<B, D>) -> Device<B>

Gets the device of the tensor.

§Arguments
  • tensor - The tensor.
§Returns

The device of the tensor.

source

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

Moves the tensor to the device.

source

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

Reshapes the tensor.

§Arguments
  • tensor - The tensor.
  • shape - The new shape.
§Returns

The tensor with the new shape.

source

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

Gets the values from the tensor for the given ranges.

§Arguments
  • tensor - The tensor.
  • ranges - The ranges to get the values from.
§Returns

The tensor with the values for the given ranges.

source

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

Sets the values in the tensor for the given ranges.

§Arguments
  • tensor - The tensor.
  • ranges - The ranges to set the values for.
  • value - The values to set.
§Returns

The tensor with the values set for the given ranges.

source

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

Equates the two tensors.

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

The tensor with the result of the equate.

source

fn bool_not<const D: usize>(tensor: BoolTensor<B, D>) -> BoolTensor<B, D>

Inverses boolean values.

§Arguments
  • tensor - The tensor.
§Returns

The tensor with the result of the negation.

source

fn bool_swap_dims<const D: usize>( tensor: BoolTensor<B, D>, dim1: usize, dim2: usize, ) -> BoolTensor<B, D>

Swaps two dimensions of a bool 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 bool_permute<const D: usize>( tensor: BoolTensor<B, D>, axes: [usize; D], ) -> BoolTensor<B, D>

Permutes the dimensions of a tensor.

§Arguments
  • tensor - The tensor to permute the dimensions of.
  • axes - The new order of the dimensions.
§Returns

The tensor with the dimensions permuted.

source

fn bool_flip<const D: usize>( tensor: BoolTensor<B, D>, axes: &[usize], ) -> BoolTensor<B, D>

Reverse the order of elements in a tensor along the given axes.

§Arguments
  • tensor - The tensor to reverse.
  • axes - The axes to reverse.

The tensor with the elements reversed.

source

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

Broadcasts the bool tensor to the given shape.

Provided Methods§

source

fn bool_repeat_dim<const D: usize>( tensor: BoolTensor<B, D>, dim: usize, times: usize, ) -> BoolTensor<B, D>

Repeats one dimension of the tensor a given number of times along that dimension.

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

The tensor with the dimension repeated.

source

fn bool_cat<const D: usize>( tensors: Vec<BoolTensor<B, D>>, dim: usize, ) -> BoolTensor<B, D>

Concatenates the tensors along the given dimension.

§Arguments
  • tensors - The tensors to concatenate.
  • dim - The dimension to concatenate along.
§Returns

The tensor with the tensors concatenated along the given dimension.

source

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

Element-wise non-equality comparison.

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

The tensor with the result of the comparison.

source

fn bool_transpose<const D: usize>(tensor: BoolTensor<B, D>) -> BoolTensor<B, D>

Transposes a bool tensor.

§Arguments
  • tensor - The tensor to transpose.
§Returns

The transposed tensor.

source

fn bool_narrow<const D: usize>( tensor: BoolTensor<B, D>, dim: usize, start: usize, length: usize, ) -> BoolTensor<B, D>

Returns a new tensor with the given dimension narrowed to the given range.

§Arguments
  • dim - The dimension along which the tensor will be narrowed.
  • start - The starting point of the given range.
  • length - The ending point of the given range.
§Panics
  • If the dimension is greater than the number of dimensions of the tensor.
  • If the given range exceeds the number of elements on the given dimension.
§Returns

A new tensor with the given dimension narrowed to the given range.

source

fn bool_chunk<const D: usize>( tensor: BoolTensor<B, D>, chunks: usize, dim: usize, ) -> Vec<BoolTensor<B, D>>

Split the tensor along the given dimension into chunks.

§Arguments
  • tensor - The tensor.
  • chunks - The number of chunks to be produced
  • times - The dimension along which the tensor will be split.
§Returns

A vector of tensors

source

fn bool_any<const D: usize>(tensor: BoolTensor<B, D>) -> BoolTensor<B, 1>

Tests if any element in the boolean tensor evaluates to True.

§Arguments
  • tensor - The tensor to test.
§Returns

A boolean tensor with a single element, True if any element in the tensor is True, False otherwise.

source

fn bool_any_dim<const D: usize>( tensor: BoolTensor<B, D>, dim: usize, ) -> BoolTensor<B, D>

Tests if any element in the boolean tensor evaluates to True along a given dimension dim.

§Arguments
  • tensor - The tensor to test.
  • dim - The axis along which to test.
§Returns

A boolean tensor Tensor<B, D, Bool> with the same size as input tensor, except in the dim axis where the size is 1. The elem in the dim axis is True if any element along this dim in the input evaluates to True, False otherwise.

source

fn bool_all<const D: usize>(tensor: BoolTensor<B, D>) -> BoolTensor<B, 1>

Tests if all elements in the boolean tensor evaluate to True.

§Arguments
  • tensor - The tensor to test.
§Returns

A boolean tensor Tensor<B, 1, Bool> with a single element, True if all elements in the input tensor evaluate to True, False otherwise.

source

fn bool_all_dim<const D: usize>( tensor: BoolTensor<B, D>, dim: usize, ) -> BoolTensor<B, D>

Tests if all elements in the boolean tensor evaluate to True along a given dimension dim.

§Arguments
  • tensor - The tensor to test.
  • dim - The axis along which to test.
§Returns

A boolean tensor Tensor<B, D, Bool> with the same size as input tensor, except in the dim axis where the size is 1. The elem in the dim axis is True if all elements along this dim in the input evaluates to True, False otherwise.

source

fn bool_argwhere<const D: usize>( tensor: BoolTensor<B, D>, ) -> impl Future<Output = IntTensor<B, 2>> + Send

Compute the indices of the elements that are non-zero, grouped by element.

§Arguments
  • tensor - The input tensor.
§Returns

A vector of tensors, one for each dimension of the given tensor, containing the indices of the non-zero elements in that dimension.

source

fn bool_nonzero<const D: usize>( tensor: BoolTensor<B, D>, ) -> impl Future<Output = Vec<IntTensor<B, 1>>> + Send

Compute the indices of the elements that are non-zero.

§Arguments
  • tensor - The input tensor.
§Returns

A vector of tensors, one for each dimension of the given tensor, containing the indices of the non-zero elements in that dimension.

Object Safety§

This trait is not object safe.

Implementors§