JuliaArrays / FillArrays.jl

Julia package for lazily representing matrices filled with a single entry
https://juliaarrays.github.io/FillArrays.jl/
MIT License
181 stars 39 forks source link

PaddedViews does not support Zygote.gradient? #367

Closed chooron closed 1 month ago

chooron commented 1 month ago

I have a matrix that I want to fill with 0 values ​​using PaddedViews.jl: f2 = x -> sum(PaddedView(eltype(x)(0.0), x, (5, 5))) But when using zygote to calculate the gradient:

arr = collect(reshape(1:9, 3, 3))
Zygote.gradient(f2, arr)

The following error occurs: ERROR: Need an adjoint for constructor PaddedView{Int64, 2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, Matrix{Int64}}. Gradient is of type FillArrays.Fill{Int64, 2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}} This bug seems similar to #483

dlfivefifty commented 1 month ago

Shouldn't this issue be in PaddedViews.jl?

chooron commented 1 month ago

Sure, please see #69