Statistics¶
The API below provides methods for statistics functions. Note that some non-cached plans use a generic handle for CUB, and just pass in the appropriate operation.
Cached API¶
-
template<typename OutputTensor, typename InputTensor>
void matx::cumsum(OutputTensor &a_out, const InputTensor &a, const cudaStream_t stream = 0)¶ Compute a cumulative sum (prefix sum) of rows of a tensor
Computes an exclusive cumulative sum over rows in a tensor. For example, and input tensor of [1, 2, 3, 4] would give the output [1, 3, 6, 10].
- Template Parameters
T1 – Type of data to sort
RANK – Rank of tensor
- Parameters
a_out – Sorted tensor
a – Input tensor
stream – CUDA stream
-
template<typename OutputTensor, typename InputTensor>
void matx::hist(OutputTensor &a_out, const InputTensor &a, const typename InputTensor::scalar_type lower, const typename InputTensor::scalar_type upper, const cudaStream_t stream = 0)¶ Compute a histogram of rows in a tensor
Computes a histogram with the given number of levels and upper/lower limits. The number of levels is one greater than the number of bins generated, and is determined by the size of the last dimension of the output tensor. Each bin contains elements falling within idx*(upper-lower)/a.out.Lsize(). In other words, each bin is as large as the different between the upper and lower bounds and the number of bins
- Template Parameters
T1 – Type of data to sort
RANK – Rank of tensor
- Parameters
a_out – Sorted tensor
a – Input tensor
lower – Lower limit
upper – Upper limit
stream – CUDA stream
Non-Cached API¶
-
template<typename OutputTensor, typename InputTensor, CUBOperation_t op>
class matx::matxCubPlan_t¶ Public Functions
-
inline matxCubPlan_t(OutputTensor &a_out, const InputTensor &a, const std::any &cparams, const cudaStream_t stream = 0)¶
Construct a handle for CUB operations
Creates a handle for performing a CUB operation. Currently supported operations are sorting and prefix sum (cumsum). Operations can either be a single dimension, or batched across a dimension (rows of a matrix, for example).
- Parameters
a – Input tensor view
a_out – Sorted output
cparams – Parameter structure specific to the operation
stream – CUDA stream
-
inline ~matxCubPlan_t()¶
Sort destructor
Destroys any helper data used for provider type and any workspace memory created
-
inline void ExecHistEven(OutputTensor &a_out, const InputTensor &a, const T1 lower, const T1 upper, const cudaStream_t stream)¶
Execute an inclusive prefix sum on a tensor
Note
Views being passed must be in row-major order
- Template Parameters
T1 – Type of tensor
- Parameters
a_out – Output tensor (must be an integer type)
a – Input tensor
lower – Lower bound on histogram
upper – Upper bound on histogram
stream – CUDA stream
-
inline void ExecPrefixScanEx(OutputTensor &a_out, const InputTensor &a, const cudaStream_t stream)¶
Execute an inclusive prefix sum on a tensor
Note
Views being passed must be in row-major order
- Template Parameters
T1 – Type of tensor
- Parameters
a_out – Output tensor
a – Input tensor
stream – CUDA stream
-
inline void ExecSort(OutputTensor &a_out, const InputTensor &a, const cudaStream_t stream, const SortDirection_t dir = SORT_DIR_ASC)¶
Execute a sort on a tensor
Note
Views being passed must be in row-major order
- Template Parameters
T1 – Type of tensor
- Parameters
a_out – Output tensor
a – Input tensor
stream – CUDA stream
dir – Sort order (SORT_DIR_ASC or SORT_DIR_DESC)
-
inline matxCubPlan_t(OutputTensor &a_out, const InputTensor &a, const std::any &cparams, const cudaStream_t stream = 0)¶