Skip to content

Commit 69d97a6

Browse files
authored
[mlir][tosa] Remove Tosa MulOp Commutative attribute (#163312)
The patch motivates by following cases in Tosa Conformance Test. conformance/operators/ew_binary/mul/mul_21x44_i8_perm0_shift0_dyn conformance/operators/ew_binary/mul/mul_44x57_i16_perm0_shift0_dyn conformance/operators/ew_binary/mul/mul_52x31_i32_perm0_shift8_dyn Shift operand could be non-constant when dynamic extension enabled. With Commutative attribute, all the operands would be treated as commutative. Shift operand could be reordered with one of the MulOp inputs incorrectly in above cases. Would there have better way to fix the issue?
1 parent 9c3ed5a commit 69d97a6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,6 @@ def Tosa_MinimumOp : Tosa_ElementwiseOp<"minimum", [
10271027
def Tosa_MulOp : Tosa_Op<"mul", [
10281028
DeclareOpInterfaceMethods<InferShapedTypeOpInterface,
10291029
["inferReturnTypeComponents"]>,
1030-
Commutative,
10311030
Pure]> {
10321031
let summary = "Multiplication operator.";
10331032

mlir/test/Dialect/Tosa/constant-op-fold.mlir

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,3 +1172,15 @@ func.func @reduce_sum_constant_aggressive() -> tensor<2x3xi32> {
11721172
%res1 = tosa.add %res0, %argmax1 : (tensor<2x3xi32>, tensor<2x3xi32>) -> tensor<2x3xi32>
11731173
return %res1 : tensor<2x3xi32>
11741174
}
1175+
1176+
// -----
1177+
1178+
// no_shift_op_reorder checks that %arg1 won't be reorder with %0
1179+
// by the folder pass.
1180+
// CHECK-LABEL: @no_shift_op_reorder
1181+
func.func @no_shift_op_reorder (%arg0 : tensor<44x1xi16>, %arg1 : tensor<1xi8>) -> tensor<44x57xi32> {
1182+
%0 = "tosa.const"() {values = dense<1> : tensor<44x57xi16>} : () -> tensor<44x57xi16>
1183+
// CHECK: tosa.mul %arg0, %0, %arg1
1184+
%1 = tosa.mul %arg0, %0, %arg1 : (tensor<44x1xi16>, tensor<44x57xi16>, tensor<1xi8>) -> tensor<44x57xi32>
1185+
return %1 : tensor<44x57xi32>
1186+
}

0 commit comments

Comments
 (0)