-
Notifications
You must be signed in to change notification settings - Fork 16
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
[GPU] Add MLP test and linalg.fill lowering in 'linalg-to-xegpu' #220
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
964398e
Aling 'linalg-to-xegpu' pass with patched XeGPU dialect
dchigarev 2778459
add simple e2e test
dchigarev 0f25517
Fix tests
dchigarev 05aa8d6
fix tests
dchigarev 829b9d4
fix tests
dchigarev 3660cdc
Merge remote-tracking branch 'origin/main' into fix-linalg-to-xe
dchigarev 52eb013
fix imex build
dchigarev 48914ac
distinct between ENABLE and USE IMEX
dchigarev 2f5561c
Merge branch 'main' into fix-linalg-to-xe
dchigarev 8184f5d
Merge remote-tracking branch 'origin/main' into fix-linalg-to-xe
dchigarev be7fdf0
remove l0 runtime
dchigarev a94205a
fix formatting
dchigarev 4cf3457
Merge remote-tracking branch 'origin/main' into fix-linalg-to-xe
dchigarev 0e21466
add mlp test
97f914b
update
8a1e875
update
e1a841f
Merge branch 'main' into longsheng/mlp-xegpu
53b8a0e
fix
7a767bd
fix
da8aea7
Merge branch 'main' into longsheng/mlp-xegpu
40403f7
Merge branch 'main' into longsheng/mlp-xegpu
b2ae504
Merge branch 'main' into longsheng/mlp-xegpu
8c8db90
fix
92ec215
imex fix
51dc371
Merge branch 'main' into longsheng/mlp-xegpu
0fcd2ab
fixed
a5b7cf3
Merge branch 'main' into longsheng/mlp-xegpu
65403e3
update imex
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 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 |
---|---|---|
@@ -1 +1 @@ | ||
ee459724294e165e360e1de72ad3b217eb9b6206 | ||
6c2e414a953b9a118bce6adac21cf9d42630e674 |
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
57 changes: 57 additions & 0 deletions
57
test/mlir/test/gc/gpu-runner/XeGPU/f16_mlp_32x4096x4096x4096.mlir
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,57 @@ | ||||
// RUN: gc-opt %s --pass-pipeline='builtin.module(func.func(iterative-tiling-and-fusion{use-cost-model=0 default-tile-size=matmul:{16,16}}),eliminate-empty-tensors,empty-tensor-to-alloc-tensor,one-shot-bufferize{bufferize-function-boundaries=1 function-boundary-type-conversion=identity-layout-map},drop-equivalent-buffer-results,func.func(finalizing-bufferize),canonicalize,cse,drop-equivalent-buffer-results,expand-realloc,canonicalize,ownership-based-buffer-deallocation,canonicalize,buffer-deallocation-simplification,bufferization-lower-deallocations,cse,canonicalize,convert-bufferization-to-memref,func.func(scf-forall-to-parallel),func.func(linalg-to-xegpu{stages=1 dpas-tile=8,16,16 k-tile=16}),xegpu-fold-alias-ops,func.func(convert-linalg-to-parallel-loops),func.func(gpu-map-parallel-loops),func.func(convert-parallel-loops-to-gpu),func.func(insert-gpu-allocs),gpu-kernel-outlining,canonicalize,set-spirv-capabilities{client-api=opencl},gpu.module(set-spirv-abi-attrs{client-api=opencl}),lower-affine,imex-vector-linearize,gpu.module(convert-xegpu-to-vc),reconcile-unrealized-casts,bf16-to-gpu,gpu.module(convert-func-to-spirv),gpu.module(convert-vector-to-spirv),imex-convert-gpu-to-spirv,spirv.module(spirv-lower-abi-attrs,spirv-update-vce),func.func(llvm-request-c-wrappers),serialize-spirv,convert-vector-to-scf,convert-gpu-to-gpux,convert-scf-to-cf,convert-cf-to-llvm,convert-vector-to-llvm,convert-index-to-llvm,convert-arith-to-llvm,convert-func-to-llvm,convert-math-to-llvm,convert-gpux-to-llvm,convert-index-to-llvm,expand-strided-metadata,lower-affine,finalize-memref-to-llvm,reconcile-unrealized-casts)' \ | ||||
// RUN: | gc-cpu-runner -e main --entry-point-result=void \ | ||||
// RUN: --shared-libs=%mlir_runner_utils,%mlir_c_runner_utils,%opencl_runtime | FileCheck %s | ||||
|
||||
module { | ||||
func.func @linalg_mlp(%arg0: tensor<32x4096xf16>, %arg1: tensor<4096x4096xf16>, %arg2 : tensor<32x4096xf16>, | ||||
%arg3: tensor<4096x4096xf16>, %arg4 : tensor<32x4096xf16>) { | ||||
%cst = arith.constant 0.000000e+00 : f16 | ||||
%0 = tensor.empty() : tensor<32x4096xf16> | ||||
%1 = linalg.fill ins(%cst : f16) outs(%0 : tensor<32x4096xf16>) -> tensor<32x4096xf16> | ||||
%2 = linalg.matmul ins(%arg0, %arg1 : tensor<32x4096xf16>, tensor<4096x4096xf16>) | ||||
outs(%1 : tensor<32x4096xf16>) -> (tensor<32x4096xf16>) | ||||
%3 = tensor.empty() : tensor<32x4096xf16> | ||||
%4 = linalg.add ins(%arg2, %2 : tensor<32x4096xf16>, tensor<32x4096xf16>) | ||||
outs(%3 : tensor<32x4096xf16>) -> tensor<32x4096xf16> | ||||
%5 = arith.constant dense<0.000000e+00> : tensor<32x4096xf16> | ||||
%6 = tensor.empty() : tensor<32x4096xf16> | ||||
%7 = linalg.max ins(%5, %4 : tensor<32x4096xf16>, tensor<32x4096xf16>) | ||||
outs(%6 : tensor<32x4096xf16>) -> tensor<32x4096xf16> | ||||
|
||||
%8 = tensor.empty() : tensor<32x4096xf16> | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you use it anywhere?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||||
%9 = linalg.fill ins(%cst : f16) outs(%8 : tensor<32x4096xf16>) -> tensor<32x4096xf16> | ||||
%10 = linalg.matmul ins(%7, %arg3 : tensor<32x4096xf16>, tensor<4096x4096xf16>) | ||||
outs(%9 : tensor<32x4096xf16>) -> (tensor<32x4096xf16>) | ||||
%11 = tensor.empty() : tensor<32x4096xf16> | ||||
%12 = linalg.add ins(%arg4, %10 : tensor<32x4096xf16>, tensor<32x4096xf16>) | ||||
outs(%11 : tensor<32x4096xf16>) -> tensor<32x4096xf16> | ||||
%13 = arith.constant dense<0.000000e+00> : tensor<32x4096xf16> | ||||
%14 = tensor.empty() : tensor<32x4096xf16> | ||||
%15 = linalg.max ins(%13, %12 : tensor<32x4096xf16>, tensor<32x4096xf16>) | ||||
outs(%14 : tensor<32x4096xf16>) -> tensor<32x4096xf16> | ||||
|
||||
%slice = tensor.extract_slice %15[0, 0][32, 1][1, 1] : tensor<32x4096xf16> to tensor<32xf16> | ||||
%cast = tensor.cast %slice : tensor<32xf16> to tensor<*xf16> | ||||
call @printMemrefF16(%cast) : (tensor<*xf16>) -> () | ||||
|
||||
return | ||||
} | ||||
|
||||
func.func @main() { | ||||
%0 = arith.constant dense<0.01> : tensor<32x4096xf16> | ||||
%1 = arith.constant dense<0.01> : tensor<4096x4096xf16> | ||||
%2 = arith.constant dense<0.02> : tensor<32x4096xf16> | ||||
%3 = arith.constant dense<0.01> : tensor<4096x4096xf16> | ||||
%4 = arith.constant dense<0.02> : tensor<32x4096xf16> | ||||
|
||||
func.call @linalg_mlp(%0, %1, %2, %3, %4) : (tensor<32x4096xf16>, tensor<4096x4096xf16>, tensor<32x4096xf16>, | ||||
tensor<4096x4096xf16>, tensor<32x4096xf16>) -> () | ||||
return | ||||
} | ||||
|
||||
func.func private @printMemrefF16(%ptr : tensor<*xf16>) attributes { llvm.emit_c_interface } | ||||
} | ||||
|
||||
// CHECK: Unranked Memref base@{{(0x)?[-0-9a-fA-F]*}} | ||||
// CHECK-SAME: rank = 1 offset = 0 sizes = [32] strides = [4096] data = | ||||
// CHECK-NEXT: [17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625, 17.625] |
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.
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.
Does this test pass on your machine? For me it fails with the following error:
incorrect lowering for 'linalg.fill'?
If I remove all
linalg.fill
from the test it then fails with another error caused by double deallocations added byinsert-gpu-allocs
pass. This can be fixed with this patch to IMEX: Menooker/mlir-extensions#3 (have you applied this patch to your IMEX build? If so, we probably should merge it and update IMEX version)free() problem
After removing
linalg.fill
and applying the patch above to IMEX the test passes for me.