Iros
 
Loading...
Searching...
No Matches
layout_left.h
Go to the documentation of this file.
1#pragma once
2
4#include "di/meta/algorithm.h"
7
8namespace di::vocab {
9template<typename Extents>
11public:
16
17 Mapping() = default;
18 Mapping(Mapping const&) = default;
19 Mapping(Mapping&&) = default;
20
21 constexpr Mapping(ExtentsType const& extents) : m_extents(extents) {}
22
23 template<concepts::Extents OtherExtents>
28
29 template<concepts::Extents OtherExtents>
33 : m_extents(other.extents()) {}
34
35 template<concepts::Extents OtherExtents>
37 constexpr explicit(ExtentsType::rank() > 0) Mapping(LayoutStride::Mapping<OtherExtents> const& other)
38 : m_extents(other.extents()) {}
39
40 auto operator=(Mapping const&) -> Mapping& = default;
41
42 constexpr auto extents() const -> ExtentsType const& { return m_extents; }
43
44 constexpr auto required_span_size() const -> SizeType { return extents().fwd_prod_of_extents(extents().rank()); }
45
46 template<typename... Indices>
47 requires(sizeof...(Indices) == ExtentsType::rank() && (concepts::ConvertibleTo<Indices, SizeType> && ...))
48 constexpr auto operator()(Indices... indices) const -> SizeType {
49 return function::unpack<meta::MakeIndexSequence<sizeof...(Indices)>>([&]<size_t... i>(meta::ListV<i...>) {
50 return ((static_cast<SizeType>(indices) * stride(i)) + ... + 0);
51 });
52 }
53
54 constexpr static auto is_always_unique() -> bool { return true; }
55 constexpr static auto is_always_exhaustive() -> bool { return true; }
56 constexpr static auto is_always_strided() -> bool { return true; }
57
58 constexpr static auto is_unique() -> bool { return true; }
59 constexpr static auto is_exhaustive() -> bool { return true; }
60 constexpr static auto is_strided() -> bool { return true; }
61
62 constexpr auto stride(RankType i) const -> SizeType { return extents().fwd_prod_of_extents(i); }
63
64private:
65 template<typename OtherExtents>
66 requires(Extents::rank() == OtherExtents::rank())
67 constexpr friend auto operator==(Mapping const& a, Mapping<OtherExtents> const& b) -> bool {
68 return a.extents() == b.extents();
69 }
70
71 [[no_unique_address]] ExtentsType m_extents;
72};
73}
Definition extents_forward_declaration.h:11
static constexpr auto rank() -> size_t
Definition extents.h:55
size_t RankType
Definition extents.h:53
T SizeType
Definition extents.h:52
Definition layout_left.h:10
LayoutLeft LayoutType
Definition layout_left.h:15
typename ExtentsType::RankType RankType
Definition layout_left.h:14
constexpr Mapping(ExtentsType const &extents)
Definition layout_left.h:21
constexpr auto required_span_size() const -> SizeType
Definition layout_left.h:44
static constexpr auto is_exhaustive() -> bool
Definition layout_left.h:59
static constexpr auto is_always_exhaustive() -> bool
Definition layout_left.h:55
Extents ExtentsType
Definition layout_left.h:12
typename ExtentsType::SizeType SizeType
Definition layout_left.h:13
constexpr auto extents() const -> ExtentsType const &
Definition layout_left.h:42
auto operator=(Mapping const &) -> Mapping &=default
static constexpr auto is_always_strided() -> bool
Definition layout_left.h:56
static constexpr auto is_unique() -> bool
Definition layout_left.h:58
static constexpr auto is_strided() -> bool
Definition layout_left.h:60
constexpr auto stride(RankType i) const -> SizeType
Definition layout_left.h:62
static constexpr auto is_always_unique() -> bool
Definition layout_left.h:54
Mapping(Mapping const &)=default
Mapping(Mapping &&)=default
Definition layout_right.h:10
Definition layout_stride.h:31
Definition operations.h:11
Definition operations.h:99
constexpr usize stride
Definition gfx_test.cpp:23
constexpr auto unpack
Definition unpack.h:24
MakeIntegerSequence< usize, count > MakeIndexSequence
Definition algorithm.h:285
Definition lazy.h:165
Definition core.h:8
Definition extents_forward_declaration.h:13