Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Files | Concepts | Classes | Typedefs | Functions | Variables
Mdspan extensions

Additional concepts, adaptors, and helpers that extend the reference mdspan implementation. More...

Files

file  conjugate_accessor.hpp
 Mdspan accessor adaptor for lazy complex conjugation.
 
file  diagonal_accessor.hpp
 Accessor support for compressed generalized diagonal tensors.
 
file  format.hpp
 Formatting support for mdspan extents.
 
file  generated_accessor.hpp
 Read-only mdspan accessor for values generated from logical indices.
 
file  generated_layout.hpp
 Synthetic mdspan layout for values generated from logical indices.
 
file  iteration_plan.hpp
 Helpers for constructing merged iteration plans over strided tensors.
 
file  mdspan.hpp
 Configured gateway to Uni20's mdspan implementation.
 
file  mdspec.hpp
 Mdspan-shaped metadata for storage whose data handle requires acquisition.
 
file  strides.hpp
 Stride utilities for mdspan-like tensors.
 
file  transform_view.hpp
 Lazy read-only elementwise transform views over mdspan-like inputs.
 
file  zip_layout.hpp
 Additional layout helpers and policies for zipped mdspan views.
 

Concepts

concept  uni20::StridedMdspanLike
 An mdspan-like type whose mapping is always strided and exposes stride observers.
 
concept  uni20::StridedMdspecLike
 An mdspec-like type whose mapping exposes multidimensional strides.
 
concept  uni20::RankedMdspanLike
 An mdspan-like type with a specified static rank.
 
concept  uni20::RankedMdspecLike
 An mdspec-like type with a specified static rank.
 
concept  uni20::MutableRankedMdspanLike
 A mutable mdspan-like type with a specified static rank.
 
concept  uni20::DefaultAccessorMdspanLike
 An mdspan-like type whose accessor is stdex::default_accessor.
 
concept  uni20::RankedStridedMdspanLike
 A strided mdspan-like type with a specified static rank.
 
concept  uni20::RankedStridedMdspecLike
 A strided mdspec-like type with a specified static rank.
 
concept  uni20::MutableRankedStridedMdspanLike
 A mutable strided mdspan-like type with a specified static rank.
 
concept  uni20::AccessorPolicy
 A model of the C++ mdspan AccessorPolicy named requirement.
 
concept  uni20::MdspanLike
 A readable type implementing the mdspan observers and multidimensional subscript contract.
 
concept  uni20::MdspecLike
 Mdspan metadata whose data handle is immediate or available through a data descriptor.
 
concept  uni20::MutableMdspanLike
 MdspanLike types whose accessor supports indexed assignment.
 
concept  uni20::MutableMdspecLike
 MdspecLike types whose eventual storage supports writes.
 
concept  uni20::MutableStridedMdspanLike
 Mutable mdspan-like types whose layout reports they are always strided.
 
concept  uni20::MutableStridedMdspecLike
 Mutable mdspec-like type whose mapping is always strided.
 
concept  uni20::DiagonalMdspecLike
 Full logical mdspec with a rank-one view of its generalized diagonal components.
 
concept  uni20::MutableDiagonalMdspecLike
 Writable generalized-diagonal mdspec with writable rank-one components.
 
concept  uni20::MutableRankedMdspecLike
 Mutable mdspec-like type with a specified static rank.
 
concept  uni20::MutableRankedStridedMdspecLike
 Mutable strided mdspec-like type with a specified static rank.
 

Classes

class  uni20::const_accessor_adaptor< Accessor >
 Adaptor that exposes a mutable lvalue accessor as read-only. More...
 
struct  uni20::extent_strides< N >
 Structure to represent a common extent and an array of strides. More...
 
struct  uni20::GeneralZipLayout< Layouts >
 Fallback zip layout for arbitrary mapping policies. More...
 
struct  uni20::is_default_accessor< Accessor >
 Trait that recognizes the standard mdspan default accessor. More...
 
struct  uni20::is_default_accessor< stdex::default_accessor< ElementType > >
 Specialization for stdex::default_accessor<T>. More...
 
struct  uni20::span_offset_type< AP, typename >
 Trait to pull an AccessorPolicy’s offset_type if present, or fall back to std::size_t otherwise. More...
 
