-
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.
* Nograd for MersenneTwister * MersenneTwister frule * Bumps patch version * Bump patch version
- Loading branch information
1 parent
ce39b65
commit 697e7e4
Showing
5 changed files
with
41 additions
and
1 deletion.
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,8 @@ | ||
frule(Δargs, ::typeof(MersenneTwister), args...) = MersenneTwister(args...), Zero() | ||
|
||
function rrule(::typeof(MersenneTwister), args...) | ||
function MersenneTwister_rrule(ΔΩ) | ||
return (NO_FIELDS, map(_ -> Zero(), args)...) | ||
end | ||
return MersenneTwister(args...), MersenneTwister_rrule | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@testset "random" begin | ||
@testset "MersenneTwister" begin | ||
@testset "no args" begin | ||
rng, dΩ = frule((5.0,), MersenneTwister) | ||
@test rng isa MersenneTwister | ||
@test dΩ isa Zero | ||
|
||
rng, pb = rrule(MersenneTwister) | ||
@test rng isa MersenneTwister | ||
@test first(pb(10)) isa Zero | ||
end | ||
@testset "unary" begin | ||
rng, dΩ = frule((5.0, 4.0), MersenneTwister, 123) | ||
@test rng isa MersenneTwister | ||
@test dΩ isa Zero | ||
|
||
rng, pb = rrule(MersenneTwister, 123) | ||
@test rng isa MersenneTwister | ||
@test all(map(x -> x isa Zero, pb(10))) | ||
end | ||
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
697e7e4
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()
697e7e4
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/17498
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:
697e7e4
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.
This commit might have caused #227
697e7e4
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.
Ooooh, I see the problem. I'll put together a fix PR.