-
Notifications
You must be signed in to change notification settings - Fork 13
Initial Kernel Bench "compiler" #115
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1d69f1c
Initial Kernel Bench "compiler"
rengolin 61fc39b
output is the first tensor
rengolin 914af58
fix
rengolin 073f0d6
fix input/output handling
rengolin de37f8d
comment
rengolin 2d85d19
move kernel_bench to tools, descriptors inside lighhouse, update sear…
rengolin c60205e
ruff
rengolin d453a93
address comments
rengolin 273609b
unnecessary directory for descriptors
rengolin c1786d8
avoid searching in the path if not registered
rengolin 09aba61
more robust path lookup, better error messages
rengolin 8b4d663
address comments
rengolin 0074f0b
support bf16
rengolin 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # RUN: python %s | FileCheck %s | ||
|
rengolin marked this conversation as resolved.
|
||
|
|
||
| # REQUIRES: torch | ||
| # REQUIRES: kernel_bench | ||
|
|
||
| import subprocess | ||
| from pathlib import Path | ||
|
|
||
| tests = [ | ||
| { | ||
| "kernel": "level1/1_Square_matrix_multiplication_.py", | ||
| "input_shapes": "32x32xf32xrnd,32x32xf32xid", | ||
| "output_shape": "32x32xf32x0", | ||
| }, | ||
| { | ||
| "kernel": "level1/1_Square_matrix_multiplication_.py", | ||
| "input_shapes": "32x32xbf16xrnd,32x32xbf16xid", | ||
| "output_shape": "32x32xbf16x0", | ||
| }, | ||
| { | ||
| "kernel": "level1/2_Standard_matrix_multiplication_.py", | ||
| "input_shapes": "8x16xf32xrnd,16x8xf32xrnd", | ||
| "output_shape": "8x8xf32x0", | ||
| }, | ||
| { | ||
| "kernel": "level1/2_Standard_matrix_multiplication_.py", | ||
| "input_shapes": "8x16xbf16xrnd,16x8xbf16xrnd", | ||
| "output_shape": "8x8xbf16x0", | ||
| }, | ||
| ] | ||
|
|
||
| if __name__ == "__main__": | ||
| project_root = Path(__file__).parent.parent.parent.parent | ||
| kb_program = project_root / "tools" / "kernel_bench" | ||
| kb_path = project_root / "third_party" / "KernelBench" / "KernelBench" | ||
|
|
||
| for test in tests: | ||
| kb_kernel = kb_path / test["kernel"] | ||
| command_line = [ | ||
| str(kb_program), | ||
| str(kb_kernel), | ||
| "--input-shapes", | ||
| test["input_shapes"], | ||
| "--output-shape", | ||
| test["output_shape"], | ||
| "--print-tensor=1", | ||
| "--seed=42", | ||
| ] | ||
| print(f"Running command: {' '.join(command_line)}") | ||
| result = subprocess.run( | ||
| command_line, | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
|
|
||
| print("STDOUT:") | ||
| print(result.stdout) | ||
| print("STDERR:") | ||
| print(result.stderr) | ||
| print(f"Return code: {result.returncode}") | ||
| assert result.returncode == 0, "Execution failed" | ||
|
|
||
| # CHECK: 1_Square_matrix_multiplication_.mlir | ||
| # CHECK 0.37454012 0.9507143 0.7319939 ... 0.04645041 0.60754484 0.17052412 | ||
| # CHECK: 0.27214515 0.59023064 0.3609739 ... 0.297349 0.9243962 0.97105825 | ||
|
|
||
| # CHECK-NOT: Execution failed | ||
|
|
||
| # CHECK: 1_Square_matrix_multiplication_.mlir | ||
| # CHECK 0.375 0.949219 0.730469 ... 0.0463867 0.609375 0.170898 | ||
| # CHECK: 0.271484 0.589844 0.361328 ... 0.296875 0.925781 0.972656 | ||
|
|
||
| # CHECK-NOT: Execution failed | ||
|
|
||
| # CHECK: 2_Standard_matrix_multiplication_.mlir | ||
| # CHECK: 3.120935 3.7697 4.5365195 4.397648 4.4506536 3.2665431 3.5362916 | ||
| # CHECK: 5.036752 5.312808 5.8109508 4.810084 4.7435184 4.35573 5.311559 | ||
|
|
||
| # CHECK-NOT: Execution failed | ||
|
|
||
| # CHECK: 2_Standard_matrix_multiplication_.mlir | ||
| # CHECK: 3.125 3.76562 4.53125 4.40625 4.4375 3.26562 3.53125 3.9375 | ||
| # CHECK: 5.03125 5.3125 5.8125 4.8125 4.75 4.34375 5.3125 5.5625 | ||
|
|
||
| # CHECK-NOT: Execution failed | ||
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
2 changes: 1 addition & 1 deletion
2
test/opt/stages/bufferization.yaml → ...e/pipeline/descriptors/bufferization.yaml
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| Pipeline: | ||
| - pass: "eliminate-empty-tensors" | ||
| - pass: "one-shot-bufferize{function-boundary-type-conversion=identity-layout-map bufferize-function-boundaries}" | ||
| - pass: "drop-equivalent-buffer-results" | ||
| - pass: "buffer-deallocation-pipeline" | ||
| - pass: "convert-bufferization-to-memref" | ||
|
|
File renamed without changes.
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,11 @@ | ||
| Pipeline: | ||
| - pass: "convert-linalg-to-loops" | ||
| - pass: "fold-memref-alias-ops" | ||
| - pass: "expand-strided-metadata" | ||
| - pass: "canonicalize" | ||
| - pass: "convert-vector-to-scf" | ||
| - pass: "lower-affine" | ||
| - pass: "convert-scf-to-cf" | ||
| - pass: "convert-vector-to-llvm" | ||
| - pass: "convert-to-llvm" | ||
| - pass: "reconcile-unrealized-casts" |
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.