forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LLVMGPU] Add vector transfer lowering patterns to LLVMGPUVectorLowering
This adds a few peephole optimizations used in SPIR-V vector lowerings to LLVMGPU. At some future point it might be worth splitting up SPIRVVectorize to unify the usage of various peephole/lowering patterns between backends. Additionally this adds some missing dialect registrations to this pass.
- Loading branch information
Showing
4 changed files
with
27 additions
and
0 deletions.
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
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
18 changes: 18 additions & 0 deletions
18
compiler/src/iree/compiler/Codegen/LLVMGPU/test/vector_lowering.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,18 @@ | ||
// RUN: iree-opt --pass-pipeline="builtin.module(func.func(iree-llvmgpu-vector-lowering))" --split-input-file %s | FileCheck %s | ||
|
||
module { | ||
func.func @broadcast_read_lowering(%arg0: memref<4096x32xf16>) -> vector<1x8xf16> { | ||
%cst_1 = arith.constant 0.000000e+00 : f16 | ||
%0 = gpu.thread_id x | ||
%workgroup_id_x = hal.interface.workgroup.id[0] : index | ||
%broadcast_read = vector.transfer_read %arg0[%workgroup_id_x, %0], %cst_1 {in_bounds = [true, true], permutation_map = affine_map<(d0, d1) -> (d1, 0)>} : memref<4096x32xf16>, vector<1x8xf16> | ||
return %broadcast_read : vector<1x8xf16> | ||
} | ||
} | ||
// CHECK-LABEL: func.func @broadcast_read_lowering | ||
// CHECK-SAME: (%[[ARG0:.+]]: memref<4096x32xf16>) | ||
// CHECK: %[[INIT:.+]] = arith.constant dense<0.000000e+00> : vector<1x8xf16> | ||
// CHECK: %[[ELEM:.+]] = memref.load %[[ARG0]]{{.*}} : memref<4096x32xf16> | ||
// CHECK: %[[SPLAT:.+]] = vector.splat %[[ELEM]] : vector<8xf16> | ||
// CHECK: %[[INSERT:.+]] = vector.insert %[[SPLAT]], %[[INIT]] [0] : vector<8xf16> into vector<1x8xf16> | ||
// CHECK: return %[[INSERT]] |