The extents of a Seq's axes: a plain Nat for a single axis, an aggregate of them for several. More...
#include <mim/tuple.h>
Public Member Functions | |
| constexpr | Shape () noexcept=default |
| constexpr | Shape (const Def *def) noexcept |
| Shape (World &, Defs shape) | |
Getters | |
| constexpr const Def * | operator* () const noexcept |
| constexpr const Def * | operator-> () const noexcept |
| constexpr | operator bool () const noexcept |
Transform | |
Each of these needs Shape::rank and yields a null Shape without it. | |
| Shape | slice (nat_t begin, nat_t end) const |
| The axes [begin, end). | |
| Shape | take (nat_t n) const |
The leading n axes. | |
| Shape | drop (nat_t n) const |
All but the leading n axes. | |
| Shape | operator+ (Shape) const |
| Concatenation - what fuses «a; «b; T»» into «a, b; T». | |
| Shape | zonk () const |
| Wraps Def::zonk();. | |
| Shape | filter (auto keep) const |
This Shape with only the axes keep accepts; *this, if it accepts all of them or the rank is dynamic. | |
| Shape | fold () const |
| Drops every literal size-1 axis, mirroring «1; T» ≡ T; all of them folded away leaves rank 0. | |
| Shape | fold (Shape shape) const |
As above but driven by shape: drops the axes it has as literal 1, whatever this one's own extents are - a broadcast reads a size-1 input axis at the output's loop index. | |
Static Public Member Functions | |
Type Checking | |
| static bool | isa_extents (const Def *) |
Is type Nat - or an aggregate of Nats, i.e. a shape? | |
| static bool | isa_indices (const Def *) |
Is type Idx - or an aggregate of Idxs, i.e. a fused index? | |
Axes | |
| bool | is_dim () const |
| Is this a single axis - a Nat/Idx rather than an aggregate of them? | |
| bool | is_fused () const |
| Does this span several axes? Also true for a dynamic rank. | |
| std::optional< nat_t > | rank () const |
| Number of axes; std::nullopt if not statically known. | |
| const Def * | operator[] (nat_t i) const |
The i th axis. | |
| const Def * | front () const |
| The outermost axis - the Def::arity of the Seq this shape describes; null for a null Shape. | |
| static std::optional< nat_t > | extent (const Def *axis) |
The extent of axis: the axis itself for a shape, its Idx size for an index. | |
The extents of a Seq's axes: a plain Nat for a single axis, an aggregate of them for several.
A multi-dimensional index into a Seq has the very same structure - one component per axis, Idx instead of Nat - so it uses this view as well.
|
constexprdefaultnoexcept |
|
inlineconstexprnoexcept |
The extent of axis: the axis itself for a shape, its Idx size for an index.
Definition at line 33 of file tuple.cpp.
References mim::Idx::isa(), mim::Lit::isa(), and mim::Def::unfold_type().
Referenced by fold(), fold(), and mim::World::seq().
|
inline |
| Shape mim::Shape::fold | ( | ) | const |
| const Def * mim::Shape::front | ( | ) | const |
The outermost axis - the Def::arity of the Seq this shape describes; null for a null Shape.
Definition at line 25 of file tuple.cpp.
References is_dim(), mim::Def::proj(), and rank().
| bool mim::Shape::is_dim | ( | ) | const |
Is this a single axis - a Nat/Idx rather than an aggregate of them?
Definition at line 16 of file tuple.cpp.
References mim::Idx::isa().
Referenced by fold(), front(), and is_fused().
|
inline |
Does this span several axes? Also true for a dynamic rank.
Definition at line 211 of file tuple.h.
References is_dim().
Referenced by mim::Seq::elem(), mim::plug::ll::is_simd(), and mim::Rewriter::rewrite_mut_Seq().
|
static |
Is type Nat - or an aggregate of Nats, i.e. a shape?
Definition at line 46 of file tuple.cpp.
References mim::isa_axes().
Referenced by mim::World::seq().
|
static |
Is type Idx - or an aggregate of Idxs, i.e. a fused index?
Definition at line 50 of file tuple.cpp.
References mim::Idx::isa(), and mim::isa_axes().
|
inlineexplicitconstexprnoexcept |
|
inlineconstexprnoexcept |
Concatenation - what fuses «a; «b; T»» into «a, b; T».
Definition at line 66 of file tuple.cpp.
References mim::Tuple::cat(), and Shape().
|
inlineconstexprnoexcept |
The i th axis.
Definition at line 215 of file tuple.h.
References rank().
| std::optional< nat_t > mim::Shape::rank | ( | ) | const |
Number of axes; std::nullopt if not statically known.
Definition at line 23 of file tuple.cpp.
References mim::Lit::isa().
Referenced by drop(), filter(), fold(), front(), operator[](), and slice().
|
inline |