Skip to content

infinite recursion of to_vec for wrapped arrays #141

Open
@CarloLucibello

Description

@CarloLucibello

I didn't look at the implementation details of to_vec but I wanted to report a bug we encountered in
FluxML/NNlib.jl#272 when applying to_vec to a custom array wrapper.

142
AutoDiff: Error During Test at /home/runner/work/NNlib.jl/NNlib.jl/test/batchedmul.jl:235
143
  Got exception outside of a @test
144
  StackOverflowError:
145
  Stacktrace:
146
       [1] to_vec(x::BatchedAdjoint{Float64, Array{Float64, 3}})
147
         @ FiniteDifferences ~/.julia/packages/FiniteDifferences/7NROH/src/to_vec.jl:56
148
       [2] to_vec(x::Base.ReshapedArray{Float64, 1, BatchedAdjoint{Float64, Array{Float64, 3}}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}, Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}})
149
         @ FiniteDifferences ~/.julia/packages/FiniteDifferences/7NROH/src/to_vec.jl:69
150
       [3] to_vec(x::BatchedAdjoint{Float64, Array{Float64, 3}})
151
         @ FiniteDifferences ~/.julia/packages/FiniteDifferences/7NROH/src/to_vec.jl:57--- the last 2 lines are repeated 39990 more times ---

We worked around the issue defining:

FiniteDifferences.to_vec(x::BatchedAdjoint) = FiniteDifferences.to_vec(collect(x))

Could this be used as a generic fallback?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions