AnyDSL / MimIR

MimIR is my Intermediate Representation
https://anydsl.github.io/MimIR/
MIT License
46 stars 9 forks source link

Closure Conversion - higher order return #117

Open NeuralCoder3 opened 2 years ago

NeuralCoder3 commented 2 years ago
1E) '([], ((.Idx 4294967296, aug_pow_else_745690_660849_352178, _660885_351873):closure_type_352061, ([], aug_pow_then_745900_661112_352340, ()):closure_type_352416)#_352541#2:(.Idx 3))' of type 
2E) '      (.Idx 4294967296, aug_pow_else_745690_660849_352178, _660885_351873):closure_type_352061, ([], aug_pow_then_745900_661112_352340, ()):closure_type_352416)#_352541#1:(.Idx 3)' of domain 

1T) '[★,                   ((.Idx 4294967296, aug_pow_else_745690_660849_352178, _660885_351873):closure_type_352061, ([], aug_pow_then_745900_661112_352340, ()):closure_type_352416)#_352541#0:(.Idx 3)]' to 
2T) '[closure_type_352015, ((.Idx 4294967296, aug_pow_else_745690_660849_352178, _660885_351873):closure_type_352061,  ([], aug_pow_then_745900_661112_352340, ()):closure_type_352416)#_352541#0:(.Idx 3)]'
      ^ only here

This behavior is exhibited for instance in pow_autodiff_eval_filter2_eval.thorin.

The program is a differentiated version of pow and as such a minimal recursive function that folds continuations inside each other in the return continuation.

leissa commented 2 years ago

Was this the issue where several closures end up in the same slot?

NeuralCoder3 commented 2 years ago

Was this the issue where several closures end up in the same slot?

The issue might be related. At least the starting position is similar. But for the same slot issue, thorin/closure conv was at least able to

Only the execution failed.

In the example above, already the thorin code optimization fails.

NeuralCoder3 commented 2 years ago

Was this the issue where several closures end up in the same slot?

I opened #118 for the other issue.

leissa commented 1 year ago

I'm pretty sure it's a duplicate of #126 but rn I get:

error: cannot pass argument '(.insert (%autodiff.zero «2; .Idx 4294967296», 0:(.Idx 2), s_473244), _473271)' of type '[«2; .Idx 4294967296», .Cn .Idx 4294967296]' to 'id_pb_471440' of domain '[«2; .Idx 4294967296», .Cn «2; .Idx 4294967296»]'
NeuralCoder3 commented 1 year ago

This program should not need autodiff to run. I run it with

./build/bin/thorin -o - -VVVV -d clos lit/autodiff/pow_autodiff_eval2.thorin.disabled

to get the issue.

The behavior displayed in your case might be another unrelated bug in autodiff or direct. (Although I get another error related to curried function specialization)

NeuralCoder3 commented 1 year ago

Maybe helpful: clos/pow_ad_eval_simpl.thorin (only clos dialect) and pow_autodiff.thorin (also ad,direct) experience the same problem. (I am not if it was always that way or if this test worked at some point.)

NeuralCoder3 commented 1 year ago

I'm pretty sure it's a duplicate of #126 but rn I get:

error: cannot pass argument '(.insert (%autodiff.zero «2; .Idx 4294967296», 0:(.Idx 2), s_473244), _473271)' of type '[«2; .Idx 4294967296», .Cn .Idx 4294967296]' to 'id_pb_471440' of domain '[«2; .Idx 4294967296», .Cn «2; .Idx 4294967296»]'

Even when adding the memory by hand, errors still occur.

I added some more tests with the manual placement of mem to ad_ptr_merge (I figured that is the branch with the most advanced closure conversion -- but I might be wrong). The files are lit/clos/pow_ad_eval_simpl[*].thorin