Skip to content

Commit

Permalink
rename _lookup_grad
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox committed Jun 18, 2021
1 parent d949838 commit 8d9fac7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/compiler/emit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ end

varargs(m::Method, n) = m.isva ? n - m.nargs + 1 : nothing

function _lookup_grad(T)
function _generate_pullback_via_decomposition(T)
(m = meta(T)) === nothing && return
va = varargs(m.method, length(T.parameters))
forw, back = stacks!(Adjoint(IR(m), varargs = va, normalise = false), T)
Expand Down
5 changes: 3 additions & 2 deletions src/compiler/interface2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end

hascr && return :($chain_rrule_f(ZygoteRuleConfig(ctx), f, args...))

g = try _lookup_grad(T) catch e e end
g = try _generate_pullback_via_decomposition(T) catch e e end
g === nothing && return :(f(args...), Pullback{$T}((f,)))
meta, forw, _ = g
argnames!(meta, Symbol("#self#"), :ctx, :f, :args)
Expand All @@ -37,7 +37,8 @@ end

@generated function (j::Pullback{T})(Δ) where T
ignore_sig(T) && return :nothing
g = try _lookup_grad(T)
g = try
_generate_pullback_via_decomposition(T)
catch e
rethrow(CompileError(T,e))
end
Expand Down

0 comments on commit 8d9fac7

Please sign in to comment.