-
Notifications
You must be signed in to change notification settings - Fork 155
Add Mooncake integration #1342
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
Closed
Closed
Add Mooncake integration #1342
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
393a9f2
Add Mooncake integration
gdalle 6e31ec7
Restructure tests
gdalle 7a38354
Fix Ci
gdalle 2210dc9
Rename job
gdalle f9821cf
Path in quotes
gdalle 8d1b4c4
Fix path
gdalle 91e0cf4
Add caching
gdalle e1b3dd9
Remove Pkg from test deps
gdalle 4952e68
Fix
gdalle 099050d
Env in matrix
gdalle 880e669
Rename test
gdalle af7d1a8
Rerename
gdalle 5b73a34
Reactivate other tests
gdalle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| module StaticArraysMooncakeExt | ||
|
|
||
| using StaticArrays: StaticArray | ||
| using Mooncake: Mooncake | ||
|
|
||
| @static if isdefined(Mooncake, :FriendlyTangentCache) # checks Mooncake >= v0.5.25 | ||
| function Mooncake.friendly_tangent_cache(x::StaticArray) | ||
| return Mooncake.FriendlyTangentCache{Mooncake.AsPrimal}(copy(x)) | ||
| end | ||
| end | ||
|
|
||
| end | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| using Pkg | ||
| Pkg.add("Mooncake") | ||
|
|
||
| using StaticArrays | ||
| using Mooncake | ||
| using Test | ||
|
|
||
| @testset verbose=true "Mooncake integration" begin | ||
| f(x) = sum(abs2, x) | ||
| config = Mooncake.Config(; friendly_tangents=true) | ||
| @testset "$(typeof(x))" for x in [ | ||
| SVector(1.0, 2.0), | ||
| MVector(1.0, 2.0) , | ||
| SMatrix{2,2}(1.0, 2.0, 3.0, 4.0), | ||
| MMatrix{2,2}(1.0, 2.0, 3.0, 4.0) | ||
| ] | ||
| cache = prepare_gradient_cache(f, zero(x); config) | ||
| val, grads = value_and_gradient!!(cache, f, x) | ||
| g = grads[2] | ||
| @test g isa typeof(x) | ||
| @test g == 2x | ||
| end | ||
| end |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.