27namespace nda::tensor {
37 template <
int Axis,
int Rank>
39 return [&]<
size_t... Before,
size_t... After>(std::index_sequence<Before...>, std::index_sequence<After...>) ->
decltype(
auto) {
40 return arr(((
void)Before, ::nda::range::all)..., i, ((
void)After, ::nda::range::all)...);
41 }(std::make_index_sequence<Axis>{}, std::make_index_sequence<Rank - Axis - 1>{});
46 template <MemoryArray A, MemoryArray B>
47 void rec_copy(A
const &a, B &&b) {
55 long n = b.extent(axis);
56 for (
long i = 0; i < n; ++i) rec_copy(slice_axis<axis, rank>(a, i), slice_axis<axis, rank>(b, i));
100 template <MemoryArray A, MemoryArray B>
102 void assign(A
const &a, std::string_view idx_a, B &&b, std::string_view idx_b) {
109 "nda::tensor::assign: host/cross-memory fallback requires identical ranks");
112 if constexpr (use_cutensor) {
114 }
else if constexpr (use_tblis) {
118 if constexpr (host_compat) {
121 detail::rec_copy(a, b);
127 template <MemoryArray A, MemoryArray B>
Provides definitions and type traits involving the different memory address spaces supported by nda.
decltype(auto) slice_axis(auto &&arr, long i)
Slice arr on the compile-time axis Axis at index i, padding the other axes with range::all.
Provides concepts for the nda library.
Provides a C++ interface for various cuTENSOR routines.
constexpr bool have_same_value_type_v
Constexpr variable that is true if all types in As have the same value type as A0.
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.
constexpr bool has_layout_strided_1d
Constexpr variable that is true if type A has the strided_1d nda::layout_prop_e guarantee.
constexpr layout_info_t get_layout_info
Constexpr variable that specifies the nda::layout_info_t of type A.
static constexpr bool have_host_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Host.
static constexpr bool have_device_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Device.
void assign(A const &a, std::string_view idx_a, B &&b, std::string_view idx_b)
Tensor assignment 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.
void require_equal_indices(std::string_view idx_a, std::string_view idx_b, int rank, std::string_view op_name)
Check if two index strings are equal and have a specified length.
std::string_view default_index()
Generate a default index string ("abc...") of a given length.
constexpr std::array< int, N > decode(uint64_t binary_representation)
Decode a uint64_t into a std::array<int, N>.
constexpr bool is_blas_lapack_v
Constexpr variable that is true if type T is either of type 'float', double, std::complex<float>' or ...
Macros used in the nda library.
Includes the itertools header and provides some additional utilities.
Provides a C++ interface for various TBLIS tensor routines.
Provides type traits for the nda library.