MimIR
0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
autodiff_zero_cleanup.cpp
Go to the documentation of this file.
1
#include "
mim/plug/autodiff/pass/autodiff_zero_cleanup.h
"
2
3
#include <iostream>
4
5
#include <
mim/lam.h
>
6
7
#include "
mim/plug/affine/affine.h
"
8
#include "
mim/plug/autodiff/autodiff.h
"
9
#include "
mim/plug/core/core.h
"
10
#include "
mim/plug/mem/mem.h
"
11
12
namespace
mim::plug::autodiff
{
13
14
Ref
AutoDiffZeroCleanup::rewrite
(
Ref
def) {
15
// Ideally this code segment is never reached.
16
// (all zeros are resolved before)
17
if
(
auto
zero_app =
match<zero>
(def); zero_app) {
18
// callee = zero
19
// arg = type T
20
auto
T = zero_app->arg();
21
world
().DLOG(
"found a remaining autodiff::zero of {}"
, T);
22
// generate ⊥:T
23
auto
dummy =
world
().
bot
(T);
24
return
dummy;
25
}
26
27
return
def;
28
}
29
30
}
// namespace mim::plug::autodiff
affine.h
autodiff.h
autodiff_zero_cleanup.h
mim::Pass::world
World & world()
Definition
pass.h:296
mim::Ref
Helper class to retrieve Infer::arg if present.
Definition
def.h:86
mim::World::bot
Ref bot(Ref type)
Definition
world.h:435
mim::plug::autodiff::AutoDiffZeroCleanup::rewrite
Ref rewrite(Ref) override
Definition
autodiff_zero_cleanup.cpp:14
core.h
lam.h
mem.h
mim::plug::autodiff
The automatic differentiation Plugin
Definition
autodiff.h:6
mim::match
auto match(Ref def)
Definition
axiom.h:112
src
mim
plug
autodiff
pass
autodiff_zero_cleanup.cpp
Generated by
1.12.0