thorin2 icon indicating copy to clipboard operation
thorin2 copied to clipboard

Closure Conversion - higher order return

Open NeuralCoder3 opened this issue 2 years ago • 7 comments

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.

NeuralCoder3 avatar Oct 14 '22 12:10 NeuralCoder3

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

leissa avatar Oct 14 '22 12:10 leissa

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

  • generate thorin code
  • generate llvm code

Only the execution failed.

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

NeuralCoder3 avatar Oct 14 '22 12:10 NeuralCoder3

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

I opened #118 for the other issue.

NeuralCoder3 avatar Oct 14 '22 12:10 NeuralCoder3

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»]'

leissa avatar Oct 25 '22 15:10 leissa

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 avatar Oct 26 '22 06:10 NeuralCoder3

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 avatar Oct 26 '22 07:10 NeuralCoder3

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

NeuralCoder3 avatar Nov 03 '22 09:11 NeuralCoder3