struct  uni20::span_offset_type< AP, std::void_t< typename AP::offset_type > >
 Partial specialization that uses an accessor policy’s declared offset_type. More...
 
struct  uni20::StridedZipLayout< NumSpans >
 Zip layout for NumSpans strided spans (all using layout_stride). More...
 
struct  uni20::StridedZipLayout< NumSpans >::mapping< Ext >
 Nested mapping policy for extents Ext, modeling LayoutMappingPolicy. More...
 
struct  uni20::zip_layout_selector< Spans >
 Picks the right zip layout for a pack of mdspan types. More...
 
struct  uni20::zip_layout_selector< Spans... >
 Specialization that selects StridedZipLayout when all spans are strided. More...
 

Typedefs

template<AccessorPolicy Acc>
using uni20::const_accessor_t = decltype(const_accessor(std::declval< Acc >()))
 Type alias that produces the const-qualified version of an accessor policy.
 
template<typename AP >
using uni20::span_offset_t = typename span_offset_type< AP >::type
 Convenience alias for accessor_offset_type<AP>::type.
 
using uni20::span_offset_type< AP, typename >::type = std::size_t
 The resulting offset type (std::size_t by default).
 
using uni20::span_offset_type< AP, std::void_t< typename AP::offset_type > >::type = typename AP::offset_type
 The resulting offset type defined by the accessor policy.
 
template<typename... Spans>
using uni20::zip_layout_t = typename zip_layout_selector< Spans... >::type
 Alias to extract the chosen layout policy for the given spans.
 

Functions

UNI20_HOST_DEVICE std::array< std::array< index_type, Ext::rank()>, num_spans > const & uni20::StridedZipLayout< NumSpans >::mapping< Ext >::all_strides () const noexcept
 Retrieve the 2-D array of all per-span strides.
 
constexpr bool uni20::extent_strides< N >::can_merge_with_inner (extent_strides inner) const noexcept
 Returns true if the current (outer) dimension and the given inner dimension can be merged.
 
template<MdspanLike Span, class... Index>
requires detail::MdspanIndexPack<Span, Index...>
constexpr decltype(auto) uni20::const_access (Span const &span, Index... indices)
 Access one mdspan element through a read-only adaptation of its stored accessor.
 
template<AccessorPolicy Acc>
requires (!std::is_const_v<typename Acc::element_type> && std::is_same_v<typename Acc::reference, typename Acc::element_type&>)
constexpr auto uni20::const_accessor (Acc const &acc)
 Wrap any accessor whose reference is T& into a const adaptor.
 
template<typename T >
constexpr stdex::default_accessor< T const > uni20::const_accessor (stdex::default_accessor< T > const &accessor_policy)
 Wrap a default_accessor<T> into a const_default_accessor<T>.
 
template<typename Ext , typename Str >
requires std::is_integral_v<Ext> && std::is_integral_v<Str>
constexpr uni20::extent_strides< N >::extent_strides (Ext e, std::array< Str, N > s)
 Construct from an extent and an array of strides.
 
template<typename Ext >
requires std::is_integral_v<Ext>
constexpr uni20::extent_strides< N >::extent_strides (Ext e, std::initializer_list< std::ptrdiff_t > s)
 Construct from an extent and initializer-list strides.
 
template<typename Ext , typename... Strides>
requires (std::is_integral_v<Ext> && sizeof...(Strides) == N)
constexpr uni20::extent_strides< N >::extent_strides (Ext e, Strides... s)
 Construct from an extent and a parameter pack of stride values.
 
UNI20_HOST_DEVICE constexpr extents_type const & uni20::StridedZipLayout< NumSpans >::mapping< Ext >::extents () const noexcept
 Return the extents of the layout.
 
UNI20_HOST_DEVICE constexpr extents_type const & uni20::GeneralZipLayout< Layouts >::mapping< Extents >::extents () const noexcept
 Access the common extents.
 
template<StridedMdspanLike AType, StridedMdspanLike BType, StridedMdspanLike CType, std::size_t N>
auto uni20::extract_strides (AType const &A, BType const &B, std::array< std::pair< std::size_t, std::size_t >, N > const &contractDims, CType const &C)
 Extract merged stride groups for a tensor contraction.
 
static UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_always_exhaustive () noexcept
 Never exhaustive: no single contiguous backing buffer.
 
static UNI20_HOST_DEVICE constexpr bool uni20::GeneralZipLayout< Layouts >::mapping< Extents >::is_always_exhaustive () noexcept
 Never exhaustive: no single contiguous backing buffer.
 
static UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_always_strided () noexcept
 Statically unknown if strided: may differ per dimension.
 
static UNI20_HOST_DEVICE constexpr bool uni20::GeneralZipLayout< Layouts >::mapping< Extents >::is_always_strided () noexcept
 Not strided.
 
static UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_always_unique () noexcept
 Always unique for uni20 tensors.
 
static UNI20_HOST_DEVICE constexpr bool uni20::GeneralZipLayout< Layouts >::mapping< Extents >::is_always_unique () noexcept
 Always unique for uni20 tensors.
 
UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_exhaustive () const noexcept
 Never exhaustive at runtime.
 
UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_strided () const noexcept
 True if every dimension uses the same stride across all spans.
 
UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_unique () const noexcept
 Always unique at runtime.
 
UNI20_HOST_DEVICE constexpr uni20::GeneralZipLayout< Layouts >::mapping< Extents >::mapping (Extents const &ext, typename Layouts::template mapping< Extents > const &... m) noexcept
 Construct child mappings.
 
template<typename... Mappings>
UNI20_HOST_DEVICE constexpr uni20::StridedZipLayout< NumSpans >::mapping< Ext >::mapping (extents_type const &exts, Mappings... maps) noexcept
 Construct from extents and existing child mappings.
 
UNI20_HOST_DEVICE constexpr uni20::StridedZipLayout< NumSpans >::mapping< Ext >::mapping (extents_type const &exts, std::array< std::array< index_type, Ext::rank()>, NumSpans > const &strides_pack) noexcept
 Construct from shared extents and per-span raw strides.
 
template<typename LeftMap , typename RightMap >
requires (LeftMap::num_spans + RightMap::num_spans == num_spans)
UNI20_HOST_DEVICE constexpr uni20::StridedZipLayout< NumSpans >::mapping< Ext >::mapping (LeftMap const &left, RightMap const &right) noexcept
 Merge two sub-mappings whose span counts sum to NumSpans.
 
template<typename OtherExt >
UNI20_HOST_DEVICE constexpr uni20::StridedZipLayout< NumSpans >::mapping< Ext >::mapping (std::array< index_type, Ext::rank()> const &new_strides, typename StridedZipLayout< num_spans - 1 >::template mapping< OtherExt > const &other) noexcept
 Prepend one span’s strides before an existing mapping of N–1 spans.
 
template<typename OtherExt >
UNI20_HOST_DEVICE constexpr uni20::StridedZipLayout< NumSpans >::mapping< Ext >::mapping (typename StridedZipLayout< num_spans - 1 >::template mapping< OtherExt > const &other, std::array< index_type, Ext::rank()> const &new_strides) noexcept
 Append one span’s strides after an existing mapping of N–1 spans.
 
template<typename Extents , std::size_t R>
requires (Extents::rank() == R)
static_vector< extent_strides< 2 >, R > uni20::merge_strides_left (Extents const &ext, std::array< std::ptrdiff_t, R > const &Stride1, std::array< std::ptrdiff_t, R > const &Stride2)
 Build and merge stride metadata from two stride arrays favouring column-major (left) order.
 
template<std::size_t N, std::size_t R>
void uni20::merge_strides_left (static_vector< extent_strides< N >, R > &out)
 Merge adjacent stride descriptors in place using column-major (left) ordering.
 
template<typename Extents , std::size_t R>
requires (Extents::rank() == R)
static_vector< extent_strides< 2 >, R > uni20::merge_strides_right (Extents const &ext, std::array< std::ptrdiff_t, R > const &Stride1, std::array< std::ptrdiff_t, R > const &Stride2)
 Build and merge stride metadata from two stride arrays favouring row-major (right) order.
 
template<std::size_t N, std::size_t R>
void uni20::merge_strides_right (static_vector< extent_strides< N >, R > &out)
 Merge adjacent stride descriptors in place using row-major (right) ordering.
 
