Conversation
| v, pb = _rrule(sc, argv, paramsv, _returns_scalar(sc)) | ||
| return v, Δ -> begin | ||
| _Δ = Base.tail(pb(collect(Δ))) | ||
| _Δ = Base.tail(pb(collect(Δ))) |
There was a problem hiding this comment.
If you comment this line out, you get the correct gradient. deepcopying everything didn't fix this so I am not sure what's going on.
There was a problem hiding this comment.
So call it once, it works. Call it twice, it breaks.
There was a problem hiding this comment.
deepcopy isn't likely to help on pointers.
There was a problem hiding this comment.
perhaps the _rrule function should be a struct which stores the initial pointer address and starts from there every time it's called
|
I would suggest taking this approach: That is, in Julia versions without package extensions, LoopVectorization.jl loads the extension files. I think it'd make sense to give |
|
yes I will do that as soon as it works well |
| offset += 1 | ||
| else | ||
| l = length(y) | ||
| v[offset + 1 : offset + l] = vec(y) |
There was a problem hiding this comment.
Note that vec allocates if !isa(y,AbstractVector)
This looks performance sensitive. Could use an @inbounds?
But also, why?
This seems internal. We should probably only be rruling relatively high level SimpleChains calls, that hide things like params getting called?
There was a problem hiding this comment.
It was called in the log prior calculation.
This PR implements ReverseDiff support which uncovered a spooky bug. Here is a reproducer that gives a wrong gradient. I will explain the spooky part and how to get the correct gradient in a comment.