vt::any#

template<typename T, size_t N>
bool vt::any(const Tensor<T, N> &tensor)#

Check if any element of the tensor is true. thrust::any_of utilizes transform_reduce algorithm to check if any element is true. Looks like if the tensor is sliced, the iterator index will go beyond the tensor size, which will cause the function to return wrong answer. The workaround is to use thrust::count_if to count the number of true elements.

Template Parameters:
  • T – Data type of the tensor.

  • N – Number of dimensions of the tensor.

Parameters:

tensor – The tensor object.

Returns:

bool: True if any element is true, false otherwise.

template<typename T, size_t N>
Tensor<bool, N - 1> vt::any(const Tensor<T, N> &tensor, int axis)#

Check if any element of the tensor is true along the given axis.

Template Parameters:
  • T – Data type of the tensor.

  • N – Number of dimensions of the tensor.

Parameters:
  • tensor – The tensor object.

  • axis – The axis to check if any element is true.

Returns:

Tensor<bool, N-1>: The result tensor.