constexpr void uni20::extent_strides< N >::merge_with_inner (extent_strides inner) noexcept
 Merge an inner dimension into this one when merging is valid.
 
UNI20_HOST_DEVICE constexpr bool uni20::GeneralZipLayout< Layouts >::mapping< Extents >::operator!= (mapping const &o) const noexcept
 Compare two mappings for inequality.
 
template<typename... Idx>
UNI20_HOST_DEVICE constexpr offset_type uni20::StridedZipLayout< NumSpans >::mapping< Ext >::operator() (Idx... idxs) const noexcept
 Compute per-span linear offsets for a multi-index.
 
template<typename... Idx>
UNI20_HOST_DEVICE constexpr offset_type uni20::GeneralZipLayout< Layouts >::mapping< Extents >::operator() (Idx... idxs) const noexcept
 Compute the per-layout offsets for a given multi-index.
 
UNI20_HOST_DEVICE constexpr bool uni20::GeneralZipLayout< Layouts >::mapping< Extents >::operator== (mapping const &o) const noexcept
 Compare two mappings for equality.
 
UNI20_HOST_DEVICE constexpr std::size_t uni20::GeneralZipLayout< Layouts >::mapping< Extents >::required_span_size () const noexcept
 Return the maximum required span size among the child mappings.
 
UNI20_HOST_DEVICE constexpr index_type uni20::StridedZipLayout< NumSpans >::mapping< Ext >::stride (rank_type r) const noexcept
 Return the common stride in dimension r.
 
UNI20_HOST_DEVICE constexpr std::array< index_type, Ext::rank()> uni20::StridedZipLayout< NumSpans >::mapping< Ext >::strides () const noexcept
 Return the common strides for each dimension.
 
template<StridedMdspecLike S>
auto uni20::strides (S const &s)
 Retrieve the strides associated with a strided mdspec-like type.
 

Variables

template<class Accessor >
constexpr bool uni20::is_default_accessor_v = is_default_accessor<std::remove_cvref_t<Accessor>>::value
 True when an accessor is stdex::default_accessor<T>.
 
static constexpr std::size_t uni20::StridedZipLayout< NumSpans >::mapping< Ext >::num_spans = NumSpans
 Number of spans in this zip layout.
 

Detailed Description

Additional concepts, adaptors, and helpers that extend the reference mdspan implementation.

Typedef Documentation

◆ const_accessor_t

template<AccessorPolicy Acc>
using uni20::const_accessor_t = typedef decltype(const_accessor(std::declval<Acc>()))

Type alias that produces the const-qualified version of an accessor policy.

Template Parameters
AccAn accessor policy.

◆ span_offset_t

template<typename AP >
using uni20::span_offset_t = typedef typename span_offset_type<AP>::type

Convenience alias for accessor_offset_type<AP>::type.

Template Parameters
APThe accessor policy to inspect.

◆ type [1/2]

template<typename AP , typename = void>
using uni20::span_offset_type< AP, typename >::type = std::size_t

The resulting offset type (std::size_t by default).

◆ type [2/2]

template<typename AP >
using uni20::span_offset_type< AP, std::void_t< typename AP::offset_type > >::type = typename AP::offset_type

The resulting offset type defined by the accessor policy.

◆ zip_layout_t

template<typename... Spans>
using uni20::zip_layout_t = typedef typename zip_layout_selector<Spans...>::type

Alias to extract the chosen layout policy for the given spans.

Template Parameters
SpansMdspan types.

Function Documentation

◆ all_strides()

template<std::size_t NumSpans>
template<typename Ext >
UNI20_HOST_DEVICE std::array< std::array< index_type, Ext::rank()>, num_spans > const & uni20::StridedZipLayout< NumSpans >::mapping< Ext >::all_strides ( ) const
inlinenoexcept

Retrieve the 2-D array of all per-span strides.

Returns
An array [span][dim] of strides.

◆ can_merge_with_inner()

template<std::size_t N>
constexpr bool uni20::extent_strides< N >::can_merge_with_inner ( extent_strides< N >  inner) const
inlineconstexprnoexcept

Returns true if the current (outer) dimension and the given inner dimension can be merged.

