Trait BoolTensorOps

Source
pub trait BoolTensorOps<B>
where B: Backend,
{
Show 32 methods // Required methods fn bool_empty( shape: Shape, device: &<B as Backend>::Device, ) -> <B as Backend>::BoolTensorPrimitive; fn bool_into_data( tensor: <B as Backend>::BoolTensorPrimitive, ) -> impl Future<Output = TensorData> + Send + 'static; fn bool_from_data( data: TensorData, device: &<B as Backend>::Device, ) -> <B as Backend>::BoolTensorPrimitive; fn bool_into_int( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::IntTensorPrimitive; fn bool_into_float( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::FloatTensorPrimitive; fn bool_device( tensor: &<B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::Device; fn bool_to_device( tensor: <B as Backend>::BoolTensorPrimitive, device: &<B as Backend>::Device, ) -> <B as Backend>::BoolTensorPrimitive; fn bool_reshape( tensor: <B as Backend>::BoolTensorPrimitive, shape: Shape, ) -> <B as Backend>::BoolTensorPrimitive; fn bool_slice( tensor: <B as Backend>::BoolTensorPrimitive, ranges: &[Range<usize>], ) -> <B as Backend>::BoolTensorPrimitive; fn bool_slice_assign( tensor: <B as Backend>::BoolTensorPrimitive, ranges: &[Range<usize>], value: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive; fn bool_equal( lhs: <B as Backend>::BoolTensorPrimitive, rhs: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive; fn bool_not( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive; fn bool_and( tensor: <B as Backend>::BoolTensorPrimitive, rhs: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive; fn bool_or( tensor: <B as Backend>::BoolTensorPrimitive, rhs: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive; fn bool_swap_dims( tensor: <B as Backend>::BoolTensorPrimitive, dim1: usize, dim2: usize, ) -> <B as Backend>::BoolTensorPrimitive; fn bool_permute( tensor: <B as Backend>::BoolTensorPrimitive, axes: &[usize], ) -> <B as Backend>::BoolTensorPrimitive; fn bool_flip( tensor: <B as Backend>::BoolTensorPrimitive, axes: &[usize], ) -> <B as Backend>::BoolTensorPrimitive; fn bool_expand( tensor: <B as Backend>::BoolTensorPrimitive, shape: Shape, ) -> <B as Backend>::BoolTensorPrimitive; // Provided methods fn bool_repeat_dim( tensor: <B as Backend>::BoolTensorPrimitive, dim: usize, times: usize, ) -> <B as Backend>::BoolTensorPrimitive { ... } fn bool_cat( tensors: Vec<<B as Backend>::BoolTensorPrimitive>, dim: usize, ) -> <B as Backend>::BoolTensorPrimitive { ... } fn bool_not_equal( lhs: <B as Backend>::BoolTensorPrimitive, rhs: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive { ... } fn bool_transpose( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive { ... } fn bool_narrow( tensor: <B as Backend>::BoolTensorPrimitive, dim: usize, start: usize, length: usize, ) -> <B as Backend>::BoolTensorPrimitive { ... } fn bool_chunk( tensor: <B as Backend>::BoolTensorPrimitive, chunks: usize, dim: usize, ) -> Vec<<B as Backend>::BoolTensorPrimitive> { ... } fn bool_split( tensor: <B as Backend>::BoolTensorPrimitive, split_size: usize, dim: usize, ) -> Vec<<B as Backend>::BoolTensorPrimitive> { ... } fn bool_split_with_sizes( tensor: <B as Backend>::BoolTensorPrimitive, split_sizes: Vec<usize>, dim: usize, ) -> Vec<<B as Backend>::BoolTensorPrimitive> { ... } fn bool_any( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive { ... } fn bool_any_dim( tensor: <B as Backend>::BoolTensorPrimitive, dim: usize, ) -> <B as Backend>::BoolTensorPrimitive { ... } fn bool_all( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive { ... } fn bool_all_dim( tensor: <B as Backend>::BoolTensorPrimitive, dim: usize, ) -> <B as Backend>::BoolTensorPrimitive { ... } fn bool_argwhere( tensor: <B as Backend>::BoolTensorPrimitive, ) -> impl Future<Output = <B as Backend>::IntTensorPrimitive> + Send + 'static { ... } fn bool_nonzero( tensor: <B as Backend>::BoolTensorPrimitive, ) -> impl Future<Output = Vec<<B as Backend>::IntTensorPrimitive>> + Send + 'static { ... }
}
Expand description

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

