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

Forward mode gradient doesn't support tuples with varying element types #1994

Open
mhauru opened this issue Oct 22, 2024 · 0 comments
Open

Comments

@mhauru
Copy link
Contributor

mhauru commented Oct 22, 2024

MWE:

julia> f(t) = t[1]*t[2]
f (generic function with 1 method)

julia> Enzyme.gradient(Enzyme.Forward, f, (1.0, Float32(2.0)))
ERROR: MethodError: no method matching onehot(::Tuple{Float64, Float32})

Closest candidates are:
  onehot(::Type{Tuple{Vararg{T, N}}}) where {T, N}
   @ Enzyme ~/projects/Enzyme.jl/src/Enzyme.jl:1557
  onehot(::Array)
   @ Enzyme ~/projects/Enzyme.jl/src/Enzyme.jl:1527
  onehot(::Array, ::Int64, ::Int64)
   @ Enzyme ~/projects/Enzyme.jl/src/Enzyme.jl:1531
  ...

Stacktrace:
 [1] macro expansion
   @ ~/projects/Enzyme.jl/src/Enzyme.jl:1833 [inlined]
 [2] create_shadows
   @ ~/projects/Enzyme.jl/src/Enzyme.jl:1811 [inlined]
 [3] gradient(::EnzymeCore.ForwardMode{false, EnzymeCore.FFIABI, false, false}, ::typeof(f), ::Tuple{Float64, Float32})
   @ Enzyme ~/projects/Enzyme.jl/src/Enzyme.jl:1970
 [4] top-level scope
   @ REPL[97]:1

Looking at the definition of onehot(::Type{NTuple{N,T}}), it doesn't seem to use the parameter T anywhere. Could it just be dropped?

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

No branches or pull requests

1 participant