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`, `generate`, `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:
15 using RWPhase::RWPhase;
16
17private:
18 const Def* rewrite_imm_App(const App*) final;
19
20 const Def* lower_broadcast(const App*);
21 const Def* lower_map_reduce(const App*);
22 const Def* lower_generate(const App*);
23 const Def* lower_pad(const App*);
24 const Def* lower_concat(const App*);
25 const Def* lower_gather(const App*);
26 const Def* lower_scatter(const App*);
27
28 /// Builds `ro` output loops over `So` and writes the element returned by `compute(out_iters, inputs)` at the
29 /// identity output coordinates. `out_iters` are the raw i64 loop counters. Used by the non-affine pointwise
30 /// lowerings (`pad`, `concat`) whose element value is chosen conditionally on the output coordinate.
31 const Def* build_pointwise(const Def* inputs,
32 const Def* type,
33 const Def* So,
34 u64 ro,
35 std::function<const Def*(Defs, const Def*)> compute);
36
37 const Def* rec_broadcast(const Def* s_in, const Def* s_out, const Def* input, u64 r, u64 i);
38};
39
40} // namespace mim::plug::tensor::phase
Base class for all Defs.
Definition def.h:289
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:334
Lowers the low-level tensor axioms (map_reduce, generate, pad, concat, broadcast) directly to their u...
const Def * rewrite_imm_App(const App *) final
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:334
fe::View< const Def * > Defs
Definition def.h:96
uint64_t u64
Definition types.h:27