An extent-one dimension is always mergeable because its stride is not observed by any logical index.

Parameters
innerThe inner dimension metadata to test.
Returns
True when the two dimensions are mergeable.

◆ const_access()

template<MdspanLike Span, class... Index>
requires detail::MdspanIndexPack<Span, Index...>
constexpr decltype(auto) uni20::const_access ( Span const &  span,
Index...  indices 
)
constexpr

Access one mdspan element through a read-only adaptation of its stored accessor.

This preserves the mapping and accessor state without constructing a second mdspan descriptor. Index eligibility and conversion match the multidimensional mdspan subscript operation.

Template Parameters
SpanThe mdspan-like descriptor type.
IndexOne index type per mdspan rank.
Parameters
spanDescriptor whose mapping, handle, and accessor are used.
indicesCoordinates for every mdspan axis.
Returns
The reference or calculated value produced by the read-only accessor.

◆ const_accessor() [1/2]

template<AccessorPolicy Acc>
requires (!std::is_const_v<typename Acc::element_type> && std::is_same_v<typename Acc::reference, typename Acc::element_type&>)
constexpr auto uni20::const_accessor ( Acc const &  acc)
constexpr

Wrap any accessor whose reference is T& into a const adaptor.

Template Parameters
AccA mutable accessor policy with reference equal to element_type&.
Parameters
accThe accessor to wrap.
Returns
A const-qualified accessor adaptor.

◆ const_accessor() [2/2]

template<typename T >
constexpr stdex::default_accessor< T const > uni20::const_accessor ( stdex::default_accessor< T > const &  accessor_policy)
constexpr

Wrap a default_accessor<T> into a const_default_accessor<T>.

Template Parameters
TElement type accessed by the policy.
Parameters
accessor_policyThe accessor policy to upgrade.
Returns
A default accessor for T const.

◆ extent_strides() [1/3]

template<std::size_t N>
template<typename Ext , typename Str >
requires std::is_integral_v<Ext> && std::is_integral_v<Str>
constexpr uni20::extent_strides< N >::extent_strides ( Ext  e,
std::array< Str, N >  s 
)
inlineconstexpr

Construct from an extent and an array of strides.

Template Parameters
ExtIntegral type for the extent.
StrIntegral type for the stride values.
Parameters
eThe extent value.
sThe strides associated with the dimension.

◆ extent_strides() [2/3]

template<std::size_t N>
template<typename Ext >
requires std::is_integral_v<Ext>
constexpr uni20::extent_strides< N >::extent_strides ( Ext  e,
std::initializer_list< std::ptrdiff_t >  s 
)
inlineconstexpr

Construct from an extent and initializer-list strides.

Template Parameters
ExtIntegral type for the extent.
Parameters
eThe extent value.
sThe strides associated with the dimension.

◆ extent_strides() [3/3]

template<std::size_t N>
template<typename Ext , typename... Strides>
requires (std::is_integral_v<Ext> && sizeof...(Strides) == N)
constexpr uni20::extent_strides< N >::extent_strides ( Ext  e,
Strides...  s 
)
inlineconstexpr

Construct from an extent and a parameter pack of stride values.

Template Parameters
ExtIntegral type for the extent.
StridesIntegral stride arguments matching N.
Parameters
eThe extent value.
sThe stride values.

◆ extents() [1/2]

template<std::size_t NumSpans>
template<typename Ext >
UNI20_HOST_DEVICE constexpr extents_type const & uni20::StridedZipLayout< NumSpans >::mapping< Ext >::extents ( ) const
inlineconstexprnoexcept

Return the extents of the layout.

Returns
The common extents of all child layouts.

◆ extents() [2/2]

template<typename... Layouts>
template<typename Extents >
UNI20_HOST_DEVICE constexpr extents_type const & uni20::GeneralZipLayout< Layouts >::mapping< Extents >::extents ( ) const
inlineconstexprnoexcept

Access the common extents.

Returns
Shared extents across all child mappings.

◆ extract_strides()

template<StridedMdspanLike AType, StridedMdspanLike BType, StridedMdspanLike CType, std::size_t N>
auto uni20::extract_strides ( AType const &  A,
BType const &  B,
std::array< std::pair< std::size_t, std::size_t >, N > const &  contractDims,
CType const &  C 
)

