ReverseDiff.jl icon indicating copy to clipboard operation
ReverseDiff.jl copied to clipboard

MethodError: vcat(::ReverseDiff.TrackedArray{Float32, Float32, 2, Matrix{Float32}, Matrix{Float32}}, ::Matrix{Float32}) is ambiguous.

Open prbzrg opened this issue 2 years ago • 4 comments

I get this error on Julia 1.10, it's working on Julia 1.9 or if I use cat(...; dims=1) instead.

  MethodError: vcat(::ReverseDiff.TrackedArray{Float32, Float32, 2, Matrix{Float32}, Matrix{Float32}}, ::Matrix{Float32}) is ambiguous.
  
  Candidates:
    vcat(x::ReverseDiff.TrackedArray{V, D, 2} where {V, D}, xs::AbstractMatrix...)
      @ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:53
    vcat(X::Union{Number, AbstractVecOrMat{<:Number}}...)
      @ SparseArrays /opt/hostedtoolcache/julia/1.10.0-beta3/x64/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:1229
    vcat(x::ReverseDiff.TrackedArray{V, D, 2} where {V, D}, xs::AbstractVecOrMat...)
      @ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:53
  
  Possible fix, define
    vcat(::ReverseDiff.TrackedArray{V, D, 2} where {V, D}, ::Vararg{AbstractMatrix{<:Number}})
  

https://github.com/impICNF/ContinuousNormalizingFlows.jl/actions/runs/6660418729/job/18101501796#step:5:18373

prbzrg avatar Oct 27 '23 20:10 prbzrg

    vcat(X::Union{Number, AbstractVecOrMat{<:Number}}...)

This method signature seems pretty bad, it's incredibly generic and even covers vcat(). Maybe this is actually a SparseArrays issue?

devmotion avatar Oct 30 '23 14:10 devmotion

Yes, I agree. But I think arrays should have an eltype in the definitions. e.g. AbstractMatrix{<:Real}.

https://github.com/JuliaDiff/ReverseDiff.jl/blob/b669294586b0789ab10bbda223543bcec64cf8aa/src/derivatives/arrays.jl#L43-L54

prbzrg avatar Oct 30 '23 15:10 prbzrg

CI failed too. so I close the PR. https://github.com/JuliaDiff/ReverseDiff.jl/actions/runs/6694385459/job/18187563784?pr=244#step:6:549

prbzrg avatar Oct 30 '23 15:10 prbzrg

The original error is fixed now, but I'm getting a new error somewhere else in my codes:

  MethodError: vcat(::ReverseDiff.TrackedArray{Float32, Float32, 2, Matrix{Float32}, Matrix{Float32}}, ::Matrix{ReverseDiff.TrackedReal{Float32, Float32, ReverseDiff.TrackedArray{Float32, Float32, 2, Matrix{Float32}, Matrix{Float32}}}}) is ambiguous.
  
  Candidates:
    vcat(x::ReverseDiff.TrackedArray{V, D, 2} where {V, D}, xs::AbstractMatrix...)
      @ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:53
    vcat(X1::Union{Number, AbstractVecOrMat{<:Number}}, X::Union{Number, AbstractVecOrMat{<:Number}}...)
      @ SparseArrays /opt/hostedtoolcache/julia/1.10.0/x64/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:1235
    vcat(x::ReverseDiff.TrackedArray{V, D, 2} where {V, D}, xs::AbstractVecOrMat...)
      @ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:53
  
  Possible fix, define
    vcat(::ReverseDiff.TrackedArray{V, D, 2} where {V, D}, ::Vararg{AbstractMatrix{<:Number}})
  

prbzrg avatar Jan 18 '24 14:01 prbzrg