-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #749 from JuliaDiff/ox/logging
Add rule for with_logger
- Loading branch information
Showing
6 changed files
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# For the CoreLogging submodule of Base. (not to be confused with the Logging stdlib) | ||
|
||
function rrule( | ||
rc::RuleConfig{>:ChainRulesCore.HasReverseMode}, | ||
::typeof(Base.CoreLogging.with_logger), | ||
f::Function, | ||
logger::Base.CoreLogging.AbstractLogger, | ||
) | ||
y, f_pb = Base.CoreLogging.with_logger(logger) do | ||
rrule_via_ad(rc, f) | ||
end | ||
with_logger_pullback(ȳ) = (NoTangent(), only(f_pb(ȳ)), NoTangent()) | ||
return y, with_logger_pullback | ||
end | ||
|
||
@non_differentiable Base.CoreLogging.current_logger(args...) | ||
@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...) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# For the CoreLogging submodule of Base. (not to be confused with the Logging stdlib) | ||
@testset "CoreLogging.jl" begin | ||
@testset "with_logger" begin | ||
test_rrule( | ||
Base.CoreLogging.with_logger, | ||
() -> 2.0 * 3.0, | ||
Base.CoreLogging.NullLogger(); | ||
check_inferred=false, | ||
) | ||
end | ||
end |
This file contains 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
6843559
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
6843559
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/94682
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: