-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try mutating Tapir #126
Try mutating Tapir #126
Conversation
@willtebbutt if you have any clues I'm all ears! |
I applied all your suggestions @willtebbutt but now I think Tapir is angry at me because my mutating function returns MethodError: no method matching copy(::Nothing)
function: num_to_arr!
Closest candidates are:
copy(::DataFrames.DataFrame; copycols)
@ DataFrames ~/.julia/packages/DataFrames/58MUJ/src/dataframe/dataframe.jl:805
copy(::IRTools.Inner.Branch)
@ IRTools ~/.julia/packages/IRTools/Q1Ewy/src/ir/ir.jl:73
copy(::LinearAlgebra.Transpose{Bool, BitMatrix})
@ LinearAlgebra ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/bitarray.jl:240
...
Stacktrace:
[1] value_and_pullback!!(::Tapir.DerivedRule{…}, ::Tapir.NoTangent, ::Tapir.CoDual{…}, ::Tapir.CoDual{…}, ::Tapir.CoDual{…})
@ Tapir ~/.julia/packages/Tapir/BqxEi/src/interface.jl:13
[2] value_and_pullback!!(f!::Function, y::Vector{…}, dx::Float64, ::AutoTapir, x::Float64, dy::FillArrays.OneElement{…}, extras::DifferentiationInterfaceTapirExt.TapirMutatingPullbackExtras{…})
@ DifferentiationInterfaceTapirExt ~/Work/GitHub/Julia/DifferentiationInterface.jl/ext/DifferentiationInterfaceTapirExt/mutating.jl:15
[3] (::DifferentiationInterface.var"#5#7"{…})(i::CartesianIndex{…})
@ DifferentiationInterface ~/Work/GitHub/Julia/DifferentiationInterface.jl/src/pushforward.jl:119 |
Ahh okay. That's unfortunate. Perhaps I should be taking a edit: PR here |
Why do you even copy it? |
@willtebbutt you're right compintell/Mooncake.jl#112 makes it no longer error, but the outputs are all wrong (seemingly uninitialized or zero arrays).
|
I need to make a copy because the reverse-pass has to "undo" all of the operations that the forwards-pass applies to any mutable state. For example, this is why you were seeing uninitialised values before I added in
Good point -- I'll probably just need to add my own |
See compintell/Mooncake.jl#113 for the distilled bug on your end / wrong use on mine |
Extensions
First try at mutating functions
f!(y, x) = nothing
with Tapir backend, and it fails due to a mismatched tangent type.