Extract merged stride groups for a tensor contraction.

Template Parameters
ATypeStrided mdspan describing the A operand.
BTypeStrided mdspan describing the B operand.
CTypeStrided mdspan describing the C operand.
NNumber of contraction dimensions.
Parameters
AThe left operand tensor.
BThe right operand tensor.
contractDimsPairs of contraction indices mapping A to B dimensions.
CThe output tensor.
Returns
Tuple of stride descriptors for the M, N, and K groupings.

◆ is_always_exhaustive() [1/2]

template<std::size_t NumSpans>
template<typename Ext >
static UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_always_exhaustive ( )
inlinestaticconstexprnoexcept

Never exhaustive: no single contiguous backing buffer.

◆ is_always_exhaustive() [2/2]

template<typename... Layouts>
template<typename Extents >
static UNI20_HOST_DEVICE constexpr bool uni20::GeneralZipLayout< Layouts >::mapping< Extents >::is_always_exhaustive ( )
inlinestaticconstexprnoexcept

Never exhaustive: no single contiguous backing buffer.

◆ is_always_strided() [1/2]

template<std::size_t NumSpans>
template<typename Ext >
static UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_always_strided ( )
inlinestaticconstexprnoexcept

Statically unknown if strided: may differ per dimension.

◆ is_always_strided() [2/2]

template<typename... Layouts>
template<typename Extents >
static UNI20_HOST_DEVICE constexpr bool uni20::GeneralZipLayout< Layouts >::mapping< Extents >::is_always_strided ( )
inlinestaticconstexprnoexcept

Not strided.

◆ is_always_unique() [1/2]

template<std::size_t NumSpans>
template<typename Ext >
static UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_always_unique ( )
inlinestaticconstexprnoexcept

Always unique for uni20 tensors.

◆ is_always_unique() [2/2]

template<typename... Layouts>
template<typename Extents >
static UNI20_HOST_DEVICE constexpr bool uni20::GeneralZipLayout< Layouts >::mapping< Extents >::is_always_unique ( )
inlinestaticconstexprnoexcept

Always unique for uni20 tensors.

◆ is_exhaustive()

template<std::size_t NumSpans>
template<typename Ext >
UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_exhaustive ( ) const
inlineconstexprnoexcept

Never exhaustive at runtime.

◆ is_strided()

template<std::size_t NumSpans>
template<typename Ext >
UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_strided ( ) const
inlineconstexprnoexcept

True if every dimension uses the same stride across all spans.

Returns
True when each span shares identical strides per dimension.

◆ is_unique()

template<std::size_t NumSpans>
template<typename Ext >
UNI20_HOST_DEVICE constexpr bool uni20::StridedZipLayout< NumSpans >::mapping< Ext >::is_unique ( ) const
inlineconstexprnoexcept

Always unique at runtime.

◆ mapping() [1/6]

template<typename... Layouts>
template<typename Extents >
UNI20_HOST_DEVICE constexpr uni20::GeneralZipLayout< Layouts >::mapping< Extents >::mapping ( Extents const &  ext,
typename Layouts::template mapping< Extents > const &...  m 
)
inlineexplicitconstexprnoexcept

Construct child mappings.

Parameters
extCommon extents shared by every mapping.
mChild mappings stored within the layout.

◆ mapping() [2/6]

template<std::size_t NumSpans>
template<typename Ext >
template<typename... Mappings>
UNI20_HOST_DEVICE constexpr uni20::StridedZipLayout< NumSpans >::mapping< Ext >::mapping ( extents_type const &  exts,
Mappings...  maps 
)
inlineconstexprnoexcept

Construct from extents and existing child mappings.

Parameters
extsShared extents of all spans.
mapsExisting mappings whose strides are copied into this layout.

◆ mapping() [3/6]

template<std::size_t NumSpans>
template<typename Ext >
UNI20_HOST_DEVICE constexpr uni20::StridedZipLayout< NumSpans >::mapping< Ext >::mapping ( extents_type const &  exts,
std::array< std::array< index_type, Ext::rank()>, NumSpans > const &  strides_pack 
)
inlineconstexprnoexcept

Construct from shared extents and per-span raw strides.

