Conversation
|
I get a failure on |
|
This is great! One important thing to do is to make sure it works all the way through Cgen. Another thing is that there are lots of small administrative changes that should be split off and submitted in separate commits (if not a separate PR). I'm happy to take action on those. |
|
And re tangent types: [Monday 2:31 PM] Tom Ellis [Monday 5:05 PM] Andrew Fitzgibbon [Monday 5:09 PM] Simon Peyton Jones [Monday 5:18 PM] Tom Ellis [Monday 8:58 PM] Andrew Fitzgibbon |
OK. But it would really help to have a Note with this code in Prim.hs making some of these points. I tripped up on this when thinking "is it ok to add two tangent types with 'add'"? |
Aha, and that's exactly where we are precise about tangentType -- we can prove there that ``tangentType . tangentType = tangentType` |
Yes, it knows about build, but not about sumbuild. In the old AD setup we had I suppose I can add that to the conversion from ksc -> categories |
|
Hi @simonpj, I'm seeing a strange error. Sometimes variable names come out as numbers without any alphabetic prefix which is invalid in our C++ and Futhark backends, as one might expect. I don't have any idea how to track this down. Do you have a suggestion of where to look? |
|
The command line to reproduce is |
Oh dear! Apparently I introduced a bug in I hope that unsticks you. |
|
Thanks Simon. The change in behaviour to |
|
Can we use something noisier e.g. |
Purely cosmetic! I just got tired of seeing lots of underscores :-). No more than that. |
|
Thanks Simon, good to know. |
|
Sorry, I said |
| parensIf ctxt inner doc | ctxt >= inner = parens doc | ||
| | otherwise = doc | ||
| parensIf ctxt inner doc | ctxt > inner = parens doc | ||
| | otherwise = doc |
There was a problem hiding this comment.
@simonpj: I'm curious about this change. Is it intended to make the pretty-printed syntax less noisy? The change actually breaks the Futhark code generator (because it uses the pretty-printing machinery here). Do you mind if I revert this change?
There was a problem hiding this comment.
Hmm. Maybe I made a mistake. Where the precedence is equal we probably do want parens. But what about
let x = e in let y = e2 in ...
we don't really want parens around that inner let.
What's the example that breaks? Just so we can see.
We can revert and lets see if strange things happen.
There was a problem hiding this comment.
One thing that breaks is the Futhark code generated for the below code from prelude.ks. With > in the precedence the condition doesn't fire and the Futhark comes out looking like
neg div (mul x1 d_ddiv) (mul x2 x2)
instead of
neg (div (mul x1 d_ddiv) (mul x2 x2))
https://github.com/microsoft/knossos-ksc/blob/master/src/runtime/prelude.ks#L87-L88
| (toCLExpr (tv:env) body) | ||
|
|
||
| to_cl_expr NotPruned env e = prune env e | ||
| to_cl_expr Pruned _ e = pprPanic "toCLExpr" (ppr e) |
There was a problem hiding this comment.
I'm hitting this a lot in the test suite. Is it something that is yet to be implemented?
There was a problem hiding this comment.
The Let case looks odd. I think it should be
to_cl_expr Pruned env (Let tv rhs body)
= CLLet (tVarName tv)
(toCLExpr env rhs)
(toCLExpr (tv:env) body)
There was a problem hiding this comment.
On what expressions?
On any assert or any lam that's not part of a build (i.e. the ones that are part of sumbuild or fold).
There was a problem hiding this comment.
OK, I fixed the let and pushed, along with a few other small changes that shouldn't interfere with anything you're doing.
|
pushed where? spj/conal? |
Ah yes, well, we can't deal with lambdas in general. I have not yet done sumbuild or fold. For sumbuild in AD.hs we just expand it back to sum of build; I suppose we can do that here too. Fold is still to-do. I have not thought about assert. Not sure if it's worth trying to round trip it through CL. Do you have a view? |
Yes |
|
Thanks for pushing the rebased version, Simon. For the record the old branch was at 62f3156. |
| , i <= length arg_tys | ||
| , n == length arg_tys | ||
| = Right (arg_tys !! (i - 1)) | ||
| selCallResultTy_maybe _ _ _ = Left (text "Bad argument to selector") |
There was a problem hiding this comment.
Is this change actually needed? It doesn't seem so, given the change to pSel above. pSel itself now checks whether it's being applied at a "tuple size" of 1 and if so assumes it was given the actual value, not a singleton tuple containing the value.
If we can do without this change I would prefer it. I'm rather wary of treating T and TypeTuple [T] as the same thing.
|
@simonpj: |
|
I've succeeded in splitting this up into smaller pieces so that I can understand it. It's on I'm comfortable with everything that's going on in the PR except treating 1-tuples as though they are the same as the thing they wrap. I worry that this may cause us headaches down the line. In particular, our backends do not make this conflation. Is it really necessary? It's the kind of thing I would be keen not to invoke unless there's no alternative. |
Agree that there's an important question here. I believe that it will probably force us to say that semantically So yes, it would be nice to see if we can work with |
I think it's entirely unnecessary. I think at one point I explored that route and then discarded it but failed to remove the code. Thanks for splitting up. I'll adopt your patches. |
since they are alphanumeric, not operators
I'm not exactly sure what this does
to reduce clutter
Specifically, bring it up to date with CatLang.
...that is without wrapping a 'c'. * I have not propagated this to the AD parts, which are now commented out. * I wonder about undoing one-arg! * Still messy around the tuple-flattening business. I'm not happy about this yet.
|
Where are we on this? |
|
branch Still needed if we want to push this further
Tom has yet a new approach (with explicit fork and join constructs) which may be better still, so it's not clear to me whether we should push the the categorical approach further or purse Tom's, or both in parallel. |
From @simonpj :
I believe [Elliot-style AD] is all working nicely now.
To run it, use Ksc.Pipeline.demoCL “ex10”, or choose your own example. It adds the Prelude automatically.
Ksc.Pipeline.demoF BasicAD ["src/runtime/prelude.ks","test/ksc/ex10.ks"]ex10demonstrates a major advantage of the Elliot approach: inrev$g, in reverse mode BasicAD we currently get two calls torev$f. They have different arguments and cannot be CSE’d. But with the Elliott approach we can the argument before callingrev$f, so we get just one call.I’d be interested in any observations you might have.
Next: splitting for reverse mode.
Some other points: