Skip to content
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

Matrix dialect #180

Merged
merged 385 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
385 commits
Select commit Hold shift + click to select a range
bb3e879
simple peephole optimization for 0+x=x
NeuralCoder3 Mar 8, 2022
65a3074
added partial eval optim to optim pass 3
NeuralCoder3 Mar 8, 2022
c00f797
tests with flat cn
NeuralCoder3 Mar 8, 2022
4f05015
temp fix for tuple coupling
NeuralCoder3 Mar 8, 2022
2ec0969
temp fix for sigma problems (conditional, return tuple)
NeuralCoder3 Mar 9, 2022
45a06d8
fixed ptr arg init
NeuralCoder3 Mar 9, 2022
fa3dbb1
merge
NeuralCoder3 Mar 10, 2022
e64e8a5
replaced lam->app
NeuralCoder3 Mar 10, 2022
08c190f
Merge https://github.com/AnyDSL/thorin2 into autodiff
NeuralCoder3 Mar 11, 2022
c54dd02
cleanup, fat pointer signature
NeuralCoder3 Mar 11, 2022
d0da3ec
alloc fat-ptr implementation
Mar 13, 2022
7ec5f04
fat_ptr alloc fix
NeuralCoder3 Mar 14, 2022
f2fbea0
correct left & tangent type for ptr to arrays
NeuralCoder3 Mar 15, 2022
18d453d
fixed unreachable
NeuralCoder3 Mar 15, 2022
cf10485
forwarded correct A (instead left transformed one)
NeuralCoder3 Mar 15, 2022
4826c15
array fat ptr input pb
NeuralCoder3 Mar 15, 2022
724f68d
wip lea fat ptr
NeuralCoder3 Mar 15, 2022
4aa790c
lea fat_ptr
NeuralCoder3 Mar 16, 2022
a06e48c
fix lea, alloc, bitcast
NeuralCoder3 Mar 16, 2022
185bd71
zero for arrays
NeuralCoder3 Mar 16, 2022
a78f65b
merge master
NeuralCoder3 Mar 17, 2022
63bc50c
fixed changes from merge
NeuralCoder3 Mar 17, 2022
c379aa4
correct zero arrays
NeuralCoder3 Mar 17, 2022
eb3647c
vec_add fat_ptr implementation
Mar 20, 2022
fde5754
vec add in call position
NeuralCoder3 Mar 22, 2022
183c344
loop over fat ptr
NeuralCoder3 Mar 22, 2022
5b1530b
vec add for pointer
NeuralCoder3 Mar 22, 2022
9ce2e5e
added correct ptr sum & fixed mem
NeuralCoder3 Mar 22, 2022
68b95a7
fix non-flat one-hot
NeuralCoder3 Mar 25, 2022
fe0b12e
temporary fix to preserve fat pointer in extract pb
NeuralCoder3 Mar 26, 2022
232e47e
solved mut problems
NeuralCoder3 Mar 29, 2022
5e997d0
Merge branch 'fat-ptr' of https://github.com/NeuralCoder3/thorin into…
NeuralCoder3 Mar 29, 2022
60be685
slightly more general fix for one hot / pb extract / flat tuple
NeuralCoder3 Mar 29, 2022
ad36256
tangent of full function type
NeuralCoder3 Mar 29, 2022
b7993c9
structure map
NeuralCoder3 Mar 29, 2022
d34f86e
corrected spelling
NeuralCoder3 Mar 29, 2022
b7e1231
merge
NeuralCoder3 Apr 4, 2022
cb666ef
removed workflow
NeuralCoder3 Apr 4, 2022
a5f1733
removed workflow
NeuralCoder3 Apr 4, 2022
fe26104
solved array projection issue
NeuralCoder3 Apr 4, 2022
1538193
fix clang errors
christopherhjung Apr 4, 2022
8fbeda5
fix sub
christopherhjung Apr 5, 2022
12cf51d
fix div
christopherhjung Apr 5, 2022
584dcc1
refactoring j_wrap_rop
christopherhjung Apr 5, 2022
b270066
bugfix rop and implementation AutoDiff definition of isReturning
christopherhjung Apr 5, 2022
3187840
fix ret_var
christopherhjung Apr 5, 2022
b4f381c
cleanup
christopherhjung Apr 5, 2022
3df8201
substitute set_filter with nom_filter_lam for better overview
christopherhjung Apr 7, 2022
657b38a
remove debug logs
christopherhjung Apr 7, 2022
1dec8a9
split src_to_dst assignment
christopherhjung Apr 7, 2022
10dd7e5
refactoring DefArray's
christopherhjung Apr 7, 2022
17749b2
Merge pull request #1 from NeuralCoder3/refactoring
NeuralCoder3 Apr 8, 2022
88c3596
made arrref->skip more explicit
NeuralCoder3 Apr 8, 2022
437a01b
merge
NeuralCoder3 Apr 12, 2022
5b62eac
removed workflow
NeuralCoder3 Apr 12, 2022
bdf21b4
remove size_t cast because size_t was replaces by nat_t so no cast re…
christopherhjung Apr 13, 2022
de64e48
Merge https://github.com/AnyDSL/thorin2 into t2
NeuralCoder3 Apr 21, 2022
34aaecd
Merge branch 't2' of https://github.com/NeuralCoder3/thorin into t2
NeuralCoder3 Apr 26, 2022
433e02b
fixed flat fat ptr app for extracts
NeuralCoder3 Apr 26, 2022
8edf242
fix segmentation fault and add partial evaluation before auto diff
christopherhjung Apr 26, 2022
efaf8b6
replace φ py phi_
christopherhjung Apr 26, 2022
f0d5e7e
do not fully unfold addition
NeuralCoder3 Apr 26, 2022
e3bea74
implement numeric diff multidim
christopherhjung Apr 12, 2022
7e49928
rebase and fix bug
christopherhjung May 4, 2022
d90d8d4
Merge pull request #2 from NeuralCoder3/multidim-numeric-new
NeuralCoder3 May 5, 2022
ace957b
refactoring AT, BT
NeuralCoder3 May 5, 2022
35e4cd6
removed loop head filter
NeuralCoder3 May 5, 2022
6c488b1
Merge branch 't2' of https://github.com/NeuralCoder3/thorin into t2
NeuralCoder3 May 5, 2022
b48780b
linear control flow for num diff
NeuralCoder3 May 5, 2022
5cbe54b
numeric diff result as tuple
NeuralCoder3 May 5, 2022
1a2fc68
fix multi out ext diff
NeuralCoder3 May 6, 2022
3bd8dec
Implement Ptr support for numeric diff
christopherhjung May 8, 2022
66b53e5
update comment
christopherhjung May 8, 2022
87bf900
Merge pull request #3 from NeuralCoder3/multidim-numeric-new
NeuralCoder3 May 11, 2022
43dad79
added todos
NeuralCoder3 May 11, 2022
e0a7dda
fix vec_add bug
christopherhjung May 12, 2022
53df3d1
Merge branch 'master' of https://github.com/AnyDSL/thorin2 into t2
NeuralCoder3 May 12, 2022
c05d56b
Merge branch 'master' of https://github.com/AnyDSL/thorin2 into t2
NeuralCoder3 May 13, 2022
cc0a27f
removed peephole optim
NeuralCoder3 May 13, 2022
d9e791e
created file for matrix
NeuralCoder3 Jun 14, 2022
6cefa99
more types
NeuralCoder3 Jun 14, 2022
90bddb4
map type
NeuralCoder3 Jun 14, 2022
a080514
remaining operations
NeuralCoder3 Jun 14, 2022
2f0c441
overlooked read, const
NeuralCoder3 Jun 14, 2022
e967508
insertion
NeuralCoder3 Jun 15, 2022
b6a9757
module cleanup
NeuralCoder3 Jun 20, 2022
7cf8510
added matrix to cmake
NeuralCoder3 Jun 20, 2022
678146c
hard reset to https://github.com/AnyDSL/thorin2 master
NeuralCoder3 Jun 20, 2022
6156061
new dialect version
NeuralCoder3 Jun 20, 2022
390f214
even more matrix operations
NeuralCoder3 Jun 20, 2022
b871783
Merge branch 'master' of https://github.com/AnyDSL/thorin2 into matri…
NeuralCoder3 Jun 23, 2022
999b9a8
matrix dialect file connection
NeuralCoder3 Jun 23, 2022
aa42b31
read(const a) = a
NeuralCoder3 Jun 23, 2022
ce7b8bb
matrix const read test
NeuralCoder3 Jun 24, 2022
6e6ecdf
attempt to normalize
NeuralCoder3 Jun 24, 2022
1c8819f
trivial normalizer
NeuralCoder3 Jun 24, 2022
c3b9115
%mat -> %matrix
NeuralCoder3 Jun 27, 2022
ef02436
correct read(const) normalizer
NeuralCoder3 Jun 27, 2022
0211382
normalizer definitions
NeuralCoder3 Jun 27, 2022
f18ffb2
passes for matrix
NeuralCoder3 Jun 28, 2022
45baef5
Merge branch 'master' of https://github.com/AnyDSL/thorin2 into matri…
NeuralCoder3 Jun 28, 2022
565b478
more normalizers
NeuralCoder3 Jun 29, 2022
f443f89
new skeleton for lowering
NeuralCoder3 Jun 29, 2022
c116a3e
Merge branch 'matrix-dialect' of https://github.com/NeuralCoder3/thor…
NeuralCoder3 Jul 7, 2022
bc5e7eb
adapted matrix to new convention
NeuralCoder3 Jul 7, 2022
544e8e6
let for better readability
NeuralCoder3 Jul 7, 2022
281b644
matrix dialect extended
NeuralCoder3 Jul 7, 2022
d0fc663
ideas for map
NeuralCoder3 Jul 8, 2022
56a0bf1
fixed typos
NeuralCoder3 Jul 19, 2022
d462ef3
generalized map, reduce, zip
NeuralCoder3 Jul 19, 2022
935d1ea
mapReduce applications
NeuralCoder3 Jul 19, 2022
96dc62b
removed old code in favor of mapReduce also known as einsum (jack of …
NeuralCoder3 Jul 19, 2022
a89d1e3
attempt to use mapReduce
NeuralCoder3 Jul 19, 2022
a3a66ce
matrix normalize begin
NeuralCoder3 Jul 22, 2022
f6eb600
update
NeuralCoder3 Jul 22, 2022
b170677
updated to mem monad matrix
NeuralCoder3 Jul 26, 2022
6706ce2
more on lowering
NeuralCoder3 Jul 26, 2022
3a66999
rewrote lower_mapReduce
NeuralCoder3 Jul 27, 2022
c1d50e2
finished one version of mapReduce lowering
NeuralCoder3 Jul 27, 2022
70d45d2
cleanup
NeuralCoder3 Jul 27, 2022
c85c2be
Merge branch 'master' into matrix_dialect
NeuralCoder3 Oct 10, 2022
2cf2642
fix compilation
NeuralCoder3 Oct 10, 2022
808e515
Merge branch 'direct_dependent' into matrix-simple
NeuralCoder3 Oct 10, 2022
bebb850
replaced Int -> Idx again
NeuralCoder3 Oct 10, 2022
71e79e6
added simplified operations
NeuralCoder3 Oct 10, 2022
80f14f7
updated test case
NeuralCoder3 Oct 10, 2022
cdf109e
Merge branch 'master' into matrix_dialect
NeuralCoder3 Oct 12, 2022
2e72687
fixed compilation issue
NeuralCoder3 Oct 12, 2022
f50ae0e
Merge branch 'matrix-simple' into matrix_dialect + adaptation
NeuralCoder3 Oct 14, 2022
0dc9960
update, generalization
NeuralCoder3 Oct 17, 2022
ff87747
updates map reduce example
NeuralCoder3 Oct 18, 2022
2b4a5ee
started rewrite of matrix lowering
NeuralCoder3 Oct 18, 2022
bea56da
finally lowered generalized matrix map reduction
NeuralCoder3 Oct 19, 2022
e96b4c5
typo
NeuralCoder3 Oct 19, 2022
073c194
multiple lowering passes
NeuralCoder3 Oct 20, 2022
b78c9ec
Merge branch 'master' into matrix_dialect
NeuralCoder3 Oct 20, 2022
fb34a44
bug reproduction
NeuralCoder3 Oct 20, 2022
621cabf
Merge branch 'master' into matrix_dialect
NeuralCoder3 Oct 20, 2022
e26d52c
used correct operations
NeuralCoder3 Oct 20, 2022
e284e84
nested matrices
NeuralCoder3 Oct 20, 2022
91cec19
completed other operations lowering onto pointer level
NeuralCoder3 Oct 20, 2022
6e0e01f
fixed hash problem
NeuralCoder3 Oct 20, 2022
9dfd85b
fixed UB
leissa Oct 20, 2022
7ac0715
added newlines to make it more readable
NeuralCoder3 Oct 21, 2022
abf6928
indentation
NeuralCoder3 Oct 21, 2022
0718baf
Merge branch 'matrix_dialect' of https://github.com/NeuralCoder3/thor…
NeuralCoder3 Oct 21, 2022
222c93e
added mem to high level operations
NeuralCoder3 Oct 21, 2022
d7ded94
prod -> map reduce
NeuralCoder3 Oct 21, 2022
66d018f
generalized handling
NeuralCoder3 Oct 21, 2022
8b0a1e9
a bit of cleanup
NeuralCoder3 Oct 21, 2022
c631bf7
moved internal function cleanup
NeuralCoder3 Oct 21, 2022
a0c51c7
external product
NeuralCoder3 Oct 21, 2022
d99c3ec
generalization approach
NeuralCoder3 Oct 21, 2022
4c7de94
wrong projection
NeuralCoder3 Oct 21, 2022
ea98aba
unary tuple extract fix
NeuralCoder3 Oct 21, 2022
96ed8ca
Merge branch 'unary_tuple_fix' into matrix_dialect
NeuralCoder3 Oct 21, 2022
08d32ee
example for extern function definition
NeuralCoder3 Oct 21, 2022
f89bcc1
remaining mapReduce definitions
NeuralCoder3 Oct 21, 2022
0acbf3f
Merge branch 'master' into matrix_dialect
NeuralCoder3 Oct 24, 2022
3f6c82e
proj issue, internals handling
NeuralCoder3 Oct 25, 2022
adc1a23
commented out unfold functions for easier debugging
NeuralCoder3 Oct 25, 2022
b9df239
improved error output
NeuralCoder3 Oct 28, 2022
4701987
Merge branch 'matrix_dialect' of https://github.com/NeuralCoder3/thor…
NeuralCoder3 Oct 28, 2022
f6327f1
Merge branch 'master' into matrix_dialect
NeuralCoder3 Oct 28, 2022
c922b63
tests to get pass to work
NeuralCoder3 Nov 3, 2022
b42f76b
manual iteration attempt
NeuralCoder3 Nov 3, 2022
e16871b
filter fix
NeuralCoder3 Nov 4, 2022
44ef888
reworked rewrite
NeuralCoder3 Nov 4, 2022
e3cf438
more tests to eliminate errors and find unprintable def
NeuralCoder3 Nov 4, 2022
a182e0a
Merge branch 'master' into matrix_dialect
NeuralCoder3 Nov 9, 2022
39e1f05
Merge branch 'matrix_dialect' of https://github.com/NeuralCoder3/thor…
NeuralCoder3 Nov 9, 2022
a8affdb
real -> math.F
NeuralCoder3 Nov 9, 2022
a24bb24
rewrite parts beforehand
NeuralCoder3 Nov 9, 2022
aa327c4
fixed last matrix lowering
NeuralCoder3 Nov 10, 2022
4bce7d1
fixed a few lit tests (only thorin generation)
NeuralCoder3 Nov 10, 2022
308b431
fixed more test cases
NeuralCoder3 Nov 10, 2022
6fdfe36
a bit of cleanup
NeuralCoder3 Nov 10, 2022
50c64af
disabled transpose for now
NeuralCoder3 Nov 10, 2022
0d109bc
added printer error demonstration
NeuralCoder3 Nov 10, 2022
92de14b
fixed remaining (non transpose) tests
NeuralCoder3 Nov 10, 2022
ab3d93a
more tranpose tests
NeuralCoder3 Nov 10, 2022
f3a3def
Merge branch 'ho_codegen' into matrix_dialect
NeuralCoder3 Nov 17, 2022
e409eee
updated test cases
NeuralCoder3 Nov 17, 2022
24cfecd
fixed some test cases
NeuralCoder3 Nov 17, 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
f59c230
Merge remote-tracking branch 'origin/master' into matrix_dialect
NeuralCoder3 Dec 6, 2022
062be31
fix axiom rewrite
NeuralCoder3 Dec 6, 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
f7118fb
fix for #165
leissa Dec 16, 2022
3b22f21
simplify
leissa Dec 16, 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
fe3283b
specialized internal cleanup
NeuralCoder3 Dec 22, 2022
1f05ef0
matrix execution test
NeuralCoder3 Dec 22, 2022
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
6968dea
more tests
NeuralCoder3 Jan 16, 2023
995beac
Merge remote-tracking branch 'origin/master' into matrix_dialect
NeuralCoder3 Jan 20, 2023
d878112
more information about failure
NeuralCoder3 Feb 1, 2023
93649bf
Merge remote-tracking branch 'origin/master' into matrix_dialect
NeuralCoder3 Feb 1, 2023
c574d09
removed implicit arguments
NeuralCoder3 Feb 1, 2023
a0f8327
reordering
NeuralCoder3 Mar 13, 2023
4fdea5e
Merge remote-tracking branch 'origin/master' into matrix_dialect
NeuralCoder3 Mar 13, 2023
75535ea
removed merge artifact
NeuralCoder3 Mar 13, 2023
a880e8c
Merge remote-tracking branch 'upstream/refactor/sort' into matrix_dia…
NeuralCoder3 Mar 14, 2023
fdf1a38
enable matrix dialect compilation
NeuralCoder3 Mar 14, 2023
5de48c5
Merge remote-tracking branch 'origin/master' into matrix_dialect
NeuralCoder3 Mar 15, 2023
f62f5b7
update code / fix merge errors
NeuralCoder3 Mar 15, 2023
68fbe05
fixed normalizers
NeuralCoder3 Mar 15, 2023
6fee15b
fix ad cleanup
NeuralCoder3 Mar 15, 2023
350c340
fixed implicit arguments
NeuralCoder3 Mar 15, 2023
e163d31
temporarily add fix from #187
NeuralCoder3 Mar 15, 2023
f50d141
fixed test case
NeuralCoder3 Mar 15, 2023
7c2a31a
revisited unresolved tests
NeuralCoder3 Mar 16, 2023
465fdd7
attempt to fix register_pass not found
NeuralCoder3 Mar 16, 2023
da8bc3d
removed old tag relict
NeuralCoder3 Mar 16, 2023
680fb6c
explicitely include pipelinebuilder
NeuralCoder3 Mar 16, 2023
e81096f
replaced casted initializer lists
NeuralCoder3 Mar 17, 2023
fd73b1e
replaced span with array
NeuralCoder3 Mar 20, 2023
ecefff0
disable timing for non-linux platforms
NeuralCoder3 Mar 20, 2023
4e63757
fixed doxygen
NeuralCoder3 Mar 20, 2023
13c3360
c++ code cleanup
NeuralCoder3 Mar 20, 2023
a66d590
thorin code cleanup
NeuralCoder3 Mar 20, 2023
fb5e7d8
removed comments in normalizers
NeuralCoder3 Mar 20, 2023
9cce49a
Merge branch 'anydsl_master' into matrix_dialect
leissa Mar 28, 2023
b88cf04
compile fixes/fix warnings
leissa Mar 28, 2023
e34828d
Merge branch 'anydsl_master' into matrix_dialect
leissa Mar 28, 2023
78c4ec2
refactor
NeuralCoder3 Mar 29, 2023
1532a18
Merge branch 'anydsl_master' into matrix_dialect
leissa Mar 29, 2023
e147add
sort indices to avoid non-deterministic map access
NeuralCoder3 Mar 29, 2023
22a608c
fixed type error
leissa Mar 29, 2023
e70c5ce
updated lit commands
leissa Mar 29, 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
24 changes: 22 additions & 2 deletions dialects/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ add_thorin_plugin(autodiff
autodiff/passes/autodiff_zero.h
autodiff/passes/autodiff_zero_cleanup.cpp
autodiff/passes/autodiff_zero_cleanup.h
autodiff/passes/autodiff_ext_cleanup.cpp
autodiff/passes/autodiff_ext_cleanup.h
autodiff/auxiliary/autodiff_aux.cpp
autodiff/auxiliary/autodiff_aux.h
autodiff/auxiliary/autodiff_rewrite_inner.cpp
autodiff/auxiliary/autodiff_rewrite_toplevel.cpp
autodiff/normalizers.cpp
compile/passes/internal_cleanup.cpp
DEPENDS
mem
core
Expand Down Expand Up @@ -127,6 +126,27 @@ add_thorin_plugin(math
INSTALL
)

add_thorin_plugin(matrix
SOURCES
matrix/matrix.cpp
matrix/matrix.h
matrix/normalizers.cpp
matrix/passes/lower_matrix_highlevel.cpp
matrix/passes/lower_matrix_highlevel.h
matrix/passes/lower_matrix_mediumlevel.cpp
matrix/passes/lower_matrix_mediumlevel.h
matrix/passes/lower_matrix_lowlevel.cpp
matrix/passes/lower_matrix_lowlevel.h
compile/passes/internal_cleanup.cpp
DEPENDS
refly
direct
affine
core
mem
compile
INSTALL
)
add_thorin_plugin(mem
SOURCES
mem/mem.cpp
Expand Down
11 changes: 9 additions & 2 deletions dialects/affine/affine.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ 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* begin, const Def* end, const Def* step, Defs inits, const Def* body, const Def* brk) {
// clang-format off
inline const Def* op_for(World& w,
Ref begin,
Ref end,
Ref step,
Defs inits,
Ref body,
Ref brk) {
DefArray types(inits.size(), [&](size_t i) { return inits[i]->type(); });
return w.app(fn_for(w, types), {begin, end, step, w.tuple(inits), body, brk});
}
// clang-format on
NeuralCoder3 marked this conversation as resolved.
Show resolved Hide resolved
} // namespace thorin::affine
4 changes: 2 additions & 2 deletions dialects/autodiff/autodiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include <thorin/pass/pipelinebuilder.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/compile/passes/internal_cleanup.h"
#include "dialects/direct/passes/ds2cps.h"

using namespace thorin;
Expand All @@ -18,7 +18,7 @@ extern "C" THORIN_EXPORT Plugin thorin_get_plugin() {
register_pass<autodiff::ad_eval_pass, autodiff::AutoDiffEval>(passes);
register_pass<autodiff::ad_zero_pass, autodiff::AutoDiffZero>(passes);
register_pass<autodiff::ad_zero_cleanup_pass, autodiff::AutoDiffZeroCleanup>(passes);
register_pass<autodiff::ad_ext_cleanup_pass, autodiff::AutoDiffExternalCleanup>(passes);
register_pass<autodiff::ad_ext_cleanup_pass, compile::InternalCleanup>(passes, "internal_diff_");
},
nullptr, [](Normalizers& normalizers) { autodiff::register_normalizers(normalizers); }};
}
23 changes: 0 additions & 23 deletions dialects/autodiff/passes/autodiff_ext_cleanup.cpp