Parameters
extsCommon extents of the view.
strides_packstrides_pack[s][d] is the stride of span s in dimension d.

◆ mapping() [4/6]

template<std::size_t NumSpans>
template<typename Ext >
template<typename LeftMap , typename RightMap >
requires (LeftMap::num_spans + RightMap::num_spans == num_spans)
UNI20_HOST_DEVICE constexpr uni20::StridedZipLayout< NumSpans >::mapping< Ext >::mapping ( LeftMap const &  left,
RightMap const &  right 
)
inlineconstexprnoexcept

Merge two sub-mappings whose span counts sum to NumSpans.

Template Parameters
LeftMapMapping of the first n spans.
RightMapMapping of the remaining spans.

◆ mapping() [5/6]

template<std::size_t NumSpans>
template<typename Ext >
template<typename OtherExt >
UNI20_HOST_DEVICE constexpr uni20::StridedZipLayout< NumSpans >::mapping< Ext >::mapping ( std::array< index_type, Ext::rank()> const &  new_strides,
typename StridedZipLayout< num_spans - 1 >::template mapping< OtherExt > const &  other 
)
inlineconstexprnoexcept

Prepend one span’s strides before an existing mapping of N–1 spans.

Template Parameters
OtherExtExtents type of the smaller mapping.

◆ mapping() [6/6]

template<std::size_t NumSpans>
template<typename Ext >
template<typename OtherExt >
UNI20_HOST_DEVICE constexpr uni20::StridedZipLayout< NumSpans >::mapping< Ext >::mapping ( typename StridedZipLayout< num_spans - 1 >::template mapping< OtherExt > const &  other,
std::array< index_type, Ext::rank()> const &  new_strides 
)
inlineconstexprnoexcept

Append one span’s strides after an existing mapping of N–1 spans.

Template Parameters
OtherExtExtents type of the smaller mapping.

◆ merge_strides_left() [1/2]

template<typename Extents , std::size_t R>
requires (Extents::rank() == R)
static_vector< extent_strides< 2 >, R > uni20::merge_strides_left ( Extents const &  ext,
std::array< std::ptrdiff_t, R > const &  Stride1,
std::array< std::ptrdiff_t, R > const &  Stride2 
)
inline

Build and merge stride metadata from two stride arrays favouring column-major (left) order.

Template Parameters
ExtentsExtents type supplying extents via operator[].
RTensor rank captured by the stride arrays.
Parameters
extThe extents of the tensor.
Stride1The strides for the first operand.
Stride2The strides for the second operand.
Returns
A compacted sequence of stride descriptors sorted by increasing primary stride.

◆ merge_strides_left() [2/2]

template<std::size_t N, std::size_t R>
void uni20::merge_strides_left ( static_vector< extent_strides< N >, R > &  out)

Merge adjacent stride descriptors in place using column-major (left) ordering.

Template Parameters
NNumber of stride values per descriptor.
RCapacity of the static vector.
Parameters
outThe sequence of stride descriptors to compact.

◆ merge_strides_right() [1/2]

template<typename Extents , std::size_t R>
requires (Extents::rank() == R)
static_vector< extent_strides< 2 >, R > uni20::merge_strides_right ( Extents const &  ext,
std::array< std::ptrdiff_t, R > const &  Stride1,
std::array< std::ptrdiff_t, R > const &  Stride2 
)
inline

Build and merge stride metadata from two stride arrays favouring row-major (right) order.

Template Parameters
ExtentsExtents type supplying extents via operator[].
RTensor rank captured by the stride arrays.
Parameters
extThe extents of the tensor.
Stride1The strides for the first operand.
Stride2The strides for the second operand.
Returns
A compacted sequence of stride descriptors sorted by decreasing primary stride.

◆ merge_strides_right() [2/2]

template<std::size_t N, std::size_t R>
void uni20::merge_strides_right ( static_vector< extent_strides< N >, R > &  out)

Merge adjacent stride descriptors in place using row-major (right) ordering.

Template Parameters
NNumber of stride values per descriptor.
RCapacity of the static vector.
Parameters
outThe sequence of stride descriptors to compact.

◆ merge_with_inner()

