Skip to content

Ad ptr merge #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 736 commits into
base: autodiff
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
736 commits
Select commit Hold shift + click to select a range
d7734e9
normalizers
NeuralCoder3 Nov 23, 2022
852cb9b
solved valgrind memory issues (pass by reference vs pass by value poi…
NeuralCoder3 Nov 23, 2022
be44cd1
Doc..
fodinabor Nov 23, 2022
eb278a9
Don't run AddMem by default.
fodinabor Nov 23, 2022
4792258
changed comment
NeuralCoder3 Nov 23, 2022
d4094d7
Merge remote-tracking branch 'upstream/feature/add-mem' into ho_codegen
NeuralCoder3 Nov 23, 2022
1022cad
Merge remote-tracking branch 'origin/ho_codegen' into ad_ptr_merge
NeuralCoder3 Nov 23, 2022
36f0ae1
more agressive simplification (not fully successful)
NeuralCoder3 Nov 23, 2022
c6eb5bf
Merge branch 'inline-optimize' into ad_ptr_merge
NeuralCoder3 Nov 24, 2022
6603b23
added the optimization framework to the new ad dialect
NeuralCoder3 Nov 24, 2022
4916de9
closure conversion passes
NeuralCoder3 Nov 24, 2022
9f546d1
apply ad pipeline
NeuralCoder3 Nov 24, 2022
ed42d16
hack to fix normalizers in one special case
NeuralCoder3 Nov 24, 2022
eb3876b
Rewrite types of non-Lam terms and args of axioms.
fodinabor Nov 24, 2022
897388e
Merge remote-tracking branch 'upstream/feature/add-mem' into ho_codegen
NeuralCoder3 Nov 24, 2022
597f549
Merge remote-tracking branch 'origin/ho_codegen' into ad_ptr_merge
NeuralCoder3 Nov 24, 2022
5711298
bug fix: pass mode to math::op(...)
Nov 24, 2022
e7c3f0d
merged ad_ptr changes
NeuralCoder3 Nov 24, 2022
4cb5d7f
disable bootstrap optimization, default compilation
NeuralCoder3 Nov 24, 2022
c7df887
refactoring 1
NeuralCoder3 Nov 24, 2022
75ad11c
overwrite with master phase
NeuralCoder3 Nov 25, 2022
e347a86
typedef -> using
NeuralCoder3 Nov 25, 2022
714abfe
replaced map with btree
NeuralCoder3 Nov 25, 2022
48b73f2
resolved cyclic dependency
NeuralCoder3 Nov 25, 2022
f166fe0
normalizer tests
NeuralCoder3 Nov 25, 2022
7a9b6c2
Merge remote-tracking branch 'upstream/feature/add-mem' into ad_ptr_m…
NeuralCoder3 Nov 25, 2022
b6d5894
disabled ad post opt
NeuralCoder3 Nov 25, 2022
a9431f1
Merge branch 'ho_codegen' into ad_ptr_merge
NeuralCoder3 Nov 25, 2022
8e419b9
test case for empty tuple problem
NeuralCoder3 Nov 25, 2022
b7f0586
inlined worklist
NeuralCoder3 Nov 25, 2022
64e48c4
comment
NeuralCoder3 Nov 25, 2022
ff7dfaf
more sophisticated way to control trigger for normalizers/matches
Nov 25, 2022
a8d2574
clang-format
Nov 25, 2022
9f608a7
curry & trip: bug fix + unit tests
Nov 26, 2022
3d8678a
clang-format
Nov 26, 2022
11e373f
make Doxygen happy
Nov 26, 2022
834a296
workaround for Doxygen warnings
Nov 26, 2022
541d066
allow true angle brackets as an alternative for D_angle/D_quote
Nov 27, 2022
e2a3d09
complete rewrite of reshape
NeuralCoder3 Nov 28, 2022
2d14b3b
fixed typo
NeuralCoder3 Nov 28, 2022
8f241c7
moved tests
NeuralCoder3 Nov 28, 2022
a62cbe6
notation
NeuralCoder3 Nov 28, 2022
2b6b308
restored default compilation (partial revert of 4cb5d7f)
NeuralCoder3 Nov 28, 2022
600b275
removed non-working pass registration
NeuralCoder3 Nov 28, 2022
c10a7a4
start of default compilation removal
NeuralCoder3 Nov 28, 2022
f38a028
start of opt dialect
NeuralCoder3 Nov 28, 2022
bfae070
handle registered dialects on pass level
NeuralCoder3 Nov 28, 2022
ba3f6ef
re-introduce raw_app to avoid recomputing dependent type
Nov 28, 2022
24100bc
phase for loaded dialects
NeuralCoder3 Nov 28, 2022
78ecf47
[CI][OSX] Override python path for CMake.
fodinabor Nov 28, 2022
46c86eb
disable ad opt
NeuralCoder3 Nov 28, 2022
104b3f9
Merge branch 'ad_ptr_merge' of https://github.com/NeuralCoder3/thorin…
NeuralCoder3 Nov 28, 2022
a3c7cc8
higher order list projection
NeuralCoder3 Nov 28, 2022
0309dfc
Merge pull request #144 from NeuralCoder3/inline-optimize
Nov 28, 2022
dacb524
Merge pull request #151 from AnyDSL/ci/use-same-python-in-cmake
Nov 28, 2022
edc357e
fiddling around with curry counting
Nov 28, 2022
9e5a3b3
Merge branch 'master' into bugfix/axiom_curry
Nov 28, 2022
c1312e7
porting to new API
Nov 28, 2022
5d44e60
clang-format
Nov 28, 2022
e31d670
Merge remote-tracking branch 'origin/master' into feature/add-mem
fodinabor Nov 28, 2022
fa7edf3
located reshape bug
NeuralCoder3 Nov 28, 2022
da44974
Merge pull request #147 from AnyDSL/feature/add-mem
Nov 28, 2022
b549402
fixed var association
NeuralCoder3 Nov 28, 2022
2a9d714
fixed array normalization
NeuralCoder3 Nov 28, 2022
e1acb84
cleanup
Nov 28, 2022
a3f2b48
refactor
NeuralCoder3 Nov 28, 2022
c0c535c
You can now use groups of identifiers within a tuple-pattern that dec…
Nov 28, 2022
90ab9aa
docs
Nov 28, 2022
370c3e1
finally working reshape
NeuralCoder3 Nov 28, 2022
85b75fc
remove unnecessary update function
NeuralCoder3 Nov 28, 2022
6c7d7ae
reshape
NeuralCoder3 Nov 29, 2022
b5e0d28
fixed normalizer special case
NeuralCoder3 Nov 29, 2022
9b5a44f
fixed direct cps2ds normalizer
NeuralCoder3 Nov 29, 2022
b0aead5
resolved circular dependency
NeuralCoder3 Nov 29, 2022
6fbb8f6
Merge remote-tracking branch 'origin/master' into ho_codegen
NeuralCoder3 Nov 29, 2022
3d2d2e6
Merge pull request #150 from AnyDSL/bugfix/axiom_curry
Nov 29, 2022
01a2443
Merge pull request #152 from AnyDSL/feature/ptrn_group
Nov 29, 2022
8e540be
merge reshape from ad_ptr_merge
NeuralCoder3 Nov 29, 2022
2695181
Merge remote-tracking branch 'origin/ho_codegen' into ad_ptr_merge
NeuralCoder3 Nov 29, 2022
fdc74c7
handle external functions
NeuralCoder3 Nov 29, 2022
a076278
fixed handling of main function
NeuralCoder3 Nov 29, 2022
a19b5fa
Merge remote-tracking branch 'origin/ho_codegen' into ad_ptr_merge
NeuralCoder3 Nov 29, 2022
696f819
compare ho codegen and ad
NeuralCoder3 Nov 29, 2022
3253246
fixed tests
NeuralCoder3 Nov 29, 2022
2d11419
merge ad_ptr_merge compilation extension
NeuralCoder3 Nov 29, 2022
ed05055
Update thorin.natvis to be more consistent with current state.
fodinabor Nov 29, 2022
5d6001b
fix warning by providing dbg info
Nov 30, 2022
0a81597
clang-format
Nov 30, 2022
4447ddc
missing dbg
Nov 30, 2022
cf90b96
clang-format
Nov 30, 2022
3548bf9
docs
Nov 30, 2022
63e5c5b
bug fix: wrong type in normalize_div
Nov 30, 2022
4f7868c
minimally invasive dialect registration
NeuralCoder3 Nov 30, 2022
e1e58ef
allow for function calls using static beta reduction
NeuralCoder3 Nov 30, 2022
e76d435
outline of default pipeline
NeuralCoder3 Nov 30, 2022
bc7e83c
add opt to default dialects
NeuralCoder3 Nov 30, 2022
71cfba5
cleanup to cope with imported internals
NeuralCoder3 Nov 30, 2022
a9ead4c
fixed tests (except clos)
NeuralCoder3 Nov 30, 2022
c38c172
fixed refly and clos tests
NeuralCoder3 Nov 30, 2022
1a6ecf0
remove old pass interface
NeuralCoder3 Nov 30, 2022
fa3a45e
refactor
NeuralCoder3 Nov 30, 2022
e9ce242
Merge remote-tracking branch 'origin/master' into ad_ptr_merge
NeuralCoder3 Nov 30, 2022
8012df2
remove unused special case pass axiom
NeuralCoder3 Nov 30, 2022
4e08350
Merge remote-tracking branch 'origin/master' into ho_codegen
NeuralCoder3 Nov 30, 2022
191336d
Merge remote-tracking branch 'origin/ho_codegen' into ad_ptr_merge
NeuralCoder3 Nov 30, 2022
fddd4ac
debug normalizer issues
NeuralCoder3 Nov 30, 2022
68b818a
fixed normalization issues
NeuralCoder3 Nov 30, 2022
6ab5377
Merge remote-tracking branch 'origin/master' into default-compilation
NeuralCoder3 Dec 1, 2022
de2b495
iterate over other compilation functions
NeuralCoder3 Dec 1, 2022
6cd4b93
fixed gtest
NeuralCoder3 Dec 1, 2022
c46517d
disable WARN_AS_ERROR
NeuralCoder3 Dec 1, 2022
f6fa75a
Merge remote-tracking branch 'origin/master' into test/direct_old_var
NeuralCoder3 Dec 2, 2022
31c8751
fixed tests
NeuralCoder3 Dec 2, 2022
55d0023
Merge remote-tracking branch 'origin/master' into matrix_dialect
NeuralCoder3 Dec 2, 2022
9a7fb9a
fixed merge error
NeuralCoder3 Dec 2, 2022
b5dbb13
Merge branch 'matrix_dialect' of https://github.com/NeuralCoder3/thor…
NeuralCoder3 Dec 2, 2022
277d500
minimal rewrite phase
NeuralCoder3 Dec 2, 2022
03f8a59
updated test
NeuralCoder3 Dec 2, 2022
da4f40e
missing std::optional checks
Dec 2, 2022
794726d
more attempts to fix cps2ds
NeuralCoder3 Dec 5, 2022
87cd669
fixed lambda rewrite
NeuralCoder3 Dec 5, 2022
1792c0a
refactoring
NeuralCoder3 Dec 5, 2022
eeaa8ab
add expected result
NeuralCoder3 Dec 5, 2022
a5b9c7b
re-enable curr nom print
NeuralCoder3 Dec 5, 2022
f88f568
more complex case
NeuralCoder3 Dec 5, 2022
8b3fa6a
removed comment
NeuralCoder3 Dec 5, 2022
cca49e6
rewrite recursively
NeuralCoder3 Dec 5, 2022
eae0fab
rewrite callee first
NeuralCoder3 Dec 5, 2022
668cd96
Merge remote-tracking branch 'origin/default-compilation' into ho_cod…
NeuralCoder3 Dec 5, 2022
ac00883
Merge remote-tracking branch 'origin/ho_codegen' into ad_ptr_merge
NeuralCoder3 Dec 5, 2022
702605d
small fix
NeuralCoder3 Dec 5, 2022
319d3f6
Merge remote-tracking branch 'origin/direct_fix' into ad_ptr_merge
NeuralCoder3 Dec 5, 2022
3c48c8f
found one offending difference leading to divergence
NeuralCoder3 Dec 5, 2022
4fc5705
Merge branch 'master' into arr_opt
Dec 5, 2022
bf924e1
better comment
Dec 5, 2022
538819f
fixes #155
Dec 5, 2022
7290afe
fix warnings: version bump
Dec 5, 2022
8d9c0c5
Merge pull request #157 from AnyDSL/version_bump
Dec 5, 2022
a1a1cbe
Merge pull request #110 from AnyDSL/arr_opt
Dec 5, 2022
8336944
30 sec timeout for lit tests per test
Dec 5, 2022
2421f81
install psutil
Dec 5, 2022
de777ff
Merge pull request #158 from AnyDSL/timeout
Dec 5, 2022
87b6356
Merge remote-tracking branch 'origin/direct_fix' into ho_codegen
NeuralCoder3 Dec 6, 2022
d395385
Merge pull request #156 from AnyDSL/bugfix/axiom_rebuild
Dec 6, 2022
e6c494e
emit "<unknown location>" if location is unknown
Dec 5, 2022
8dbfeb2
Add new thorin_all_dialects target.
fodinabor Dec 6, 2022
b925217
increase timeout to 5 minutes/test
Dec 6, 2022
6d9b791
Merge branch 'master' into feature/all-dialects-target
fodinabor Dec 6, 2022
df9eb5f
removed indirection, solved argument issue
NeuralCoder3 Dec 6, 2022
7269d64
refactoring
NeuralCoder3 Dec 6, 2022
fb1ec79
Merge remote-tracking branch 'origin/default-compilation' into ho_cod…
NeuralCoder3 Dec 6, 2022
f59c230
Merge remote-tracking branch 'origin/master' into matrix_dialect
NeuralCoder3 Dec 6, 2022
062be31
fix axiom rewrite
NeuralCoder3 Dec 6, 2022
a7ff1a8
Merge pull request #160 from AnyDSL/feature/all-dialects-target
Dec 6, 2022
d34c575
Merge remote-tracking branch 'origin/ho_codegen' into ad_ptr_merge
NeuralCoder3 Dec 6, 2022
01b7af8
resolved .Nat not type error at completely unrelated code point
NeuralCoder3 Dec 6, 2022
98b25b2
fixed tests
NeuralCoder3 Dec 6, 2022
1b0f9fc
fix non-imp test case
NeuralCoder3 Dec 6, 2022
367ba55
moved eval to https://github.com/NeuralCoder3/ad-thorin-eval
NeuralCoder3 Dec 7, 2022
93a9646
increased timeout
NeuralCoder3 Dec 7, 2022
45dfa94
Merge remote-tracking branch 'origin/master' into default-compilation
NeuralCoder3 Dec 7, 2022
4415b8a
added meta info to inline test
NeuralCoder3 Dec 7, 2022
299da40
only reshape small arrays
NeuralCoder3 Dec 7, 2022
1c43d60
add compile dependency to all dialects with passes
NeuralCoder3 Dec 8, 2022
86799e8
move mem in reshape
NeuralCoder3 Dec 8, 2022
8a56cf0
init mem args
NeuralCoder3 Dec 8, 2022
78a8a13
move mem to front (for closure)
NeuralCoder3 Dec 8, 2022
d6f4ae2
Merge branch 'ho_codegen' of https://github.com/NeuralCoder3/thorin2 …
NeuralCoder3 Dec 8, 2022
4733334
merge
NeuralCoder3 Dec 8, 2022
685d2f1
add mem tests
NeuralCoder3 Dec 9, 2022
fe95409
do not overwrite mem from non-apps
NeuralCoder3 Dec 9, 2022
0add729
some comments
NeuralCoder3 Dec 9, 2022
f528b4b
error reporting script
NeuralCoder3 Dec 9, 2022
9994590
Merge remote-tracking branch 'origin/ho_codegen' into ad_ptr_merge
NeuralCoder3 Dec 9, 2022
491c0b4
re-enabled WARN_AS_ERROR
NeuralCoder3 Dec 9, 2022
36ab407
refactor
NeuralCoder3 Dec 9, 2022
a9597ee
Merge pull request #154 from NeuralCoder3/default-compilation
Dec 9, 2022
1102f70
fix warnings and missing dbg info
Dec 9, 2022
be4a3e6
bug fix: argument order messed up
Dec 9, 2022
3b4e086
fixed warning
Dec 9, 2022
bc3767f
fixed comment
Dec 9, 2022
f66228a
compile dialect: added HEADER_DEPENDS core
Dec 9, 2022
a5ab96c
used overloaded app that already constructs a tuple for us
Dec 9, 2022
dfe46a7
removing core HEADER_DEPENDS from compile dialect agian
Dec 9, 2022
b85670a
removed unused include
Dec 9, 2022
1fe61ac
syntax highlight
NeuralCoder3 Dec 12, 2022
64d27ed
Merge remote-tracking branch 'origin/ho_codegen' into ad_ptr_merge
NeuralCoder3 Dec 12, 2022
0e6f52c
correctly negated check
NeuralCoder3 Dec 13, 2022
a3c67d9
Merge branch 'ho_codegen' of https://github.com/NeuralCoder3/thorin2 …
NeuralCoder3 Dec 13, 2022
736d3dc
error reporting for assert
NeuralCoder3 Dec 13, 2022
a49df1c
add mem attempt for ordering problem
NeuralCoder3 Dec 13, 2022
46f3b04
removed duplicate optimization
NeuralCoder3 Dec 13, 2022
a771115
more interesting index
NeuralCoder3 Dec 13, 2022
3eec6a4
additional test for comparison
NeuralCoder3 Dec 13, 2022
f6c7bd0
Merge remote-tracking branch 'origin/master' into matrix_dialect
NeuralCoder3 Dec 14, 2022
ebac94e
fixed normalizers
NeuralCoder3 Dec 15, 2022
f5bb4d1
more tests
NeuralCoder3 Dec 15, 2022
248a9f6
handle internals/externals in RWPhase
NeuralCoder3 Dec 16, 2022
1bbe9fb
Merge branch 'matrix_dialect' of https://github.com/NeuralCoder3/thor…
NeuralCoder3 Dec 16, 2022
315f7f0
nested allocation
NeuralCoder3 Dec 16, 2022
866d585
fix for #165
Dec 16, 2022
f7118fb
fix for #165
Dec 16, 2022
3b22f21
simplify
Dec 16, 2022
aa28d02
fixes #155
Dec 16, 2022
e603f69
README.md: fixed badges
Dec 17, 2022
d3c0b84
Merge branch 'master' into matrix_dialect
NeuralCoder3 Dec 19, 2022
7169584
added matrix passes, phases
NeuralCoder3 Dec 19, 2022
095be62
Merge branch 'matrix_dialect' of https://github.com/NeuralCoder3/thor…
NeuralCoder3 Dec 19, 2022
9e32eb5
Merge remote-tracking branch 'origin/master' into matrix_dialect
NeuralCoder3 Dec 19, 2022
cbb799a
fixed tests
NeuralCoder3 Dec 19, 2022
7d321f8
transpose test
NeuralCoder3 Dec 19, 2022
3cf2838
remaining map reduce lowerings
NeuralCoder3 Dec 19, 2022
05604bf
Merge remote-tracking branch 'origin/ho_codegen' into matrix_dialect
NeuralCoder3 Dec 20, 2022
2810df7
resolved merge artifact
NeuralCoder3 Dec 20, 2022
202d1a5
ho codegen
NeuralCoder3 Dec 20, 2022
a5a7595
merge codegen fixes from matrix
NeuralCoder3 Dec 20, 2022
0a96f0f
Merge branch 'ho_codegen' of https://github.com/NeuralCoder3/thorin2 …
NeuralCoder3 Dec 20, 2022
255797e
generalized internal cleanup
NeuralCoder3 Dec 22, 2022
fe3283b
specialized internal cleanup
NeuralCoder3 Dec 22, 2022
1f05ef0
matrix execution test
NeuralCoder3 Dec 22, 2022
6c0024c
register phase
NeuralCoder3 Dec 23, 2022
8954d72
Merge remote-tracking branch 'origin/master' into ho_codegen
NeuralCoder3 Dec 23, 2022
50e46bc
move dependency axiom code to compile dialect
NeuralCoder3 Dec 23, 2022
5817fd2
more tests
NeuralCoder3 Dec 23, 2022
0b1f9b9
Merge remote-tracking branch 'origin/ho_codegen' into ad_ptr_merge
NeuralCoder3 Dec 23, 2022
8fa2502
fixes, removed filecheck
NeuralCoder3 Jan 6, 2023
76bb125
ignore non-set functions
NeuralCoder3 Jan 9, 2023
7ee94ce
additional tests
NeuralCoder3 Jan 9, 2023
bc63865
more complex examples
NeuralCoder3 Jan 11, 2023
a2977e5
edge case
NeuralCoder3 Jan 11, 2023
5d6034a
merge matrix
NeuralCoder3 Jan 13, 2023
bc69ec0
handle cleanup
NeuralCoder3 Jan 13, 2023
d02b0b9
fixed naming
NeuralCoder3 Jan 13, 2023
6968dea
more tests
NeuralCoder3 Jan 16, 2023
5174465
Merge remote-tracking branch 'origin/matrix_dialect' into ad_ptr_merge
NeuralCoder3 Jan 16, 2023
6a524b2
fixed in/ex-ternal cleanup composition
NeuralCoder3 Jan 16, 2023
ee33da0
ad matrix test
NeuralCoder3 Jan 16, 2023
b8cb88b
[CI] Downgrade MacOS Runner to 11 for now
fodinabor Jan 19, 2023
d16bb4a
Merge pull request #176 from AnyDSL/ci/downgrade-macos-runner
Jan 20, 2023
995beac
Merge remote-tracking branch 'origin/master' into matrix_dialect
NeuralCoder3 Jan 20, 2023
a5748e7
Merge remote-tracking branch 'origin/matrix_dialect' into ad_ptr_merge
NeuralCoder3 Jan 20, 2023
10f0cf2
hack to fix alpha equivalence
NeuralCoder3 Jan 20, 2023
04c5f38
matrix diff test
NeuralCoder3 Jan 23, 2023
eb65880
working ad matrix test
NeuralCoder3 Jan 23, 2023
39974b4
removed generated cps2ds calls from axiom transformations (tuple call…
NeuralCoder3 Jan 23, 2023
22251d1
removed cps2ds for tuples (packs remaining)
NeuralCoder3 Jan 25, 2023
9fc843c
added check information for imperative test
NeuralCoder3 Jan 25, 2023
b88a56b
comment about pack
NeuralCoder3 Jan 26, 2023
100ca64
more complex test case
NeuralCoder3 Jan 26, 2023
239ffe3
tests on ad memory
NeuralCoder3 Feb 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
*.s
.DS_Store
.cache
build*
build*/
vgcore.*
61 changes: 35 additions & 26 deletions dialects/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ add_thorin_dialect(core
INSTALL
)

add_thorin_dialect(mem
SOURCES
mem/mem.cpp
mem/mem.h
mem/normalizers.cpp
mem/passes/fp/copy_prop.cpp
mem/passes/fp/copy_prop.h
mem/passes/fp/ssa_constr.cpp
mem/passes/fp/ssa_constr.h
mem/passes/rw/alloc2malloc.cpp
mem/passes/rw/alloc2malloc.h
mem/passes/rw/remem_elim.cpp
mem/passes/rw/remem_elim.h
mem/passes/rw/reshape.cpp
mem/passes/rw/reshape.h
HEADER_DEPENDS
core
INSTALL
)

add_thorin_dialect(clos
SOURCES
clos/clos.cpp
Expand All @@ -24,11 +44,13 @@ add_thorin_dialect(clos
clos/pass/rw/clos2sjlj.h
clos/pass/rw/clos_conv_prep.cpp
clos/pass/rw/clos_conv_prep.h
clos/pass/rw/phase_wrapper.h
clos/phase/clos_conv.cpp
clos/phase/clos_conv.h
clos/phase/lower_typed_clos.cpp
clos/phase/lower_typed_clos.h
mem/passes/fp/copy_prop.cpp
mem/passes/rw/reshape.cpp
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if inter-dialect phases are necessary here.

DEPENDS
mem
affine
Expand All @@ -37,14 +59,6 @@ add_thorin_dialect(clos
INSTALL
)

add_thorin_dialect(demo
SOURCES
demo/demo.cpp
demo/demo.h
demo/normalizers.cpp
INSTALL
)

add_thorin_dialect(direct
SOURCES
direct/direct.cpp
Expand All @@ -57,34 +71,25 @@ add_thorin_dialect(direct
INSTALL
)

add_thorin_dialect(mem
SOURCES
mem/mem.cpp
mem/mem.h
mem/normalizers.cpp
mem/passes/fp/copy_prop.cpp
mem/passes/fp/copy_prop.h
mem/passes/fp/ssa_constr.cpp
mem/passes/fp/ssa_constr.h
mem/passes/rw/alloc2malloc.cpp
mem/passes/rw/alloc2malloc.h
mem/passes/rw/remem_elim.cpp
mem/passes/rw/remem_elim.h
HEADER_DEPENDS
core
INSTALL
)

add_thorin_dialect(refly
SOURCES
refly/refly.h
refly/refly.cpp
refly/passes/remove_perm.h
refly/passes/remove_perm.cpp
refly/passes/debug_dump.h
refly/normalizers.cpp
INSTALL
)

add_thorin_dialect(demo
SOURCES
demo/demo.cpp
demo/demo.h
demo/normalizers.cpp
INSTALL
)

add_thorin_dialect(affine
SOURCES
affine/affine.cpp
Expand Down Expand Up @@ -112,7 +117,11 @@ add_thorin_dialect(autodiff
autodiff/auxiliary/autodiff_aux.h
autodiff/auxiliary/autodiff_rewrite_inner.cpp
autodiff/auxiliary/autodiff_rewrite_toplevel.cpp
autodiff/auxiliary/autodiff_mem.cpp
autodiff/auxiliary/autodiff_mem.h
autodiff/normalizers.cpp
affine/passes/lower_for.cpp
mem/passes/rw/reshape.cpp
DEPENDS
mem
core
Expand Down
5 changes: 3 additions & 2 deletions dialects/affine/affine.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#include "dialects/affine/affine.h"

#include <thorin/config.h>
#include <thorin/pass/pass.h>

#include "thorin/dialects.h"

#include "dialects/affine/affine.h"
#include "dialects/affine/passes/lower_for.h"

extern "C" THORIN_EXPORT thorin::DialectInfo thorin_get_dialect_info() {
return {"affine",
[](thorin::PipelineBuilder& builder) {
builder.extend_opt_phase([](thorin::PassMan& man) { man.add<thorin::affine::LowerFor>(); });
builder.extend_opt_phase(106, [](thorin::PassMan& man) { man.add<thorin::affine::LowerFor>(); });
},
nullptr, nullptr};
}
4 changes: 2 additions & 2 deletions dialects/affine/affine.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ inline const Def* fn_for(World& w, Defs params) {
/// Returns a fully applied affine_for axiom.
/// See documentation for %affine.For axiom in @ref affine.
inline const Def* op_for(World& w,
const Def* mem,
const Def* begin,
const Def* end,
const Def* step,
Defs inits,
const Def* body,
const Def* brk) {
DefArray types(inits.size(), [&](size_t i) { return inits[i]->type(); });
return w.app(fn_for(w, types), {mem, begin, end, step, w.tuple(inits), body, brk});
auto fn = fn_for(w, types);
return w.app(fn, {begin, end, step, w.tuple(inits), body, brk});
}
} // namespace thorin::affine
10 changes: 5 additions & 5 deletions dialects/affine/passes/lower_for.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ const Def* LowerFor::rewrite(const Def* def) {

// reduce the body to remove the cn parameter
auto nom_body = body->as_nom<Lam>();
auto new_body = nom_body->stub(w, w.cn(w.sigma()), body->dbg());
new_body->set(nom_body->reduce(w.tuple({iter, acc, yield_lam})));
auto new_body = nom_body->stub(w, w.cn(acc->type()), body->dbg());
new_body->set(nom_body->reduce(w.tuple({iter, new_body->var(), yield_lam})));

// break
auto if_else_cn = w.cn(w.sigma());
auto if_else_cn = w.cn(acc->type());
auto if_else = w.nom_lam(if_else_cn, nullptr);
if_else->app(false, brk, acc);
if_else->app(false, brk, if_else->var());

auto cmp = core::op(core::icmp::ul, iter, end);
for_lam->branch(false, cmp, new_body, if_else, w.tuple());
for_lam->branch(false, cmp, new_body, if_else, acc);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@christopherhjung
Is the inlining/forwarding of the accumulator necessary here?
Optimizations like CopyProp will probably delete the arguments.
And Closure Conversion has as one main function closing open terms and will (if not inlined) re-add the accumulator and bound variables as arguments.

}

DefArray for_args{for_ax->num_args() - 2, [&](size_t i) { return for_ax->arg(i); }};
Expand Down
13 changes: 10 additions & 3 deletions dialects/autodiff/autodiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

#include "thorin/dialects.h"

#include "dialects/affine/passes/lower_for.h"
#include "dialects/autodiff/passes/autodiff_eval.h"
#include "dialects/autodiff/passes/autodiff_ext_cleanup.h"
#include "dialects/autodiff/passes/autodiff_zero.h"
#include "dialects/autodiff/passes/autodiff_zero_cleanup.h"
#include "dialects/direct/passes/ds2cps.h"
#include "dialects/mem/passes/rw/reshape.h"

using namespace thorin;

Expand All @@ -18,22 +20,27 @@ using namespace thorin;
/// * perform ad [105]
/// * resolve unsolved zeros (not added) [111]
/// * optimize further, cleanup direct style [115-120] (in direct)
/// * cleanup (zeros, externals) [299]
/// * cleanup (zeros, externals) [126]
extern "C" THORIN_EXPORT thorin::DialectInfo thorin_get_dialect_info() {
return {"autodiff",
[](thorin::PipelineBuilder& builder) {
builder.add_opt(110);

builder.extend_opt_phase(104, [](PassMan& man) { man.add<mem::Reshape>(mem::Reshape::Arg); });
builder.extend_opt_phase(105, [](thorin::PassMan& man) { man.add<thorin::autodiff::AutoDiffEval>(); });
builder.extend_opt_phase(111, [](thorin::PassMan& man) {
builder.extend_opt_phase(106, [](thorin::PassMan& man) { man.add<thorin::affine::LowerFor>(); });
builder.extend_opt_phase(107, [](thorin::PassMan& man) {
// in theory only after partial eval (beta, ...)
// but before other simplification
// zero and add need to be close together
man.add<thorin::autodiff::AutoDiffZero>();
});
builder.extend_opt_phase(299, [](PassMan& man) {
builder.extend_opt_phase(126, [](PassMan& man) {
man.add<thorin::autodiff::AutoDiffZeroCleanup>();
man.add<thorin::autodiff::AutoDiffExternalCleanup>();
});

builder.add_opt(125);
},
nullptr, [](Normalizers& normalizers) { autodiff::register_normalizers(normalizers); }};
}
18 changes: 18 additions & 0 deletions dialects/autodiff/autodiff.thorin
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@
};
inner_cmp
};
/// core.icmp.ul
.lam .extern internal_diff_core_icmp_XygLe
![w: .Nat] ->
(.Cn[[.Idx w, .Idx w], .Cn[.Idx 2, .Cn[.Idx 2, .Cn[.Idx w, .Idx w]]]])
= {
.cn inner_cmp
![[a: .Idx w, b: .Idx w], ret:.Cn[.Idx 2, .Cn[.Idx 2, .Cn[.Idx w, .Idx w]]]]
= {
.let result = %core.icmp.ul (w) (a,b);
.cn cmp_pb ![s: .Idx 2, pb_ret:.Cn[.Idx w, .Idx w]]
= {
.let z = 0:(.Idx w);
pb_ret (z, z)
};
ret (result,cmp_pb)
};
inner_cmp
};
/// core.icmp.e
.lam .extern internal_diff_core_icmp_xyglE
![w: .Nat] ->
Expand Down
Loading