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

Compatibility with logging #386

Open
xukai92 opened this issue Oct 31, 2019 · 3 comments
Open

Compatibility with logging #386

xukai92 opened this issue Oct 31, 2019 · 3 comments

Comments

@xukai92
Copy link
Contributor

xukai92 commented Oct 31, 2019

MWE

julia> using Zygote

julia> function f(x)
       @info x
       2 * x
       end
f (generic function with 1 method)

julia> f'(1.0)
[ Info: 1.0
ERROR: Compiling Tuple{typeof(f),Float64}: try/catch is not supported.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] instrument(::IRTools.Inner.IR) at /Users/kai/.julia/packages/Zygote/9Mec5/src/compiler/reverse.jl:88
 [3] #Primal#6 at /Users/kai/.julia/packages/Zygote/9Mec5/src/compiler/reverse.jl:158 [inlined]
 [4] Type at ./none:0 [inlined]
 [5] #Adjoint#22(::Nothing, ::Bool, ::Type{Zygote.Adjoint}, ::IRTools.Inner.IR) at /Users/kai/.julia/packages/Zygote/9Mec5/src/compiler/reverse.jl:271
 [6] (::getfield(Core, Symbol("#kw#Type")))(::NamedTuple{(:varargs, :normalise),Tuple{Nothing,Bool}}, ::Type{Zygote.Adjoint}, ::IRTools.Inner.IR) at ./none:0
 [7] _lookup_grad(::Type) at /Users/kai/.julia/packages/Zygote/9Mec5/src/compiler/emit.jl:101
 [8] #s2641#1468 at /Users/kai/.julia/packages/Zygote/9Mec5/src/compiler/interface2.jl:21 [inlined]
 [9] #s2641#1468(::Any, ::Any, ::Any) at ./none:0
 [10] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any,N} where N) at ./boot.jl:524
 [11] (::getfield(Zygote, Symbol("##28#29")){typeof((f))})(::Float64) at /Users/kai/.julia/packages/Zygote/9Mec5/src/compiler/interface.jl:38
 [12] gradient at /Users/kai/.julia/packages/Zygote/9Mec5/src/compiler/interface.jl:47 [inlined]
 [13] (::getfield(Zygote, Symbol("##30#31")){typeof(f)})(::Float64) at /Users/kai/.julia/packages/Zygote/9Mec5/src/compiler/interface.jl:50
 [14] top-level scope at REPL[3]:1
@baggepinnen
Copy link
Contributor

Duplicate of #269

@MikeInnes
Copy link
Member

This is hard because it immediately expands into try/catch, so we can't just nograd it.

One option is to split out a new function containing the @info and @nograd that. Another is to just fix exception support in Zygote, which we're probably past due on.

@xukai92
Copy link
Contributor Author

xukai92 commented Oct 31, 2019

One option is to split out a new function containing the @info and @Nograd that. Another is to just fix exception support in Zygote, which we're probably past due on.

This is my current hack. Just a bit annoying one has to do this when using e.g. TensorBoardLogger as one of the advantage is you can simply do @info...

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

3 participants