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

import NewvarNode #41

Merged
merged 1 commit into from
Aug 26, 2021
Merged

import NewvarNode #41

merged 1 commit into from
Aug 26, 2021

Conversation

niklasschmitz
Copy link
Contributor

This PR fixes a bug due to NewvarNode not being imported in recurse_fwd.jl

Currently this leads to an error:

using Diffractor
x = ones(3)
v = ones(3)
f(x) = sum(abs2, x)
julia> Diffractor.PrimeDerivativeFwd(ε -> f(x + ε*v))(0.0)
ERROR: LoadError: UndefVarError: NewvarNode not defined
Stacktrace:
  [1] (::Diffractor.var"#mapstmt!#215"{Core.SimpleVector, Int64, Diffractor.var"#emit!#214"{Vector{Any}, Vector{Any}}, Vector{Int64}})(stmt::GlobalRef)
    @ Diffractor ~/.julia/dev/Diffractor.jl/src/stage1/recurse_fwd.jl:58
  [2] (::Diffractor.var"#210#216"{Diffractor.var"#emit!#214"{Vector{Any}, Vector{Any}}})(stmt::GlobalRef)
    @ Diffractor ~/.julia/dev/Diffractor.jl/src/stage1/recurse_fwd.jl:39
  [3] iterate
    @ ./generator.jl:47 [inlined]
  [4] _collect(c::Vector{Any}, itr::Base.Generator{Vector{Any}, Diffractor.var"#210#216"{Diffractor.var"#emit!#214"{Vector{Any}, Vector{Any}}}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:783
  [5] collect_similar
    @ ./array.jl:698 [inlined]
  [6] map
    @ ./abstractarray.jl:2853 [inlined]
  [7] (::Diffractor.var"#mapstmt!#215"{Core.SimpleVector, Int64, Diffractor.var"#emit!#214"{Vector{Any}, Vector{Any}}, Vector{Int64}})(stmt::Expr)
    @ Diffractor ~/.julia/dev/Diffractor.jl/src/stage1/recurse_fwd.jl:38
  [8] transform_fwd!(ci::Core.CodeInfo, meth::Method, nargs::Int64, sparams::Core.SimpleVector, N::Int64)
    @ Diffractor ~/.julia/dev/Diffractor.jl/src/stage1/recurse_fwd.jl:93
  [9] perform_fwd_transform(ff::Type{Diffractor.∂☆recurse{1}}, args::Any)
    @ Diffractor ~/.julia/dev/Diffractor.jl/src/stage1/recurse_fwd.jl:139
 [10] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
    @ Core ./boot.jl:580
 [11] ∂☆internal
    @ ~/.julia/dev/Diffractor.jl/src/stage1/forward.jl:115 [inlined]
 [12] ∂☆
    @ ~/.julia/dev/Diffractor.jl/src/stage1/forward.jl:134 [inlined]
 [13] (::Diffractor.PrimeDerivativeFwd{1, var"#1#2"})(x::Float64)
    @ Diffractor ~/.julia/dev/Diffractor.jl/src/interface.jl:177
 [14] top-level scope

After import:

julia> Diffractor.PrimeDerivativeFwd(ε -> f(x + ε*v))(0.0)
6.0

@Keno Keno merged commit 1c4cc4f into JuliaDiff:main Aug 26, 2021
@niklasschmitz niklasschmitz deleted the newvarnode branch August 26, 2021 18:03
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 this pull request may close these issues.

2 participants