BoolTensorOps

Trait BoolTensorOps 

Source
pub trait BoolTensorOps<B: Backend> {
Show 33 methods // Required methods fn bool_empty(shape: Shape, device: &Device<B>) -> BoolTensor<B>; fn bool_zeros(shape: Shape, device: &Device<B>) -> BoolTensor<B>; fn bool_ones(shape: Shape, device: &Device<B>) -> BoolTensor<B>; fn bool_into_data( tensor: BoolTensor<B>, ) -> impl Future<Output = TensorData> + Send; fn bool_from_data(data: TensorData, device: &Device<B>) -> BoolTensor<B>; fn bool_into_int(tensor: BoolTensor<B>) -> IntTensor<B>; fn bool_into_float(tensor: BoolTensor<B>) -> FloatTensor<B>; fn bool_device(tensor: &BoolTensor<B>) -> Device<B>; fn bool_to_device( tensor: BoolTensor<B>, device: &Device<B>, ) -> BoolTensor<B>; fn bool_reshape(tensor: BoolTensor<B>, shape: Shape) -> BoolTensor<B>; fn bool_slice(tensor: BoolTensor<B>, slices: &[Slice]) -> BoolTensor<B>; fn bool_slice_assign( tensor: BoolTensor<B>, slices: &[Slice], value: BoolTensor<B>, ) -> BoolTensor<B>; fn bool_equal(lhs: BoolTensor<B>, rhs: BoolTensor<B>) -> BoolTensor<B>; fn bool_not(tensor: BoolTensor<B>) -> BoolTensor<B>; fn bool_and(tensor: BoolTensor<B>, rhs: BoolTensor<B>) -> BoolTensor<B>; fn bool_or(tensor: BoolTensor<B>, rhs: BoolTensor<B>) -> BoolTensor<B>; fn bool_swap_dims( tensor: BoolTensor<B>, dim1: usize, dim2: usize, ) -> BoolTensor<B>; fn bool_permute(tensor: BoolTensor<B>, axes: &[usize]) -> BoolTensor<B>; fn bool_flip(tensor: BoolTensor<B>, axes: &[usize]) -> BoolTensor<B>; fn bool_expand(tensor: BoolTensor<B>, shape: Shape) -> BoolTensor<B>; fn bool_unfold( tensor: BoolTensor<B>, dim: usize, size: usize, step: usize, ) -> BoolTensor<B>; // Provided methods fn bool_select( tensor: BoolTensor<B>, dim: usize, indices: IntTensor<B>, ) -> BoolTensor<B> { ... } fn bool_select_assign( tensor: BoolTensor<B>, dim: usize, indices: IntTensor<B>, value: BoolTensor<B>, ) -> BoolTensor<B> { ... } fn bool_repeat_dim( tensor: BoolTensor<B>, dim: usize, times: usize, ) -> BoolTensor<B> { ... } fn bool_cat(tensors: Vec<BoolTensor<B>>, dim: usize) -> BoolTensor<B> { ... } fn bool_not_equal(lhs: BoolTensor<B>, rhs: BoolTensor<B>) -> BoolTensor<B> { ... } fn bool_xor(lhs: BoolTensor<B>, rhs: BoolTensor<B>) -> BoolTensor<B> { ... } fn bool_transpose(tensor: BoolTensor<B>) -> BoolTensor<B> { ... } fn bool_any(tensor: BoolTensor<B>) -> BoolTensor<B> { ... } fn bool_any_dim(tensor: BoolTensor<B>, dim: usize) -> BoolTensor<B> { ... } fn bool_all(tensor: BoolTensor<B>) -> BoolTensor<B> { ... } fn bool_all_dim(tensor: BoolTensor<B>, dim: usize) -> BoolTensor<B> { ... } fn bool_argwhere( tensor: BoolTensor<B>, ) -> impl Future<Output = IntTensor<B>> + 'static + Send { ... }
}
Expand description

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

Required Methods§

Source

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

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_zeros(shape: Shape, device: &Device<B>) -> BoolTensor<B>

Creates a new bool tensor filled false.

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

The boolean tensor filled with false.

Source

fn bool_ones(shape: Shape, device: &Device<B>) -> BoolTensor<B>

Creates a new bool tensor filled true.

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

