MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
lower_map_reduce.h
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4
5#include <mim/phase.h>
6
8
9/// Lowers the low-level tensor axioms (`map_reduce`, `pad`, `concat`, `broadcast`)
10/// directly to their underlying primitives (loops, `extract`, `insert`, `pack`, …).
11/// High-level axioms (`transpose`, `conv`, `broadcast_in_dim`, …) are expected to have been desugared to
12/// these low-level axioms by an earlier `Lower` phase.
13class LowerMapReduce : public RWPhase {
14public:
17
18private:
19 const Def* rewrite_imm_App(const App*) final;
20
21 const Def* lower_broadcast(const App*);
22 const Def* lower_map_reduce(const App*);
23 const Def* lower_pad(const App*);
24 const Def* lower_concat(const App*);
25
26 /// Builds `ro` output loops over `So` and writes the element returned by `compute(out_iters, inputs)` at the
27 /// identity output coordinates. `out_iters` are the raw i64 loop counters. Used by the non-affine pointwise
28 /// lowerings (`pad`, `concat`) whose element value is chosen conditionally on the output coordinate.
29 const Def* build_pointwise(const Def* inputs,
30 const Def* type,
31 const Def* So,
32 u64 ro,
33 std::function<const Def*(const DefVec&, const Def*)> compute);
34
35 const Def* rec_broadcast(const Def* s_in, const Def* s_out, const Def* input, u64 r, u64 i);
36};
37
38} // namespace mim::plug::tensor::phase
Base class for all Defs.
Definition def.h:261
flags_t annex() const
Definition phase.h:81
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:316
World & world()=delete
Hides both and forbids direct access.
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:36
const Def * rewrite_imm_App(const App *) final
LowerMapReduce(World &world, flags_t annex)
Vector< const Def * > DefVec
Definition def.h:79
u64 flags_t
Definition types.h:39
uint64_t u64
Definition types.h:27