31namespace nda::tensor {
66 template <BlasArrayOrConj A>
70 static_assert(!run_on_device ||
have_cutensor,
"nda::tensor::reduce: cuTENSOR support is required");
73 if constexpr (run_on_device) {
85 NDA_RUNTIME_ERROR <<
"nda::tensor::reduce: binary_op::MAX/MIN are unsupported for complex value types";
91 case binary_op::SUM:
return nda::sum(a);
98 case binary_op::MIN:
return max_min(op_reduce);
99 default: NDA_RUNTIME_ERROR <<
"nda::tensor::reduce: unknown binary_op on nda host fallback";
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides various algorithms to be used with nda::Array objects.
Provides the generic class for arrays.
A generic multi-dimensional array.
Provides concepts for the nda library.
Provides a C++ interface for various cuTENSOR routines.
Provides various convenient aliases and helper functions for nda::basic_array and nda::basic_array_vi...
auto max_element(A const &a)
Find the maximum element of an array.
auto sum(A const &a)
Sum all the elements of an nda::Array object.
auto product(A const &a)
Multiply all the elements of an nda::Array object.
auto min_element(A const &a)
Find the minimum element of an array.
auto zeros(std::array< Int, Rank > const &shape)
Make an array of the given shape on the given address space and zero-initialize it.
decltype(auto) to_host(A &&a)
Convert an nda::MemoryArray to its regular type on host memory.
auto abs(A &&a)
Function abs for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
auto abs2(A &&a)
Function abs2 for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
constexpr int get_rank
Constexpr variable that specifies the rank of an nda::Array or of a contiguous 1-dimensional range.
std::decay_t< decltype(get_first_element(std::declval< A const >()))> get_value_t
Get the value type of an array/view or a scalar type.
static constexpr bool have_device_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Device.
heap_basic< mem::mallocator< AdrSp > > heap
Alias template of the nda::heap_basic policy using an nda::mem::mallocator.
get_value_t< A > reduce(A const &a, binary_op op_reduce=binary_op::SUM)
Full tensor reduction with cuTENSOR/TBLIS/nda dispatch.
static constexpr bool have_tblis
Constexpr variable that is true if nda is configured with TBLIS support.
static constexpr bool have_cutensor
Constexpr variable that is true if nda is configured cuTENSOR support.
binary_op
Binary operations for tensor operations.
std::string_view default_index()
Generate a default index string ("abc...") of a given length.
constexpr bool is_complex_v
Constexpr variable that is true if type T is a std::complex type.
Provides definitions of various layout policies.
Macros used in the nda library.
Provides some custom implementations of standard mathematical functions used for lazy,...
Provides lazy, coefficient-wise array operations of standard mathematical functions together with ove...
Defines various memory handling policies.
Contiguous layout policy with C-order (row-major order).
Provides a C++ interface for various TBLIS tensor routines.
Provides type traits for the nda library.