Closed wazizian closed 2 years ago
This seems related to a Zygote bug, for which I don't remember the reference. Replacing i = x
with i = identity(x)
avoids the problem:
function f2(x)
i = identity(x)
while i > 0
i -= 1
end
return x
end
passthrough(f2, 1) == f2(1) == 1
function g2(y)
return f2(1) * y
end
gradient(g2, 1) == (1.0,)
My belief is that this is an IRTools problem, which would be great to solve!
Hi, I encountered an issue with
IRTools
which can be reduced to the following exampleBut, with both Julia 1.7.1 and 1.8 (see versions below), this outputs
Moreover, this also translates into a Zygote issue
which gives
I am open to investigating this issue further but I am a bit clueless right now. In particular, I am not sure whether it is a Julia or IRTools issue, and if it is a Julia issue, of where to start.
Thank you in advance for your help (and thank you for publishing IRTools !), Cheers, Waïss
How I arrived at this MWE
I began by investigating an incorrect behavior in the
string
function. Indeed, when a@dynamo
is used, the functionwrite(io::IO, s::String)
do not correctly updateio.ptr
. I narrowed it down to the variablewritten
inunsafe_write
(here and called there) being incorrectly decreased in thewhile
loop, akin to what happens in the example above.Version info
I reproduced this bug on both Julia 1.7.1 and Julia 1.8 nightly.
(Edit: fix code formatting)