Merged
Conversation
mcabbott
commented
Sep 1, 2022
Comment on lines
323
to
+325
| function unbroadcast(x::Base.AbstractArrayOrBroadcasted, dx_raw) | ||
| dx = unthunk(dx_raw) | ||
| N = ndims(dx) | ||
| N = _ndims(dx) |
Member
Author
There was a problem hiding this comment.
This one has a test, lazy broadcasting of - means this can be called with dx::Tuple
Comment on lines
133
to
143
| function back_generic(dys) | ||
| deltas = unzip_broadcast(backs, unthunk(dys)) do back, dy # (could be map, sizes match) | ||
| deltas = unzip_broadcast(backs, dys) do back, dy # (could be map, sizes match) | ||
| map(unthunk, back(dy)) | ||
| end | ||
| dargs = map(unbroadcast, args, Base.tail(deltas)) | ||
| df = ProjectTo(f)(sum(first(deltas))) | ||
| return (NoTangent(), NoTangent(), df, dargs...) | ||
| end | ||
| back_generic(dys::AbstractThunk) = back_generic(unthunk(dys)) | ||
| back_generic(z::AbstractZero) = (TRI_NO..., map(Returns(z), args)...) | ||
| return ys3, back_generic |
Member
Author
There was a problem hiding this comment.
Somehow Diffractor fed this pullback a thunk containing a ZeroTangent. And... well maybe I tried this with #671 which changes this to unzip_map, and that was not happy about the zero. So I changed them all to have 3 methods, not two.
Member
Author
There was a problem hiding this comment.
Now some removed, as this caused inference problems.
mcabbott
commented
Sep 2, 2022
| @non_differentiable Base.CoreLogging.current_logger_for_env(::Any...) | ||
| @non_differentiable Base.CoreLogging._invoked_shouldlog(::Any...) | ||
| @non_differentiable Base.CoreLogging.Base.fixup_stdlib_path(::Any) | ||
| @non_differentiable Base.CoreLogging.handle_message(::Any...) |
Member
Author
There was a problem hiding this comment.
These fix this -- a second derivative notices @debug inside rules, and fails.
julia> gradient([1,2,3]) do x
gradient(x) do y
sum(y .* y)
end[1] |> sum
end
ERROR: (1, current_logger_for_env(std_level::Base.CoreLogging.LogLevel, group, _module) @ Base.CoreLogging logging.jl:500, :($(Expr(:meta, :noinline))))
Stacktrace:
[1] error(s::Tuple{Int64, Method, Expr})
@ Base ./error.jl:44
[2] transform!(ci::Core.CodeInfo, meth::Method, nargs::Int64, sparams::Core.SimpleVector, N::Int64)
@ Diffractor ~/.julia/dev/Diffractor/src/stage1/recurse.jl:621
[3] perform_optic_transform(ff::Type{Diffractor.∂⃖recurse{1}}, args::Any)
@ Diffractor ~/.julia/dev/Diffractor/src/stage1/generated.jl:25
oxinabox
approved these changes
Sep 4, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to JuliaDiff/Diffractor.jl#89