Thorin
1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
autodiff_zero_cleanup.cpp
Go to the documentation of this file.
1
#include "
thorin/plug/autodiff/pass/autodiff_zero_cleanup.h
"
2
3
#include <iostream>
4
5
#include <
thorin/lam.h
>
6
7
#include "
thorin/plug/affine/affine.h
"
8
#include "
thorin/plug/autodiff/autodiff.h
"
9
#include "
thorin/plug/core/core.h
"
10
#include "
thorin/plug/mem/mem.h
"
11
12
namespace
thorin::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 thorin::plug::autodiff
affine.h
autodiff.h
autodiff_zero_cleanup.h
thorin::Pass::world
World & world()
Definition
pass.h:296
thorin::Ref
Helper class to retrieve Infer::arg if present.
Definition
def.h:87
thorin::World::bot
Ref bot(Ref type)
Definition
world.h:414
thorin::plug::autodiff::AutoDiffZeroCleanup::rewrite
Ref rewrite(Ref) override
Definition
autodiff_zero_cleanup.cpp:14
core.h
lam.h
mem.h
thorin::plug::autodiff
The automatic differentiation Plugin
Definition
autodiff.h:7
src
thorin
plug
autodiff
pass
autodiff_zero_cleanup.cpp
Generated by
1.9.8