Skip to content

Need adjoint for reinterpret SVector #606

Open
@jenkspt

Description

@jenkspt

Minimum working example:

f(x) = sum(sum(reinterpret(SVector{size(x, 1), eltype(x)}, x)))
Zygote.gradient(f, rand(3, 10))
ERROR: Need an adjoint for constructor Base.ReinterpretArray{SVector{3, Float64}, 2, Float64, Matrix{Float64}, false}. Gradient is of type FillArrays.Fill{FillArrays.Fill{Float64, 1, Tuple{Base.OneTo{Int64}}}, 2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] (::Zygote.Jnew{Base.ReinterpretArray{SVector{3, Float64}, 2, Float64, Matrix{Float64}, false}, Nothing, false})(Δ::FillArrays.Fill{FillArrays.Fill{Float64, 1, Tuple{Base.OneTo{Int64}}}, 2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}})
   @ Zygote ~/.julia/packages/Zygote/ajuwN/src/lib/lib.jl:323
 [3] (::Zygote.var"#1811#back#235"{Zygote.Jnew{Base.ReinterpretArray{SVector{3, Float64}, 2, Float64, Matrix{Float64}, false}, Nothing, false}})(Δ::FillArrays.Fill{FillArrays.Fill{Float64, 1, Tuple{Base.OneTo{Int64}}}, 2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}})
   @ Zygote ~/.julia/packages/ZygoteRules/AIbCs/src/adjoint.jl:67
 [4] Pullback
   @ ./reinterpretarray.jl:47 [inlined]
 [5] (::typeof(∂(reinterpret)))(Δ::FillArrays.Fill{FillArrays.Fill{Float64, 1, Tuple{Base.OneTo{Int64}}}, 2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}})
   @ Zygote ~/.julia/packages/Zygote/ajuwN/src/compiler/interface2.jl:0
 [6] Pullback
   @ ./REPL[95]:1 [inlined]
 [7] (::Zygote.var"#52#53"{typeof(∂(f))})(Δ::Float64)
   @ Zygote ~/.julia/packages/Zygote/ajuwN/src/compiler/interface.jl:41
 [8] gradient(::Function, ::Matrix{Float64}, ::Vararg{Any})
   @ Zygote ~/.julia/packages/Zygote/ajuwN/src/compiler/interface.jl:76
 [9] top-level scope
   @ REPL[98]:1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions