MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
fuse.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/phase.h>
4
6
7class Fuse : public RWPhase {
8public:
10
11private:
12 void start() override;
13 const Def* rewrite_imm_App(const App*) final;
14
15 const Def* fuse_map_reduce(const App*);
16 const Def* fuse_epilogue(const App* callee, const Def* arg);
17 const Def* fuse_read_through(const App* callee, const Def* arg);
18 bool sole_consumer(const Def*) const;
19
20 /// Old-world consumer count per `map_reduce_post` app (attributed through tuple wrappers), for
21 /// the epilogue direction's single-consumer guard.
22 DefMap<u64> mr_consumers_;
23 /// New-world defs whose consumers were multiplied by bypassing a shared (or uncounted) read;
24 /// the old-world count cannot see this, so `sole_consumer` rejects them.
25 DefSet shared_;
26 /// Rewritten/fused `map_reduce_post` app → the old-world app it replaces, to look up the
27 /// consumer count of new-world fusion candidates.
28 DefMap<const Def*> new2old_;
29};
30
31} // 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
void start() override
Actual entry.
Definition fuse.cpp:600
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:334
const Def * rewrite_imm_App(const App *) final
Definition fuse.cpp:606
GIDMap< const Def *, To > DefMap
Definition def.h:93
GIDSet< const Def * > DefSet
Definition def.h:94