template<std::size_t N>
constexpr void uni20::extent_strides< N >::merge_with_inner ( extent_strides< N >  inner)
inlineconstexprnoexcept

Merge an inner dimension into this one when merging is valid.

The merged descriptor retains the non-singleton dimension's strides. Two singleton dimensions use canonical unit strides.

Parameters
innerThe inner dimension metadata to merge.

◆ operator!=()

template<typename... Layouts>
template<typename Extents >
UNI20_HOST_DEVICE constexpr bool uni20::GeneralZipLayout< Layouts >::mapping< Extents >::operator!= ( mapping< Extents > const &  o) const
inlineconstexprnoexcept

Compare two mappings for inequality.

Parameters
oMapping to compare against.
Returns
True when either extents or child mappings differ.

◆ operator()() [1/2]

template<std::size_t NumSpans>
template<typename Ext >
template<typename... Idx>
UNI20_HOST_DEVICE constexpr offset_type uni20::StridedZipLayout< NumSpans >::mapping< Ext >::operator() ( Idx...  idxs) const
inlineconstexprnoexcept

Compute per-span linear offsets for a multi-index.

Template Parameters
IdxTypes of each index argument.
Parameters
idxsIndices for each dimension.
Returns
Array of per-span offsets.

◆ operator()() [2/2]

template<typename... Layouts>
template<typename Extents >
template<typename... Idx>
UNI20_HOST_DEVICE constexpr offset_type uni20::GeneralZipLayout< Layouts >::mapping< Extents >::operator() ( Idx...  idxs) const
inlineconstexprnoexcept

Compute the per-layout offsets for a given multi-index.

Template Parameters
IdxTypes of each index argument.
Parameters
idxsIndices for each dimension.
Returns
Tuple containing offsets for every child mapping.

◆ operator==()

template<typename... Layouts>
template<typename Extents >
UNI20_HOST_DEVICE constexpr bool uni20::GeneralZipLayout< Layouts >::mapping< Extents >::operator== ( mapping< Extents > const &  o) const
inlineconstexprnoexcept

Compare two mappings for equality.

Parameters
oMapping to compare against.
Returns
True when both extents and child mappings match.

◆ required_span_size()

template<typename... Layouts>
template<typename Extents >
UNI20_HOST_DEVICE constexpr std::size_t uni20::GeneralZipLayout< Layouts >::mapping< Extents >::required_span_size ( ) const
inlineconstexprnoexcept

Return the maximum required span size among the child mappings.

Returns
Maximum number of elements any child mapping may touch.

◆ stride()

template<std::size_t NumSpans>
template<typename Ext >
UNI20_HOST_DEVICE constexpr index_type uni20::StridedZipLayout< NumSpans >::mapping< Ext >::stride ( rank_type  r) const
inlineconstexprnoexcept

Return the common stride in dimension r.

Precondition
All spans share the same stride in dimension r.
Parameters
rDimension index, 0 ≤ r < rank().
Returns
The stride (step) in the flattened data for dim r.

◆ strides() [1/2]

template<std::size_t NumSpans>
template<typename Ext >
UNI20_HOST_DEVICE constexpr std::array< index_type, Ext::rank()> uni20::StridedZipLayout< NumSpans >::mapping< Ext >::strides ( ) const
inlineconstexprnoexcept

Return the common strides for each dimension.

Returns
Array of strides indexed by dimension.

◆ strides() [2/2]

template<StridedMdspecLike S>
auto uni20::strides ( S const &  s)

Retrieve the strides associated with a strided mdspec-like type.

Template Parameters
SThe strided mdspec-like type.
Parameters
sThe multidimensional descriptor whose strides will be returned.
Returns
A std::array containing the strides for each rank.

Variable Documentation

◆ is_default_accessor_v

template<class Accessor >
constexpr bool uni20::is_default_accessor_v = is_default_accessor<std::remove_cvref_t<Accessor>>::value
inlineconstexpr

True when an accessor is stdex::default_accessor<T>.

Template Parameters
AccessorCandidate accessor policy.

◆ num_spans

template<std::size_t NumSpans>
template<typename Ext >
constexpr std::size_t uni20::StridedZipLayout< NumSpans >::mapping< Ext >::num_spans = NumSpans
staticconstexpr

Number of spans in this zip layout.