Below is the smallest possible function that exhibits what I think is the error. The error message is even more daunting, but at least the top row is clear: βMutating arrays is not supportedβ. The recursion was my attempt at not mutating arrays, but apparently it does not work that way.
using Pkg
pkg"activate ."
using Zygote
function S1(x)
d = length(x)
t = x[1:1]
for idx = 2:d
t = recu(t, x[idx])
end
sum(t)
end
function recu(t, x)
[t x]
end
x = collect(1.0:10)
S1(x)
gradient(S1, x)
ERROR: LoadError: Mutating arrays is not supported
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] (::getfield(Zygote, Symbol("##794#795")))(::Nothing) at /julia/packages/Zygote/bdE6T/src/lib/array.jl:37
[3] (::getfield(Zygote, Symbol("##2100#back#796")){getfield(Zygote, Symbol("##794#795"))})(::Nothing) at /julia/packages/ZygoteRules/Jn4LO/src/adjoint.jl:48
[4] fill! at ./multidimensional.jl:839 [inlined]
[5] (::typeof(β(fill!)))(::Nothing) at /julia/packages/Zygote/bdE6T/src/compiler/interface2.jl:0
[6] __cat at ./abstractarray.jl:1412 [inlined]
[7] (::typeof(β(Base.__cat)))(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/Zygote/bdE6T/src/compiler/interface2.jl:0
[8] (::getfield(Zygote, Symbol("##143#144")){typeof(β(Base.__cat)),Tuple{Tuple{Nothing,Nothing,Nothing},Tuple{Nothing,Nothing}}})(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/Zygote/bdE6T/src/lib/lib.jl:132
[9] (::getfield(Zygote, Symbol("##274#back#145")){getfield(Zygote, Symbol("##143#144")){typeof(β(Base.__cat)),Tuple{Tuple{Nothing,Nothing,Nothing},Tuple{Nothing,Nothing}}}})(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/ZygoteRules/Jn4LO/src/adjoint.jl:48
[10] _cat_t at ./abstractarray.jl:1392 [inlined]
[11] (::getfield(Zygote, Symbol("##143#144")){typeof(β(Base._cat_t)),Tuple{Tuple{Nothing,Nothing},Tuple{Nothing,Nothing}}})(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/Zygote/bdE6T/src/lib/lib.jl:132
[12] #143 at /julia/packages/ZygoteRules/Jn4LO/src/adjoint.jl:48 [inlined]
[13] (::getfield(Zygote, Symbol("##274#back#145")){getfield(Zygote, Symbol("##143#144")){typeof(β(Base.#cat_t#103)),Tuple{Tuple{Nothing,Nothing,Nothing},Tuple{Nothing,Nothing}}}})(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/ZygoteRules/Jn4LO/src/adjoint.jl:48
[14] #cat_t at /julia/packages/Zygote/bdE6T/src/compiler/interface2.jl:0 [inlined]
[15] (::typeof(β(getfield(Base, Symbol("#kw##cat_t"))())))(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/Zygote/bdE6T/src/compiler/interface2.jl:0
[16] (::getfield(Zygote, Symbol("##143#144")){typeof(β(getfield(Base, Symbol("#kw##cat_t"))())),Tuple{Tuple{Nothing,Nothing,Nothing},Tuple{Nothing,Nothing}}})(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/Zygote/bdE6T/src/lib/lib.jl:132
[17] #274#back at /julia/packages/ZygoteRules/Jn4LO/src/adjoint.jl:48 [inlined]
[18] _cat at ./abstractarray.jl:1382 [inlined]
[19] (::typeof(β(Base._cat)))(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/Zygote/bdE6T/src/compiler/interface2.jl:0
[20] (::getfield(Zygote, Symbol("##143#144")){typeof(β(Base._cat)),Tuple{Tuple{Nothing},Tuple{Nothing,Nothing}}})(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/Zygote/bdE6T/src/lib/lib.jl:132
[21] #143 at /julia/packages/ZygoteRules/Jn4LO/src/adjoint.jl:48 [inlined]
[22] (::getfield(Zygote, Symbol("##274#back#145")){getfield(Zygote, Symbol("##143#144")){typeof(β(Base.#cat#104)),Tuple{Tuple{Nothing,Nothing},Tuple{Nothing,Nothing}}}})(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/ZygoteRules/Jn4LO/src/adjoint.jl:48
[23] #cat at /julia/packages/Zygote/bdE6T/src/compiler/interface2.jl:0 [inlined]
[24] (::typeof(β(getfield(Base, Symbol("#kw##cat"))())))(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/Zygote/bdE6T/src/compiler/interface2.jl:0
[25] (::getfield(Zygote, Symbol("##143#144")){typeof(β(getfield(Base, Symbol("#kw##cat"))())),Tuple{Tuple{Nothing,Nothing},Tuple{Nothing,Nothing}}})(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/Zygote/bdE6T/src/lib/lib.jl:132
[26] #274#back at /julia/packages/ZygoteRules/Jn4LO/src/adjoint.jl:48 [inlined]
[27] hcat at ./abstractarray.jl:1491 [inlined]
[28] (::typeof(β(hcat)))(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/Zygote/bdE6T/src/compiler/interface2.jl:0
[29] recu at quicktest.jl:19 [inlined]
[30] (::typeof(β(recu)))(::FillArrays.Fill{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) at /julia/packages/Zygote/bdE6T/src/compiler/interface2.jl:0
[31] S1 at quicktest.jl:12 [inlined]
[32] (::typeof(β(S1)))(::Float64) at /julia/packages/Zygote/bdE6T/src/compiler/interface2.jl:0
[33] (::getfield(Zygote, Symbol("##32#33")){typeof(β(S1))})(::Float64) at /julia/packages/Zygote/bdE6T/src/compiler/interface.jl:38
[34] gradient(::Function, ::Array{Float64,1}) at /julia/packages/Zygote/bdE6T/src/compiler/interface.jl:47
[35] top-level scope at none:0
[36] include at ./boot.jl:326 [inlined]
[37] include_relative(::Module, ::String) at ./loading.jl:1038
[38] include(::Module, ::String) at ./sysimg.jl:29
[39] exec_options(::Base.JLOptions) at ./client.jl:267
[40] _start() at ./client.jl:436
in expression starting at quicktest.jl:24