Description
If a function returns a static array or vector, the AutoMooncake backend errors
using StaticArrays
using DifferentiationInterface
using ForwardDiff
using Mooncake
function MWE(x::AbstractVector)
z = SVector{3}(x.^2)
return z
end
test = rand(3)
f_ad, df_ad = value_and_jacobian(
MWE,
AutoMooncake(; config=nothing),
test
)
f_ad, df_ad = value_and_jacobian(
MWE,
AutoForwardDiff(),
test
)
Gives the error
ERROR: MethodError: no method matching copyto!(::Mooncake.Tangent{@NamedTuple{data::Tuple{Float64, Float64, Float64}}}, ::SVector{3, Float64})
The functioncopyto!
exists, but no method is defined for this combination of argument types.Closest candidates are:
copyto!(::IndexStyle, ::AbstractArray, ::IndexStyle, ::AbstractArray)
@ Base abstractarray.jl:1064
copyto!(::Zygote.Buffer, ::Any)
@ Zygote C:\Users\jmurp.julia\packages\Zygote\nyzjS\src\tools\buffer.jl:54
copyto!(::PermutedDimsArray, ::AbstractArray)
@ Base permuteddimsarray.jl:295
...Stacktrace:
[1] copyto!!(dst::Mooncake.Tangent{@NamedTuple{data::Tuple{Float64, Float64, Float64}}}, src::SVector{3, Float64})
@ DifferentiationInterfaceMooncakeExt C:\Users\jmurp.julia\packages\DifferentiationInterface\gSdHF\ext\DifferentiationInterfaceMooncakeExt\DifferentiationInterfaceMooncakeExt.jl:29
[2] value_and_pullback(::Function, ::DifferentiationInterfaceMooncakeExt.MooncakeOneArgPullbackPrep{…}, ::AutoMooncake{…}, ::Vector{…}, ::Tuple{…})
@ DifferentiationInterfaceMooncakeExt C:\Users\jmurp.julia\packages\DifferentiationInterface\gSdHF\ext\DifferentiationInterfaceMooncakeExt\onearg.jl:35
[3] prepare_pullback(::Function, ::AutoMooncake{Nothing}, ::Vector{Float64}, ::Tuple{SVector{3, Float64}})
@ DifferentiationInterfaceMooncakeExt C:\Users\jmurp.julia\packages\DifferentiationInterface\gSdHF\ext\DifferentiationInterfaceMooncakeExt\onearg.jl:22
[4] _prepare_jacobian_aux(::DifferentiationInterface.PushforwardSlow, ::DifferentiationInterface.BatchSizeSettings{…}, ::SVector{…}, ::Tuple{…}, ::AutoMooncake{…}, ::Vector{…})
@ DifferentiationInterface C:\Users\jmurp.julia\packages\DifferentiationInterface\gSdHF\src\first_order\jacobian.jl:167
[5] prepare_jacobian(::typeof(MWE), ::AutoMooncake{Nothing}, ::Vector{Float64})
@ DifferentiationInterface C:\Users\jmurp.julia\packages\DifferentiationInterface\gSdHF\src\first_order\jacobian.jl:108
[6] value_and_jacobian(::typeof(MWE), ::AutoMooncake{Nothing}, ::Vector{Float64})
@ DifferentiationInterface C:\Users\jmurp.julia\packages\DifferentiationInterface\gSdHF\src\fallbacks\no_prep.jl:60
[7] top-level scope
@ c:\Users\jmurp.julia\dev\SatelliteToolboxGravityModels\test\differentiability.jl:69
Some type information was truncated. Useshow(err)
to see complete types.