-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: add support for clamp
and clamp!
#247
Merged
Conversation
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
Collaborator
avik-pal
commented
Nov 8, 2024
•
edited
Loading
edited
- needs testing
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
wsmoses
reviewed
Nov 8, 2024
src/TracedRNumber.jl
Outdated
@@ -270,6 +270,17 @@ Base.abs2(x::TracedRNumber{<:Real}) = x^2 | |||
|
|||
Base.log1p(x::TracedRNumber{T}) where {T} = log(x + one(T)) | |||
|
|||
function Base.clamp(x::TracedRNumber{T}, min::Number, max::Number) where {T} |
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.
do we want to have versions where min and/or max are tracedvalues?
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.
Reactant.jl Benchmarks
Benchmark suite | Current: f652d5d | Previous: f34ec8f | Ratio |
---|---|---|---|
ViT base (256 x 256 x 3 x 32)/forward/CPU/Reactant (optimize = :after_enzyme) |
6961960600 ns |
7027955167 ns |
0.99 |
ViT base (256 x 256 x 3 x 32)/forward/CPU/Reactant |
5008876591 ns |
5911790203 ns |
0.85 |
ViT base (256 x 256 x 3 x 32)/forward/CPU/Reactant (optimize = :before_enzyme) |
5099056791 ns |
5039003346 ns |
1.01 |
ViT base (256 x 256 x 3 x 32)/forward/CPU/Reactant (optimize = :only_enzyme) |
7634865394 ns |
7620308614 ns |
1.00 |
ViT base (256 x 256 x 3 x 32)/forward/CPU/Lux |
35163148305 ns |
31357074001 ns |
1.12 |
ViT small (256 x 256 x 3 x 4)/forward/CPU/Reactant (optimize = :after_enzyme) |
1573585661 ns |
1572787384 ns |
1.00 |
ViT small (256 x 256 x 3 x 4)/forward/CPU/Reactant |
1548430614 ns |
1548995246 ns |
1.00 |
ViT small (256 x 256 x 3 x 4)/forward/CPU/Reactant (optimize = :before_enzyme) |
1544114996 ns |
1555509740 ns |
0.99 |
ViT small (256 x 256 x 3 x 4)/forward/CPU/Reactant (optimize = :only_enzyme) |
3302096089 ns |
3467552492 ns |
0.95 |
ViT small (256 x 256 x 3 x 4)/forward/CPU/Lux |
3626707137 ns |
3419731143 ns |
1.06 |
ViT tiny (256 x 256 x 3 x 32)/forward/CPU/Reactant (optimize = :after_enzyme) |
2132195996 ns |
2180418814 ns |
0.98 |
ViT tiny (256 x 256 x 3 x 32)/forward/CPU/Reactant |
2130406024 ns |
2173460673 ns |
0.98 |
ViT tiny (256 x 256 x 3 x 32)/forward/CPU/Reactant (optimize = :before_enzyme) |
2124925292 ns |
2158353524 ns |
0.98 |
ViT tiny (256 x 256 x 3 x 32)/forward/CPU/Reactant (optimize = :only_enzyme) |
3894240054 ns |
3927830322 ns |
0.99 |
ViT tiny (256 x 256 x 3 x 32)/forward/CPU/Lux |
6049924945 ns |
6253378741.5 ns |
0.97 |
ViT tiny (256 x 256 x 3 x 4)/forward/CPU/Reactant (optimize = :after_enzyme) |
1423316093 ns |
1440134479 ns |
0.99 |
ViT tiny (256 x 256 x 3 x 4)/forward/CPU/Reactant |
1422220966 ns |
1421557207 ns |
1.00 |
ViT tiny (256 x 256 x 3 x 4)/forward/CPU/Reactant (optimize = :before_enzyme) |
1411767213 ns |
1428360591 ns |
0.99 |
ViT tiny (256 x 256 x 3 x 4)/forward/CPU/Reactant (optimize = :only_enzyme) |
3159441173 ns |
3208488833 ns |
0.98 |
ViT tiny (256 x 256 x 3 x 4)/forward/CPU/Lux |
1307717501 ns |
1139085595.5 ns |
1.15 |
ViT tiny (256 x 256 x 3 x 16)/forward/CPU/Reactant (optimize = :after_enzyme) |
1707093674 ns |
1712651271 ns |
1.00 |
ViT tiny (256 x 256 x 3 x 16)/forward/CPU/Reactant |
1709893988 ns |
1706763760 ns |
1.00 |
ViT tiny (256 x 256 x 3 x 16)/forward/CPU/Reactant (optimize = :before_enzyme) |
1696454194 ns |
1704312368 ns |
1.00 |
ViT tiny (256 x 256 x 3 x 16)/forward/CPU/Reactant (optimize = :only_enzyme) |
3443868848 ns |
3479746822 ns |
0.99 |
ViT tiny (256 x 256 x 3 x 16)/forward/CPU/Lux |
2887267582 ns |
3154626911 ns |
0.92 |
ViT small (256 x 256 x 3 x 16)/forward/CPU/Reactant (optimize = :after_enzyme) |
2187516129 ns |
2175602283 ns |
1.01 |
ViT small (256 x 256 x 3 x 16)/forward/CPU/Reactant |
2203005347 ns |
2162683110 ns |
1.02 |
ViT small (256 x 256 x 3 x 16)/forward/CPU/Reactant (optimize = :before_enzyme) |
2186065337 ns |
2187544254 ns |
1.00 |
ViT small (256 x 256 x 3 x 16)/forward/CPU/Reactant (optimize = :only_enzyme) |
3914533482 ns |
3928792736 ns |
1.00 |
ViT small (256 x 256 x 3 x 16)/forward/CPU/Lux |
5664834406 ns |
6172504320 ns |
0.92 |
ViT small (256 x 256 x 3 x 32)/forward/CPU/Reactant (optimize = :after_enzyme) |
2943345673 ns |
2997646442 ns |
0.98 |
ViT small (256 x 256 x 3 x 32)/forward/CPU/Reactant |
2965291585 ns |
2957532725 ns |
1.00 |
ViT small (256 x 256 x 3 x 32)/forward/CPU/Reactant (optimize = :before_enzyme) |
3017015460 ns |
2960803098 ns |
1.02 |
ViT small (256 x 256 x 3 x 32)/forward/CPU/Reactant (optimize = :only_enzyme) |
4820077455 ns |
4863944327 ns |
0.99 |
ViT small (256 x 256 x 3 x 32)/forward/CPU/Lux |
13103708690 ns |
22191688400 ns |
0.59 |
ViT base (256 x 256 x 3 x 16)/forward/CPU/Reactant (optimize = :after_enzyme) |
3153534399 ns |
3157390991 ns |
1.00 |
ViT base (256 x 256 x 3 x 16)/forward/CPU/Reactant |
3171484785 ns |
3212937029 ns |
0.99 |
ViT base (256 x 256 x 3 x 16)/forward/CPU/Reactant (optimize = :before_enzyme) |
3168248608 ns |
3419812778 ns |
0.93 |
ViT base (256 x 256 x 3 x 16)/forward/CPU/Reactant (optimize = :only_enzyme) |
5052248374 ns |
5010112071 ns |
1.01 |
ViT base (256 x 256 x 3 x 16)/forward/CPU/Lux |
14025077866 ns |
10940648930 ns |
1.28 |
ViT base (256 x 256 x 3 x 4)/forward/CPU/Reactant (optimize = :after_enzyme) |
2065027295 ns |
1843742771 ns |
1.12 |
ViT base (256 x 256 x 3 x 4)/forward/CPU/Reactant |
1898465030 ns |
1827524417 ns |
1.04 |
ViT base (256 x 256 x 3 x 4)/forward/CPU/Reactant (optimize = :before_enzyme) |
1883176767 ns |
1842645194 ns |
1.02 |
ViT base (256 x 256 x 3 x 4)/forward/CPU/Reactant (optimize = :only_enzyme) |
3720749988 ns |
3593953850 ns |
1.04 |
ViT base (256 x 256 x 3 x 4)/forward/CPU/Lux |
3362179008 ns |
3544018917 ns |
0.95 |
This comment was automatically generated by workflow using github-action-benchmark.
wsmoses
approved these changes
Nov 8, 2024
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.