-
Notifications
You must be signed in to change notification settings - Fork 177
Add AIR compatibility #2934
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
Open
pw0908
wants to merge
13
commits into
EnzymeAD:main
Choose a base branch
from
pw0908:metal-air-math-intrinsics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add AIR compatibility #2934
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e923393
Add AIR compatibility
pw0908 13c5f0f
Fix air-atan2 test
pw0908 e6829ea
Merge branch 'main' into metal-air-math-intrinsics
pw0908 f5d0531
Fix clang error
pw0908 69c0607
Add metal to list of uses
pw0908 8d75b8c
Merge branch 'metal-air-math-intrinsics' of github.com:pw0908/Enzyme …
pw0908 1576c15
Merge branch 'main' into metal-air-math-intrinsics
pw0908 fb3543e
Add utility function to identify GPU architecture
pw0908 b601d8f
Fix make issue.
pw0908 ed2faf0
Logic fix
pw0908 2e91916
Merge branch 'main' into metal-air-math-intrinsics
pw0908 180fd07
Merge branch 'main' into metal-air-math-intrinsics
pw0908 c698f9a
Merge branch 'main' into metal-air-math-intrinsics
pw0908 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
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
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
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
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,35 @@ | ||
| ; RUN: if [ %llvmver -lt 16 ]; then %opt < %s %loadEnzyme -preserve-nvvm -enzyme -early-cse -instcombine -enzyme-preopt=false -S | FileCheck %s; fi | ||
| ; RUN: %opt < %s %newLoadEnzyme -passes="preserve-nvvm,enzyme,function(early-cse,instcombine)" -enzyme-preopt=false -S | FileCheck %s | ||
|
|
||
| ; Metal AIR math intrinsic (air.atan2.f32): not a real LLVM intrinsic, so | ||
| ; this exercises the new air.atan2.f32/air.atan2.f64 CallPattern entry in | ||
| ; forward mode. | ||
|
|
||
| define float @tester(float %y, float %x) { | ||
| entry: | ||
| %call = call float @air.atan2.f32(float %y, float %x) | ||
| ret float %call | ||
| } | ||
|
|
||
| define float @test_derivative(float %y, float %x) { | ||
| entry: | ||
| %0 = tail call float (...) @__enzyme_fwddiff(float (float, float)* nonnull @tester, float %y, float 1.000000e+00, float %x, float 1.000000e+00) | ||
| ret float %0 | ||
| } | ||
|
|
||
| declare float @air.atan2.f32(float, float) | ||
|
|
||
| ; Function Attrs: nounwind | ||
| declare float @__enzyme_fwddiff(...) | ||
|
|
||
| ; CHECK-LABEL: define internal float @fwddiffetester( | ||
| ; CHECK-NEXT: entry: | ||
| ; CHECK-DAG: %[[a3:.+]] = fmul fast float %"y'", %x | ||
| ; CHECK-DAG: %[[a1:.+]] = fmul fast float %x, %x | ||
| ; CHECK-DAG: %[[a0:.+]] = fmul fast float %y, %y | ||
| ; CHECK-DAG: %[[a2:.+]] = fadd fast float %[[a1]], %[[a0]] | ||
| ; CHECK-DAG: %[[a4:.+]] = fmul fast float %"x'", %y | ||
| ; CHECK-DAG: %[[a5:.+]] = fsub fast float %[[a3]], %[[a4]] | ||
| ; CHECK-DAG: %[[a6:.+]] = fdiv fast float %[[a5]], %[[a2]] | ||
| ; CHECK-NEXT: ret float %[[a6]] | ||
| ; CHECK-NEXT: } |
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,37 @@ | ||
| ; RUN: if [ %llvmver -lt 16 ]; then %opt < %s %loadEnzyme -enzyme-preopt=false -preserve-nvvm -enzyme -mem2reg -sroa -early-cse -instsimplify -simplifycfg -adce -S | FileCheck %s; fi | ||
| ; RUN: %opt < %s %newLoadEnzyme -passes="preserve-nvvm,enzyme,function(mem2reg,sroa,early-cse,instsimplify,%simplifycfg,adce)" -enzyme-preopt=false -S | FileCheck %s | ||
|
|
||
| ; Metal AIR math intrinsic (air.atan2.f32): not a real LLVM intrinsic, so | ||
| ; this exercises the new air.atan2.f32/air.atan2.f64 CallPattern entry. | ||
|
|
||
| define float @tester(float %y, float %x) { | ||
| entry: | ||
| %call = call float @air.atan2.f32(float %y, float %x) | ||
| ret float %call | ||
| } | ||
|
|
||
| define float @test_derivative(float %y, float %x) { | ||
| entry: | ||
| %0 = tail call float (...) @__enzyme_autodiff(float (float, float)* nonnull @tester, float %y, float %x) | ||
| ret float %0 | ||
| } | ||
|
|
||
| declare float @air.atan2.f32(float, float) | ||
|
|
||
| ; Function Attrs: nounwind | ||
| declare float @__enzyme_autodiff(...) | ||
|
|
||
| ; CHECK: define internal { float, float } @diffetester(float %y, float %x, float %differeturn) | ||
| ; CHECK-NEXT: entry: | ||
| ; CHECK-DAG: %[[a0:.+]] = fmul fast float %y, %y | ||
| ; CHECK-DAG: %[[a1:.+]] = fmul fast float %x, %x | ||
| ; CHECK-DAG: %[[a2:.+]] = fadd fast float %[[a1]], %[[a0]] | ||
| ; CHECK-DAG: %[[a3:.+]] = fmul fast float %differeturn, %x | ||
| ; CHECK-DAG: %[[a4:.+]] = fdiv fast float %[[a3]], %[[a2]] | ||
| ; CHECK-DAG: %[[a5:.+]] = fmul fast float %differeturn, %y | ||
| ; CHECK-DAG: %[[a6:.+]] = fdiv fast float %[[a5]], %[[a2]] | ||
| ; CHECK-DAG: %[[a7:.+]] = {{(fneg fast float)|(fsub fast float (-)?0.000000e\+00,)}} %[[a6]] | ||
| ; CHECK-DAG: %[[a8:.+]] = insertvalue { float, float } undef, float %[[a4]], 0 | ||
| ; CHECK-DAG: %[[a9:.+]] = insertvalue { float, float } %[[a8]], float %[[a7]], 1 | ||
| ; CHECK-DAG: ret { float, float } %[[a9]] | ||
| ; CHECK-NEXT: } |
Oops, something went wrong.
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.