Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
uni20::diagonal_accessor< ElementType, Extents > Class Template Reference

Mdspan accessor over a compressed rank-N generalized diagonal. More...

#include <diagonal_accessor.hpp>

Classes

struct  component_index_result
 Decoded component coordinate for one logical mapping offset. More...
 

Public Types

using data_handle_type = diagonal_data_handle< element_type >
 
using element_type = ElementType
 
using extents_type = Extents
 
using index_type = typename extents_type::index_type
 
using offset_policy = diagonal_accessor
 
using offset_type = std::size_t
 
using reference = std::conditional_t< std::is_const_v< element_type >, value_type, diagonal_reference< value_type > >
 
using value_type = std::remove_cv_t< ElementType >
 

Public Member Functions

UNI20_HOST_DEVICE constexpr reference access (data_handle_type handle, offset_type offset) const
 Read or write the logical element represented by an encoded offset.
 
UNI20_HOST_DEVICE constexpr auto component_index (data_handle_type handle, offset_type offset=0) const noexcept -> component_index_result
 Decode whether a logical offset addresses a stored component and which one.
 
UNI20_HOST_DEVICE constexpr auto component_stride () const noexcept -> index_type
 Return the physical offset between consecutive diagonal components.
 
UNI20_HOST_DEVICE constexpr diagonal_accessor ()=default
 
UNI20_HOST_DEVICE constexpr diagonal_accessor (extents_type extents, index_type component_stride=1)
 Construct an accessor for one logical index space and component stride.
 
UNI20_HOST_DEVICE constexpr auto extents () const noexcept -> extents_type const &
 Return the extents used to decode logical offsets.
 
UNI20_HOST_DEVICE constexpr data_handle_type offset (data_handle_type handle, offset_type offset) const noexcept
 Advance a logical handle without changing its original index space.
 

Detailed Description

template<class ElementType, class Extents>
class uni20::diagonal_accessor< ElementType, Extents >

Mdspan accessor over a compressed rank-N generalized diagonal.

The associated mapping encodes logical tensor indices as offsets. This accessor decodes those offsets and addresses the compressed value only when every logical index is equal. Rectangular tensors store min(extents...) values.

Template Parameters
ElementTypePresented element type, possibly const-qualified.
ExtentsLogical tensor extents used to decode mapping offsets.

Member Typedef Documentation

◆ data_handle_type

template<class ElementType , class Extents >
using uni20::diagonal_accessor< ElementType, Extents >::data_handle_type = diagonal_data_handle<element_type>

◆ element_type

template<class ElementType , class Extents >
using uni20::diagonal_accessor< ElementType, Extents >::element_type = ElementType

◆ extents_type

template<class ElementType , class Extents >
using uni20::diagonal_accessor< ElementType, Extents >::extents_type = Extents

◆ index_type

template<class ElementType , class Extents >
using uni20::diagonal_accessor< ElementType, Extents >::index_type = typename extents_type::index_type

◆ offset_policy

template<class ElementType , class Extents >
using uni20::diagonal_accessor< ElementType, Extents >::offset_policy = diagonal_accessor

◆ offset_type

template<class ElementType , class Extents >
using uni20::diagonal_accessor< ElementType, Extents >::offset_type = std::size_t

◆ reference

template<class ElementType , class Extents >
using uni20::diagonal_accessor< ElementType, Extents >::reference = std::conditional_t<std::is_const_v<element_type>, value_type, diagonal_reference<value_type> >

◆ value_type

template<class ElementType , class Extents >
using uni20::diagonal_accessor< ElementType, Extents >::value_type = std::remove_cv_t<ElementType>

Constructor & Destructor Documentation

◆ diagonal_accessor() [1/2]

template<class ElementType , class Extents >
UNI20_HOST_DEVICE constexpr uni20::diagonal_accessor< ElementType, Extents >::diagonal_accessor ( )
constexprdefault

◆ diagonal_accessor() [2/2]

template<class ElementType , class Extents >
UNI20_HOST_DEVICE constexpr uni20::diagonal_accessor< ElementType, Extents >::diagonal_accessor ( extents_type  extents,
index_type  component_stride = 1 
)
inlineexplicitconstexpr

Construct an accessor for one logical index space and component stride.

Parameters
extentsFull logical tensor extents.
component_strideOffset between consecutive stored diagonal components.

Member Function Documentation

◆ access()

template<class ElementType , class Extents >
UNI20_HOST_DEVICE constexpr reference uni20::diagonal_accessor< ElementType, Extents >::access ( data_handle_type  handle,
offset_type  offset 
) const
inlineconstexpr

Read or write the logical element represented by an encoded offset.

◆ component_index()

template<class ElementType , class Extents >
UNI20_HOST_DEVICE constexpr auto uni20::diagonal_accessor< ElementType, Extents >::component_index ( data_handle_type  handle,
offset_type  offset = 0 
) const -> component_index_result
inlineconstexprnoexcept

Decode whether a logical offset addresses a stored component and which one.

◆ component_stride()

template<class ElementType , class Extents >
UNI20_HOST_DEVICE constexpr auto uni20::diagonal_accessor< ElementType, Extents >::component_stride ( ) const -> index_type
inlineconstexprnoexcept

Return the physical offset between consecutive diagonal components.

◆ extents()

template<class ElementType , class Extents >
UNI20_HOST_DEVICE constexpr auto uni20::diagonal_accessor< ElementType, Extents >::extents ( ) const -> extents_type const&
inlineconstexprnoexcept

Return the extents used to decode logical offsets.

◆ offset()

template<class ElementType , class Extents >
UNI20_HOST_DEVICE constexpr data_handle_type uni20::diagonal_accessor< ElementType, Extents >::offset ( data_handle_type  handle,
offset_type  offset 
) const
inlineconstexprnoexcept

Advance a logical handle without changing its original index space.


The documentation for this class was generated from the following file: