-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VectorDistribution] Configure contraction layouts at linalg level (#…
…18152) This patch moves layout anchoring for contractions to linalg level. This is primarily motivated by allowing us to decide layouts based on lowering_config. Future patches will also move the transfer_read anchoring to linalg level.
- Loading branch information
Showing
29 changed files
with
585 additions
and
562 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
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
55 changes: 20 additions & 35 deletions
55
compiler/src/iree/compiler/Codegen/Common/GPU/test/gpu_vector_alloc.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 |
---|---|---|
@@ -1,41 +1,26 @@ | ||
// RUN: iree-opt %s --split-input-file --pass-pipeline="builtin.module(func.func(iree-codegen-gpu-vector-alloc))" | FileCheck %s | ||
|
||
func.func @matmul_256x256x256(%lhs: tensor<16x256xf16>, | ||
%rhs: tensor<256x16xf16>, | ||
%out: tensor<16x16xf32>) -> tensor<16x16xf32> { | ||
%cst = arith.constant 0.000000e+00 : f16 | ||
%cst_0 = arith.constant dense<0.000000e+00> : vector<16x16xf32> | ||
%c32 = arith.constant 32 : index | ||
%c256 = arith.constant 256 : index | ||
%c0 = arith.constant 0 : index | ||
%8 = scf.for %arg0 = %c0 to %c256 step %c32 iter_args(%arg1 = %cst_0) -> (vector<16x16xf32>) { | ||
%10 = vector.transfer_read %lhs[%c0, %arg0], %cst {in_bounds = [true, true]} : tensor<16x256xf16>, vector<16x32xf16> | ||
%11 = vector.transfer_read %rhs[%arg0, %c0], %cst {in_bounds = [true, true]} : tensor<256x16xf16>, vector<32x16xf16> | ||
%12 = vector.contract {indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>, affine_map<(d0, d1, d2) -> (d2, d1)>, affine_map<(d0, d1, d2) -> (d0, d1)>], iterator_types = ["parallel", "parallel", "reduction"], kind = #vector.kind<add>} %10, %11, %arg1 : vector<16x32xf16>, vector<32x16xf16> into vector<16x16xf32> | ||
scf.yield %12 : vector<16x16xf32> | ||
} | ||
%9 = vector.transfer_write %8, %out[%c0, %c0] {in_bounds = [true, true]} : vector<16x16xf32>, tensor<16x16xf32> | ||
return %9 : tensor<16x16xf32> | ||
} | ||
|
||
#layout = #iree_vector_ext.nested_layout< | ||
subgroups_per_workgroup = [1, 1], | ||
batches_per_subgroup = [1, 1], | ||
outers_per_batch = [1, 1], | ||
threads_per_outer = [4, 16], | ||
elements_per_thread = [4, 1], | ||
|
||
// CHECK-LABEL: func.func @matmul_256x256x256 | ||
// CHECK: scf.for {{.*}} -> (vector<16x16xf32>) { | ||
// CHECK-DAG: %[[A:.*]] = vector.transfer_read %{{.*}} : tensor<16x256xf16>, vector<16x32xf16> | ||
// CHECK-DAG: %[[B:.*]] = vector.transfer_read %{{.*}} : tensor<256x16xf16>, vector<32x16xf16> | ||
// CHECK: gpu.barrier | ||
subgroup_strides = [1, 1], | ||
thread_strides = [0, 0] | ||
> | ||
|
||
// LHS copy. | ||
// CHECK: %[[PA:.*]] = bufferization.alloc_tensor() {memory_space = #gpu.address_space<workgroup>} : tensor<16x32xf16, #gpu.address_space<workgroup>> | ||
// CHECK: %[[LWRITE:.+]] = vector.transfer_write %[[A]], %[[PA]]{{.*}} : vector<16x32xf16>, tensor<16x32xf16, #gpu.address_space<workgroup>> | ||
// CHECK: %[[LCOPY:.+]] = bufferization.materialize_in_destination %[[LWRITE]] in %[[LWRITE]] | ||
func.func @test(%vector: vector<16x16xf16>) -> vector<16x16xf16> { | ||
%out = iree_vector_ext.to_layout %vector to #layout {shared_memory_conversion} : vector<16x16xf16> | ||
return %out : vector<16x16xf16> | ||
} | ||
|
||
// RHS copy. | ||
// CHECK: %[[PB:.*]] = bufferization.alloc_tensor() {memory_space = #gpu.address_space<workgroup>} : tensor<32x16xf16, #gpu.address_space<workgroup>> | ||
// CHECK: %[[RWRITE:.+]] = vector.transfer_write %[[B]], %[[PB]]{{.*}} : vector<32x16xf16>, tensor<32x16xf16, #gpu.address_space<workgroup>> | ||
// CHECK: %[[RCOPY:.+]] = bufferization.materialize_in_destination %[[RWRITE]] in %[[RWRITE]] | ||
// CHECK: gpu.barrier | ||
|
||
// CHECK: %[[LHS:.+]] = vector.transfer_read %[[LCOPY]]{{.*}} : tensor<16x32xf16, #gpu.address_space<workgroup>>, vector<16x32xf16> | ||
// CHECK: %[[RHS:.+]] = vector.transfer_read %[[RCOPY]]{{.*}} : tensor<32x16xf16, #gpu.address_space<workgroup>>, vector<32x16xf16> | ||
// CHECK: %12 = vector.contract {{.*}} %[[LHS]], %[[RHS]], %{{.*}} | ||
// CHECK-LABEL: func.func @test | ||
// CHECK: gpu.barrier | ||
// CHECK: %[[ALLOC:.+]] = bufferization.alloc_tensor() {memory_space = #gpu.address_space<workgroup>} : tensor<16x16xf16, #gpu.address_space<workgroup>> | ||
// CHECK: %[[WRITE:.+]] = vector.transfer_write %{{.*}}, %[[ALLOC]] | ||
// CHECK: %[[BAR:.+]] = iree_gpu.value_barrier %[[WRITE]] | ||
// CHECK: %[[READ:.+]] = vector.transfer_read %[[BAR]] | ||
// CHECK: %[[OUT:.+]] = iree_vector_ext.to_layout %[[READ]] |
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
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
Oops, something went wrong.