This file was deleted.

17 changes: 0 additions & 17 deletions dialects/autodiff/passes/autodiff_ext_cleanup.h

This file was deleted.

2 changes: 1 addition & 1 deletion dialects/autodiff/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ zip*:

zip*:
λ S. split(
mapReduce
map_reduce
(λ (m,n,s).
let (_, f*) = f' (m,n);
f* s
Expand Down
4 changes: 2 additions & 2 deletions dialects/clos/clos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ extern "C" THORIN_EXPORT Plugin thorin_get_plugin() {
return {"clos",
[](Passes& passes) {
register_pass<clos::clos_conv_prep_pass, clos::ClosConvPrep>(passes, nullptr);
register_pass<clos::clos_conv_pass, ClosConvWrapper>(passes);
register_pass<clos::clos_conv_pass, clos::ClosConvWrapper>(passes);
register_pass<clos::branch_clos_pass, clos::BranchClosElim>(passes);
register_pass<clos::lower_typed_clos_prep_pass, clos::LowerTypedClosPrep>(passes);
register_pass<clos::clos2sjlj_pass, clos::Clos2SJLJ>(passes);
register_pass<clos::lower_typed_clos_pass, LowerTypedClosWrapper>(passes);
register_pass<clos::lower_typed_clos_pass, clos::LowerTypedClosWrapper>(passes);
// TODO:; remove after ho_codegen merge
passes[flags_t(Axiom::Base<clos::eta_red_bool_pass>)] = [&](World&, PipelineBuilder& builder, Ref app) {
auto bb = app->as<App>()->arg();
Expand Down
4 changes: 3 additions & 1 deletion dialects/clos/pass/rw/phase_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "dialects/clos/phase/clos_conv.h"
#include "dialects/clos/phase/lower_typed_clos.h"

using namespace thorin;
namespace thorin::clos {

class ClosConvWrapper : public RWPass<ClosConvWrapper, Lam> {
public:
Expand All @@ -23,3 +23,5 @@ class LowerTypedClosWrapper : public RWPass<LowerTypedClosWrapper, Lam> {

void prepare() override { clos::LowerTypedClos(world()).run(); }
};

}
1 change: 1 addition & 0 deletions dialects/compile/compile.thorin
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
.ax %compile.clos_plugin : %compile.Plugin;
.ax %compile.direct_plugin : %compile.Plugin;
.ax %compile.refly_plugin : %compile.Plugin;
.ax %compile.matrix_plugin : %compile.Plugin;
///
/// ### %opt.is_loaded
///
Expand Down
31 changes: 23 additions & 8 deletions dialects/core/be/ll/ll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ std::string Emitter::convert(const Def* type) {

std::string Emitter::convert_ret_pi(const Pi* pi) {
auto dom = mem::strip_mem_ty(pi->dom());
if (dom == world().sigma()) { return "void"; }
if (dom == world().sigma()) return "void";
return convert(dom);
}

Expand Down Expand Up @@ -261,9 +261,8 @@ void Emitter::finalize(const Scope& scope) {
print(func_impls_, "{}:\n", lam->unique_name());

++tab;
for (const auto& part : bb.parts) {
for (const auto& part : bb.parts)
for (const auto& line : part) tab.print(func_impls_, "{}\n", line.str());
}
--tab;
func_impls_ << std::endl;
}
Expand Down Expand Up @@ -305,7 +304,26 @@ void Emitter::emit_epilogue(Lam* lam) {
}
}
} else if (auto ex = app->callee()->isa<Extract>(); ex && app->callee_type()->is_basicblock()) {
emit_unsafe(app->arg());
// emit_unsafe(app->arg());
// A call to an extract like constructed for conditionals (else,then)#cond (args)
// TODO: we can not rely on the structure of the extract (it might be a nested extract)
for (auto callee_def : ex->tuple()->projs()) {
// dissect the tuple of lambdas
auto callee = callee_def->as_nom<Lam>();
// each callees type should agree with the argument type (should be checked by type checking).
// Especially, the number of vars should be the number of arguments.
// TODO: does not hold for complex arguments that are not tuples.
assert(callee->num_vars() == app->num_args());
for (size_t i = 0, e = callee->num_vars(); i != e; ++i) {
// emits the arguments one by one (TODO: handle together like before)
if (auto arg = emit_unsafe(app->arg(i)); !arg.empty()) {
auto phi = callee->var(i);
assert(!match<mem::M>(phi->type()));
lam2bb_[callee].phis[phi].emplace_back(arg, id(lam, true));
locals_[phi] = id(phi);
}
}
}

auto c = emit(ex->index());
if (ex->tuple()->num_projs() == 2) {
Expand Down Expand Up @@ -344,9 +362,8 @@ void Emitter::emit_epilogue(Lam* lam) {

std::vector<std::string> args;
auto app_args = app->args();
for (auto arg : app_args.skip_back()) {
for (auto arg : app_args.skip_back())
if (auto v_arg = emit_unsafe(arg); !v_arg.empty()) args.emplace_back(convert(arg->type()) + " " + v_arg);
}

if (app->args().back()->isa<Bot>()) {
// TODO: Perhaps it'd be better to simply η-wrap this prior to the BE...
Expand Down Expand Up @@ -725,8 +742,6 @@ std::string Emitter::emit_bb(BB& bb, const Def* def) {
auto [v_i, t_i] = emit_gep_index(i);

return bb.assign(name, "getelementptr inbounds {}, {} {}, i64 0, {} {}", t_pointee, t_ptr, v_ptr, t_i, v_i);
} else if (match<core::trait>(def)) {
unreachable();
} else if (auto malloc = match<mem::malloc>(def)) {
declare("i8* @malloc(i64)");

Expand Down
1 change: 1 addition & 0 deletions dialects/direct/passes/cps2ds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void CPS2DS::rewrite_lam(Lam* lam) {
}

const Def* CPS2DS::rewrite_body(const Def* def) {
if (!def) return nullptr;
if (auto i = rewritten_.find(def); i != rewritten_.end()) return i->second;
auto new_def = rewrite_body_(def);
rewritten_[def] = new_def;
Expand Down
26 changes: 26 additions & 0 deletions dialects/matrix/matrix.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#include "dialects/matrix/matrix.h"

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

#include "dialects/compile/passes/internal_cleanup.h"
#include "dialects/matrix/passes/lower_matrix_highlevel.h"
#include "dialects/matrix/passes/lower_matrix_lowlevel.h"
#include "dialects/matrix/passes/lower_matrix_mediumlevel.h"
#include "dialects/refly/refly.h"

using namespace thorin;

extern "C" THORIN_EXPORT Plugin thorin_get_plugin() {
return {"matrix",
[](Passes& passes) {
register_pass<matrix::lower_matrix_high_level_map_reduce, thorin::matrix::LowerMatrixHighLevelMapRed>(
passes);
register_pass<matrix::lower_matrix_medium_level, thorin::matrix::LowerMatrixMediumLevel>(passes);
register_phase<matrix::lower_matrix_low_level, thorin::matrix::LowerMatrixLowLevel>(passes);
register_pass<matrix::internal_map_reduce_cleanup, thorin::compile::InternalCleanup>(passes,
INTERNAL_PREFIX);
},
nullptr, [](Normalizers& normalizers) { matrix::register_normalizers(normalizers); }};
}
31 changes: 31 additions & 0 deletions dialects/matrix/matrix.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <thorin/pass/pipelinebuilder.h>
#include <thorin/world.h>

#include "dialects/matrix/autogen.h"
#include "dialects/mem/mem.h"

namespace thorin::matrix {

#define INTERNAL_PREFIX "internal_mapRed_"

/// %mat.zero: Π [n: .Nat, S: «n; .Nat», m: .Nat] -> %mat.Mat (n,S,(.Idx m));
inline const Def* zero_int(World& w, Ref n, Ref S, Ref mem, nat_t m) {
// TODO: use thorin definition by name
return w.app(w.ax<matrix::constMat>(), {n, S, w.type_idx(m), mem, w.lit_idx(m, 0)});
}

inline const Def* op_read(Ref mem, Ref matrix, Ref idx) {
auto& world = matrix->world();
auto mat_ty = match<Mat>(matrix->type());
if (!mat_ty) return matrix;
assert(mat_ty);
world.DLOG("matrix read: {}[{}]", matrix, idx);
world.DLOG(" matrix type: {}", matrix->type());
auto [n, S, T] = mat_ty->args<3>();
world.DLOG(" (n,S,T): {}, {}, {}", n, S, T);
return world.app(world.app(world.ax<read>(), {n, S, T}), {mem, matrix, idx});
}

NeuralCoder3 marked this conversation as resolved.
Show resolved Hide resolved
} // namespace thorin::matrix
Loading