The boolean tensor filled with true.

Source

fn bool_into_data( tensor: BoolTensor<B>, ) -> 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(data: TensorData, device: &Device<B>) -> BoolTensor<B>

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: BoolTensor<B>) -> IntTensor<B>

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: BoolTensor<B>) -> FloatTensor<B>

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: &BoolTensor<B>) -> Device<B>

Gets the device of the tensor.

§Arguments
  • tensor - The tensor.
§Returns

The device of the tensor.

Source

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

Moves the tensor to the device.

Source

fn bool_reshape(tensor: BoolTensor<B>, shape: Shape) -> BoolTensor<B>

Reshapes the tensor.

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

The tensor with the new shape.

Source

fn bool_slice(tensor: BoolTensor<B>, slices: &[Slice]) -> BoolTensor<B>

Gets the values from the tensor for the given ranges.

§Arguments
  • tensor - The tensor.
  • slices - The slices specifying ranges and steps for each dimension.
§Returns

The tensor with the values for the given slices.

Source

fn bool_slice_assign( tensor: BoolTensor<B>, slices: &[Slice], value: BoolTensor<B>, ) -> BoolTensor<B>

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: BoolTensor<B>, rhs: BoolTensor<B>) -> BoolTensor<B>

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: BoolTensor<B>) -> BoolTensor<B>

Inverses boolean values.

§Arguments
  • tensor - The tensor.
§Returns

The tensor with the result of the negation.

Source

fn bool_and(tensor: BoolTensor<B>, rhs: BoolTensor<B>) -> BoolTensor<B>

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: BoolTensor<B>, rhs: BoolTensor<B>) -> BoolTensor<B>

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: BoolTensor<B>, dim1: usize, dim2: usize, ) -> BoolTensor<B>

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: BoolTensor<B>, axes: &[usize]) -> BoolTensor<B>

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: BoolTensor<B>, axes: &[usize]) -> BoolTensor<B>

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: BoolTensor<B>, shape: Shape) -> BoolTensor<B>

Broadcasts the bool tensor to the given shape.

Source

fn bool_unfold( tensor: BoolTensor<B>, dim: usize, size: usize, step: usize, ) -> BoolTensor<B>

Unfold windows along a dimension.

Returns a view of the tensor with all complete windows of size size in dimension dim; where windows are advanced by step at each index.

The number of windows is max(0, (shape[dim] - size).ceil_div(step)).

§Arguments
  • tensor - The input tensor to unfold; of shape [pre=..., dim shape, post=...]
  • dim - the selected dim.
  • size - the size of each unfolded window.
  • step - the step between each window.
§Returns

A tensor view with shape [pre=..., windows, size, post=...].

Provided Methods§

Source

fn bool_select( tensor: BoolTensor<B>, dim: usize, indices: IntTensor<B>, ) -> BoolTensor<B>

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

§Arguments
  • tensor - The tensor to select from.
  • dim - The dimension to select from.
  • indices - The indices of the elements to select.
§Returns

The tensor with the selected elements.

Source

fn bool_select_assign( tensor: BoolTensor<B>, dim: usize, indices: IntTensor<B>, value: BoolTensor<B>, ) -> BoolTensor<B>

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

§Arguments
  • tensor - The tensor to assign the values to.
  • dim - The dimension to select from.
  • indices - The indices of the elements to assign.
  • value - The values to assign.
§Returns

The tensor with the assigned values.

Source

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

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<BoolTensor<B>>, dim: usize) -> BoolTensor<B>

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: BoolTensor<B>, rhs: BoolTensor<B>) -> BoolTensor<B>

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_xor(lhs: BoolTensor<B>, rhs: BoolTensor<B>) -> BoolTensor<B>

Element-wise exclusive or.

§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: BoolTensor<B>) -> BoolTensor<B>

Transposes a bool tensor.

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

The transposed tensor.

Source

fn bool_any(tensor: BoolTensor<B>) -> BoolTensor<B>

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: BoolTensor<B>, dim: usize) -> BoolTensor<B>

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: BoolTensor<B>) -> BoolTensor<B>

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: BoolTensor<B>, dim: usize) -> BoolTensor<B>

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: BoolTensor<B>, ) -> impl Future<Output = IntTensor<B>> + 'static + Send

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.

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§