FluxML / Zygote.jl

21st century AD
https://fluxml.ai/Zygote.jl/
Other
1.48k stars 213 forks source link

New ChainRules.rrule defs not taking effect until Zyogte.refresh() #718

Open MasonProtter opened 4 years ago

MasonProtter commented 4 years ago

MWE:

julia> using Zygote, ChainRules

julia> f(x) = 2x + 1
f (generic function with 1 method)

julia> f'(1)
2

julia> ChainRules.rrule(::typeof(f), x::Int) = f(x), Δf -> (Zero(), 10000000000)

julia> f'(1)
2

julia> Zygote.refresh()

julia> f'(1)
10000000000

julia> versioninfo()
Julia Version 1.5.0-rc1.0
Commit 24f033c951* (2020-06-26 20:13 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD Ryzen 5 2600 Six-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, znver1)
Environment:
  JULIA_NUM_THREADS = 6

julia> Pkg.status("Zygote")
Status `~/.julia/environments/v1.5/Project.toml`
  [e88e6eb3] Zygote v0.5.1 `https://github.com/FluxML/Zygote.jl.git#master`
willtebbutt commented 4 years ago

@oxinabox any thoughts?

oxinabox commented 4 years ago

No. Maybe @vchuravy has thoughts?