Required Methods§

Source

fn bool_empty( shape: Shape, device: &<B as Backend>::Device, ) -> <B as Backend>::BoolTensorPrimitive

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_into_data( tensor: <B as Backend>::BoolTensorPrimitive, ) -> impl Future<Output = TensorData> + Send + 'static

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( data: TensorData, device: &<B as Backend>::Device, ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::IntTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::FloatTensorPrimitive

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( tensor: &<B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::Device

Gets the device of the tensor.

§Arguments
  • tensor - The tensor.
§Returns

The device of the tensor.

Source

fn bool_to_device( tensor: <B as Backend>::BoolTensorPrimitive, device: &<B as Backend>::Device, ) -> <B as Backend>::BoolTensorPrimitive

Moves the tensor to the device.

Source

fn bool_reshape( tensor: <B as Backend>::BoolTensorPrimitive, shape: Shape, ) -> <B as Backend>::BoolTensorPrimitive

Reshapes the tensor.

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

The tensor with the new shape.

Source

fn bool_slice( tensor: <B as Backend>::BoolTensorPrimitive, ranges: &[Range<usize>], ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, ranges: &[Range<usize>], value: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive

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( lhs: <B as Backend>::BoolTensorPrimitive, rhs: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive

Inverses boolean values.

§Arguments
  • tensor - The tensor.
§Returns

The tensor with the result of the negation.

Source

fn bool_and( tensor: <B as Backend>::BoolTensorPrimitive, rhs: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive

Executes the logical and (&&) operation on two boolean tensors.

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

The tensor with the result of the logical and.

Source

fn bool_or( tensor: <B as Backend>::BoolTensorPrimitive, rhs: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive

Executes the logical or (||) operation on two boolean tensors.

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

The tensor with the result of the logical or.

Source

fn bool_swap_dims( tensor: <B as Backend>::BoolTensorPrimitive, dim1: usize, dim2: usize, ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, axes: &[usize], ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, axes: &[usize], ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, shape: Shape, ) -> <B as Backend>::BoolTensorPrimitive

Broadcasts the bool tensor to the given shape.

Provided Methods§

Source

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

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( tensors: Vec<<B as Backend>::BoolTensorPrimitive>, dim: usize, ) -> <B as Backend>::BoolTensorPrimitive

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( lhs: <B as Backend>::BoolTensorPrimitive, rhs: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive

Transposes a bool tensor.

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

The transposed tensor.

Source

fn bool_narrow( tensor: <B as Backend>::BoolTensorPrimitive, dim: usize, start: usize, length: usize, ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, chunks: usize, dim: usize, ) -> Vec<<B as Backend>::BoolTensorPrimitive>

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_split( tensor: <B as Backend>::BoolTensorPrimitive, split_size: usize, dim: usize, ) -> Vec<<B as Backend>::BoolTensorPrimitive>

Split the tensor along the given dimension into chunks of split_size.

§Arguments
  • tensor - The tensor.
  • split_size - The size of a single chunk.
  • times - The dimension along which the tensor will be split.
§Returns

A vector of tensors.

Source

fn bool_split_with_sizes( tensor: <B as Backend>::BoolTensorPrimitive, split_sizes: Vec<usize>, dim: usize, ) -> Vec<<B as Backend>::BoolTensorPrimitive>

Split the tensor along the given dimension into chunks with sizes in dim according to split_sizes.

§Arguments
  • tensor - The tensor.
  • split_sizes - Vector of sizes for each chunk.
  • times - The dimension along which the tensor will be split.
§Returns

A vector of tensors.

Source

fn bool_any( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, dim: usize, ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, dim: usize, ) -> <B as Backend>::BoolTensorPrimitive

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( tensor: <B as Backend>::BoolTensorPrimitive, ) -> impl Future<Output = <B as Backend>::IntTensorPrimitive> + Send + 'static

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

§Arguments
  • tensor - The input tensor.
§Returns

A 2D tensor containing the indices of all non-zero elements of the given tensor. Each row contains the indices of a non-zero element.

Source

fn bool_nonzero( tensor: <B as Backend>::BoolTensorPrimitive, ) -> impl Future<Output = Vec<<B as Backend>::IntTensorPrimitive>> + Send + 'static

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. If all elements are zero, the vector is empty.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§