forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LLVMCPU] Add an option for tiling reduction only to LLVMCPUTile. (ir…
…ee-org#13821) If the option is true, only tile the ops that has reduction loops. It is useful because it allows us to tile on reduction ops firstly and tileAndFuse on other operations later. We can greedily apply tileAndFuse on consumers because the reduction op will no longer be pulled in. There is a scf.for as barrier to stop fusion on reductions. The changes to LLVMTileAndFuse is needed together because we follow the same pipeline behavior. Now we need to use TileAndFuse in last level of tiling for consumers. If there are no consumers, it will not be applied on reduction ops. It is a step toward iree-org#13706 and iree-org#13474
- Loading branch information
1 parent
5435c54
commit 7297be0
Showing
8 changed files
with
83 additions
and
8 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// RUN: iree-opt --pass-pipeline="builtin.module(func.func(iree-llvmcpu-tile{tiling-level=0}))" --split-input-file %s | FileCheck %s | ||
// RUN: iree-opt --pass-pipeline="builtin.module(func.func(iree-llvmcpu-tile{tiling-level=0 reduction-only=true}))" --split-input-file %s | FileCheck %s --check-prefix=CHECK-REDUCTION | ||
|
||
func.func @matmul_bias_add(%arg0 : tensor<?x?xf32>, %arg1 : tensor<?x?xf32>, %arg2 : tensor<?xf32>) -> tensor<?x?xf32> { | ||
%cst = arith.constant 0.0 : f32 | ||
%c0 = arith.constant 0 : index | ||
%c1 = arith.constant 1 : index | ||
%d0 = tensor.dim %arg0, %c0 : tensor<?x?xf32> | ||
%d1 = tensor.dim %arg1, %c1 : tensor<?x?xf32> | ||
%init = tensor.empty(%d0, %d1) : tensor<?x?xf32> | ||
%0 = linalg.fill ins(%cst : f32) outs(%init : tensor<?x?xf32>) -> tensor<?x?xf32> | ||
%1 = linalg.matmul {lowering_config = #iree_codegen.lowering_config<tile_sizes = [[10, 20, 30]]>} | ||
ins(%arg0, %arg1 : tensor<?x?xf32>, tensor<?x?xf32>) | ||
outs(%0 : tensor<?x?xf32>) -> tensor<?x?xf32> | ||
%2 = linalg.generic { | ||
indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d1)>, affine_map<(d0, d1)-> (d0, d1)>], | ||
iterator_types = ["parallel", "parallel"]} | ||
ins(%1, %arg2 : tensor<?x?xf32>, tensor<?xf32>) | ||
outs(%init : tensor<?x?xf32>) { | ||
^bb0(%arg3: f32, %arg4: f32, %arg5: f32): | ||
%3 = arith.addf %arg3, %arg4 : f32 | ||
linalg.yield %3 : f32 | ||
} -> tensor<?x?xf32> | ||
return %2 : tensor<?x?xf32> | ||
} | ||
// CHECK-LABEL: func.func @matmul_bias_add( | ||
// CHECK: scf.for | ||
// CHECK: scf.for | ||
// CHECK: linalg.fill | ||
// CHECK: scf.for | ||
// CHECK: scf.for | ||
// CHECK: scf.for | ||
// CHECK: linalg.matmul | ||
// CHECK: scf.for | ||
// CHECK: scf.for | ||
// CHECK: linalg.generic | ||
// CHECK-REDUCTION-LABEL: func.func @matmul_bias_add( | ||
// CHECK-REDUCTION: linalg.fill | ||
// CHECK-REDUCTION: scf.for | ||
// CHECK-REDUCTION: scf.for | ||
// CHECK-REDUCTION: scf.for | ||
// CHECK-REDUCTION: linalg.matmul | ||
// CHECK-REDUCITON-NOT: scf.for | ||
// CHECK-REDUCTION: linalg.generic |
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