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

create_array(::Type{ReshapedArray}, ...) doesn't work #644

Open
jariji opened this issue Aug 31, 2024 · 2 comments · May be fixed by #679
Open

create_array(::Type{ReshapedArray}, ...) doesn't work #644

jariji opened this issue Aug 31, 2024 · 2 comments · May be fixed by #679

Comments

@jariji
Copy link

jariji commented Aug 31, 2024

LoadError: MethodError: no method matching create_array(::Type{Base.ReshapedArray{Num, 1, Symbolics.Arr{Num, 2}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}}}, ::Nothing, ::Val{1}, ::Val{(6,)}, ::Num, ::Num, ::Num, ::Num, ::Num, ::Num)

Closest candidates are:
  create_array(::Type{<:Array}, ::Any, ::Val, ::Val, ::Any...)
   @ SymbolicUtils ~/.julia/packages/SymbolicUtils/iH1dT/src/code.jl:498
  create_array(::Type{<:Array}, ::Nothing, ::Val, ::Val{dims}, ::Any...) where dims
   @ SymbolicUtils ~/.julia/packages/SymbolicUtils/iH1dT/src/code.jl:502
  create_array(::Type{<:Array}, ::Nothing, ::Val{1}, ::Val{dims}, ::Any...) where dims
   @ SymbolicUtils ~/.julia/packages/SymbolicUtils/iH1dT/src/code.jl:509
  ...
@benedict-96
Copy link

benedict-96 commented Dec 6, 2024

I have the same problem and, unfortunately, adding this doesn't seem to fix it:

function create_array(::Type{<:Base.ReshapedArray{T, N, P}}, S, nd::Val, d::Val, elems...) where {T, N, P}
    create_array(P, S, nd, d, elems...)
end

In that case I just get:

ERROR: MethodError: no method matching create_array(::Type{Symbolics.Arr{Symbolics.Num, 1}}, ::Nothing, ::Val{2}, ::Val{(2, 1)}, ::Symbolics.Num, ::Symbolics.Num)
The function `create_array` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  create_array(::Type{<:Base.ReshapedArray{T, N, P}}, ::Any, ::Val, ::Val, ::Any...) where {T, N, P}
   @ GeometricMachineLearning ~/Documents/GeometricMachineLearning/src/pullbacks/zygote_pullback.jl:42
  create_array(::Type{<:SubArray{T, N, P, I, L}}, ::Any, ::Val, ::Val, ::Any...) where {T, N, P, I, L}
   @ SymbolicUtils ~/.julia/packages/SymbolicUtils/jf8aQ/src/code.jl:546
  create_array(::Type{<:Array}, ::Any, ::Val, ::Val, ::Any...)
   @ SymbolicUtils ~/.julia/packages/SymbolicUtils/jf8aQ/src/code.jl:498
  ...

Stacktrace:
  [1] create_array(::Type{Base.ReshapedArray{…}}, ::Nothing, ::Val{2}, ::Val{(2, 1)}, ::Symbolics.Num, ::Vararg{Symbolics.Num})
    @ GeometricMachineLearning ~/Documents/GeometricMachineLearning/src/pullbacks/zygote_pullback.jl:43
  [2] macro expansion
    @ ./none:8 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/RuntimeGeneratedFunctions/M9ZX8/src/RuntimeGeneratedFunctions.jl:163 [inlined]
  [4] macro expansion
    @ ./none:0 [inlined]
  [5] generated_callfunc
    @ ./none:0 [inlined]
  [6] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{…})(::Base.ReshapedArray{…}, ::NeuralNetworkParameters{…}, ::Int64)
    @ RuntimeGeneratedFunctions ~/.julia/packages/RuntimeGeneratedFunctions/M9ZX8/src/RuntimeGeneratedFunctions.jl:150
  [7] (::SymbolicNeuralNetworks.var"#15#17"{Base.ReshapedArray{}, NeuralNetworkParameters{}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{}})(k::Int64)

Maybe RuntimeGeneratedFunctions has problems when used together with ReshapedArrays?

@benedict-96
Copy link

Short update:
I think adding

function create_array(::Type{<:Base.ReshapedArray{T, N, P}}, S, nd::Val, d::Val, elems...) where {T, N, P}
    create_array(P, S, nd, d, elems...)
end

would indeed fix the problem. My code wasn't running before due to another problem.

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