MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
lower_matrix_mediumlevel.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/def.h>
4#include <mim/phase.h>
5
7
8/// In this step, we lower `map_reduce` operations into affine for loops making the iteration scheme explicit.
9/// Pseudo-code:
10/// ```
11/// out_matrix = init
12/// for output_indices:
13/// acc = zero
14/// for input_indices:
15/// element_[0..m] = read(matrix[0..m], indices)
16/// acc = f (acc, elements)
17/// insert (out_matrix, output_indices, acc)
18/// return out_matrix
19/// ```
20///
21/// Detailed pseudo-code:
22/// * out indices = (0,1,2, ..., n)
23/// * bounds in S
24/// * we assume that certain paramters are constant and statically known
25/// to avoid inline-metaprogramming like multiiter
26/// e.g. the number of matrizes, the dimensions, the indices
27/// ```
28/// // iterate over out indices
29/// output = init_matrix (n,S,T)
30/// for i_0 in [0, S#0)
31/// ...
32/// for i_{n-1} in [0, S#(n-1))
33/// s = zero
34/// // iterate over non-out indices
35/// for j in [0, SI#(...)]:
36/// // indices depend on the specified access
37/// // input#k#0
38/// e_0 = read (input#0#1, (i_1, i_0))
39/// ...
40/// e_(m-1) = read (input#(m-1)#1, (i_2, j))
41///
42/// s = add(s, mul (e_0, ..., e_(m-1)) )
43/// write (output, (i_0, ..., i_{n-1}), s)
44/// ```
46public:
49
50 const Def* rewrite_imm_App(const App*) final;
51};
52
53} // namespace mim::plug::matrix::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
u64 flags_t
Definition types.h:39