-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows decomposing the op, i.e. inlining the region of the `custom_op` into the parent region, and removal of the op. Also add a TD op for testing. Signed-off-by: MaheshRavishankar <mahesh.ravishankar@gmail.com>
- Loading branch information
1 parent
598a60e
commit 5f3f863
Showing
13 changed files
with
192 additions
and
7 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
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
62 changes: 62 additions & 0 deletions
62
compiler/src/iree/compiler/Dialect/LinalgExt/Transforms/test/decompose_aggregate_op.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,62 @@ | ||
// RUN: iree-opt --iree-transform-dialect-interpreter --canonicalize --mlir-print-local-scope --split-input-file %s | FileCheck %s | ||
|
||
func.func @custom_op_decomposition(%lhs1 : tensor<1000000x?xf32>, | ||
%rhs1 : tensor<?x?xf32>, %rhs2 : tensor<?x?xf32>, %scalar : f32, | ||
%outs1 : tensor<1000000x?xf32>, %outs2 : tensor<1000000x?xf32>) | ||
-> (tensor<1000000x?xf32>, tensor<1000000x?xf32>) { | ||
%0:2 = iree_linalg_ext.custom_op { | ||
indexing_maps = [affine_map<(d0, d1)[s0, s1] -> (d0, s0)>, | ||
affine_map<(d0, d1)[s0, s1] -> (s0, s1)>, | ||
affine_map<(d0, d1)[s0, s1] -> (s1, d1)>, | ||
affine_map<(d0, d1)[s0, s1] -> ()>, | ||
affine_map<(d0, d1)[s0, s1] -> (d0, s1)>, | ||
affine_map<(d0, d1)[s0, s1] -> (d0, d1)>], | ||
iterator_types = [#iree_linalg_ext.iterator_type<parallel>, | ||
#iree_linalg_ext.iterator_type<parallel>]} | ||
ins(%lhs1, %rhs1, %rhs2, %scalar | ||
: tensor<1000000x?xf32>, tensor<?x?xf32>, tensor<?x?xf32>, f32) | ||
outs(%outs1, %outs2 : tensor<1000000x?xf32>, tensor<1000000x?xf32>) { | ||
^bb0(%t0 : tensor<?x?xf32>, %t1 : tensor<?x?xf32>, %t2 : tensor<?x?xf32>, | ||
%s : f32, %t3 : tensor<?x?xf32>, %t4 : tensor<?x?xf32>) : | ||
%0 = linalg.matmul ins(%t0, %t1 : tensor<?x?xf32>, tensor<?x?xf32>) | ||
outs(%t3 : tensor<?x?xf32>) -> tensor<?x?xf32> | ||
%1 = linalg.matmul ins(%0, %t2 : tensor<?x?xf32>, tensor<?x?xf32>) | ||
outs(%t4 : tensor<?x?xf32>) -> tensor<?x?xf32> | ||
%2 = linalg.generic { | ||
indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, | ||
affine_map<(d0, d1) -> ()>, | ||
affine_map<(d0, d1) -> (d0, d1)>], | ||
iterator_types = ["parallel", "parallel"]} | ||
ins(%1, %s : tensor<?x?xf32>, f32) outs(%1 : tensor<?x?xf32>) { | ||
^bb0(%b0 : f32, %b1 : f32, %b2 :f32): | ||
%3 = arith.addf %b0, %b2 : f32 | ||
linalg.yield %3 : f32 | ||
} -> tensor<?x?xf32> | ||
iree_linalg_ext.yield %0, %2 : tensor<?x?xf32>, tensor<?x?xf32> | ||
} -> tensor<1000000x?xf32>, tensor<1000000x?xf32> | ||
return %0#0, %0#1 : tensor<1000000x?xf32>, tensor<1000000x?xf32> | ||
} | ||
module attributes { transform.with_named_sequence } { | ||
transform.named_sequence @__transform_main(%module_op: !transform.any_op {transform.readonly}) { | ||
%0 = transform.structured.match ops{["iree_linalg_ext.custom_op"]} in %module_op : (!transform.any_op) -> !transform.any_op | ||
transform.iree.decompose_aggregate_op %0 : (!transform.any_op) -> () | ||
transform.yield | ||
} | ||
} | ||
// CHECK-LABEL: func @custom_op_decomposition( | ||
// CHECK-SAME: %[[LHS1:[a-zA-Z0-9]+]]: tensor<1000000x?xf32> | ||
// CHECK-SAME: %[[RHS1:[a-zA-Z0-9]+]]: tensor<?x?xf32> | ||
// CHECK-SAME: %[[RHS2:[a-zA-Z0-9]+]]: tensor<?x?xf32> | ||
// CHECK-SAME: %[[SCALAR:[a-zA-Z0-9]+]]: f32 | ||
// CHECK-SAME: %[[INIT1:[a-zA-Z0-9]+]]: tensor<1000000x?xf32> | ||
// CHECK-SAME: %[[INIT2:[a-zA-Z0-9]+]]: tensor<1000000x?xf32> | ||
// CHECK: %[[MATMUL1:.+]] = linalg.matmul | ||
// CHECK-SAME: ins(%[[LHS1]], %[[RHS1]] : | ||
// CHECK-SAME: outs(%[[INIT1]] : | ||
// CHECK: %[[MATMUL2:.+]] = linalg.matmul | ||
// CHECK-SAME: ins(%[[MATMUL1]], %[[RHS2]] : | ||
// CHECK-SAME: outs(%[[INIT2]] : | ||
// CHECK: %[[GENERIC:.+]] = linalg.generic | ||
// CHECK-SAME: ins(%[[MATMUL2]], %[[SCALAR]] : | ||
// CHECK-SAME: outs(%[[MATMUL2]] : | ||
// CHECK: return %[[MATMUL1]], %[[GENERIC]] |