Skip to content
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

Error with StaticArray of non-isbitstype's #686

Open
marius311 opened this issue Jun 15, 2020 · 1 comment · Fixed by JuliaArrays/StaticArrays.jl#1196
Open

Error with StaticArray of non-isbitstype's #686

marius311 opened this issue Jun 15, 2020 · 1 comment · Fixed by JuliaArrays/StaticArrays.jl#1196

Comments

@marius311
Copy link
Contributor

marius311 commented Jun 15, 2020

This was discussed in #547 (comment) but just wanted to make this issue to track it and to provide a MWE (StaticArrays 0.12.3 / Zygote 0.4.20):

julia> using StaticArrays, Zygote

julia> x = @SVector[ [1,2] ]
1-element SArray{Tuple{1},Array{Int64,1},1,1} with indices SOneTo(1):
 [1, 2]

julia> gradient(x -> sum(x[1]), x)
ERROR: setindex!() with non-isbitstype eltype is not supported by StaticArrays. Consider using SizedArray.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] setindex! at /home/marius/.julia/packages/StaticArrays/mlIi1/src/MArray.jl:99 [inlined]
 [3] macro expansion at /home/marius/.julia/packages/StaticArrays/mlIi1/src/arraymath.jl:105 [inlined]
 [4] _fill! at /home/marius/.julia/packages/StaticArrays/mlIi1/src/arraymath.jl:101 [inlined]
 [5] fill!(::MArray{Tuple{1},Union{Nothing, FillArrays.Fill{Int64,1,Tuple{Base.OneTo{Int64}}}},1,1}, ::Nothing) at /home/marius/.julia/packages/StaticArrays/mlIi1/src/arraymath.jl:99
 [6] _zero(::SArray{Tuple{1},Array{Int64,1},1,1}, ::Type{T} where T) at /home/marius/.julia/packages/Zygote/YeCEW/src/lib/array.jl:52
 [7] (::Zygote.var"#1040#1042"{SArray{Tuple{1},Array{Int64,1},1,1},Tuple{Int64}})(::FillArrays.Fill{Int64,1,Tuple{Base.OneTo{Int64}}}) at /home/marius/.julia/packages/Zygote/YeCEW/src/lib/array.jl:40
 [8] (::Zygote.var"#2739#back#1036"{Zygote.var"#1040#1042"{SArray{Tuple{1},Array{Int64,1},1,1},Tuple{Int64}}})(::FillArrays.Fill{Int64,1,Tuple{Base.OneTo{Int64}}}) at /home/marius/.julia/packages/ZygoteRules/6nssF/src/adjoint.jl:49
 [9] literal_getindex at /home/marius/.julia/packages/Zygote/YeCEW/src/lib/lib.jl:94 [inlined]
 [10] (::typeof((literal_getindex)))(::FillArrays.Fill{Int64,1,Tuple{Base.OneTo{Int64}}}) at /home/marius/.julia/packages/Zygote/YeCEW/src/compiler/interface2.jl:0
 [11] #13 at ./none:1 [inlined]
 [12] (::typeof((#13)))(::Int64) at /home/marius/.julia/packages/Zygote/YeCEW/src/compiler/interface2.jl:0
 [13] (::Zygote.var"#36#37"{typeof((#13))})(::Int64) at /home/marius/.julia/packages/Zygote/YeCEW/src/compiler/interface.jl:46
 [14] gradient(::Function, ::SArray{Tuple{1},Array{Int64,1},1,1}) at /home/marius/.julia/packages/Zygote/YeCEW/src/compiler/interface.jl:55
 [15] top-level scope at none:0

I actually think the fix belongs in StaticArrays: JuliaArrays/StaticArrays.jl#799

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants