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

Diffractor's forward mode cannot differentiate a struct with extra type params #18

Closed
YingboMa opened this issue Jul 27, 2021 · 2 comments

Comments

@YingboMa
Copy link
Member

MWE:

julia> struct Goo{I,T}
           x::T
       end

julia> using Diffractor

julia> const var"'" = Diffractor.PrimeDerivativeFwd
Diffractor.PrimeDerivativeFwd

julia> goo(x) = Goo{Int,typeof(x)}(x).x
goo (generic function with 1 method)

julia> goo'(1)
ERROR: MethodError: no method matching apply_type(::Type{Goo}, ::Type{Int64}, ::Type{Int64})
Stacktrace:
  [1] ∂☆nomethd(args::Any)
    @ Diffractor ~/src/julia/Diffractor/src/stage1/recurse_fwd.jl:115
  [2] macro expansion
    @ ~/src/julia/Diffractor/src/stage1/recurse_fwd.jl:0 [inlined]
  [3] (::Diffractor.∂☆recurse{1})(::Diffractor.UniformBu, ::Diffractor.UniformBu, ::Diffractor.UniformBu, ::Diffractor.UniformBu)
    @ Diffractor ~/src/julia/Diffractor/src/stage1/recurse_fwd.jl:160
  [4] (::Diffractor.∂☆internal{1})(::Diffractor.UniformBu, ::Vararg{Diffractor.Ab)
    @ Diffractor ~/src/julia/Diffractor/src/stage1/forward.jl:115
  [5] (::Diffractor.∂☆{1})(::Diffractor.UniformBu, ::Vararg{Diffractor.Ab)
    @ Diffractor ~/src/julia/Diffractor/src/stage1/forward.jl:134
  [6] ∂☆recurse
    @ ./REPL[4]:1 [inlined]
  [7] (::Diffractor.∂☆recurse{1})(::Diffractor.UniformBu, ::Diffractor.TangentBu)
    @ Diffractor ~/src/julia/Diffractor/src/stage1/recurse_fwd.jl:0
  [8] (::Diffractor.∂☆internal{1})(::Diffractor.UniformBu, ::Vararg{Diffractor.Ab)
    @ Diffractor ~/src/julia/Diffractor/src/stage1/forward.jl:115
  [9] ∂☆
    @ ~/src/julia/Diffractor/src/stage1/forward.jl:134 [inlined]
 [10] (::Diffractor.PrimeDerivativeFwd{1, typeof(goo)})(x::Int64)
    @ Diffractor ~/src/julia/Diffractor/src/interface.jl:177
 [11] top-level scope
    @ REPL[5]:1
@YingboMa YingboMa changed the title Diffractor cannot differentiate a struct with extra type params Diffractor's forward mode cannot differentiate a struct with extra type params Jul 27, 2021
@Keno
Copy link
Collaborator

Keno commented Jul 29, 2021

This works fine with JuliaDiff/ChainRules.jl#463.

@Keno
Copy link
Collaborator

Keno commented Aug 2, 2021

Fixed by ChainRules bump.

@Keno Keno closed this as completed Aug 2, 2021
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

2 participants