Skip to content

[mlir][tosa] Align shift attribute of TOSA_MulOp with the spec #67816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

GeorgeARM
Copy link
Contributor

According to specification the shift attribute of the Mul operator in TOSA is of signless i8 type instead of i32.

@llvmbot
Copy link
Member

llvmbot commented Sep 29, 2023

@llvm/pr-subscribers-mlir-tosa
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-linalg

Changes

According to specification the shift attribute of the Mul operator in TOSA is of signless i8 type instead of i32.


Full diff: https://github.com/llvm/llvm-project/pull/67816.diff

8 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td (+1-1)
  • (modified) mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir (+4-4)
  • (modified) mlir/test/Dialect/Tosa/broadcast.mlir (+1-1)
  • (modified) mlir/test/Dialect/Tosa/canonicalize.mlir (+5-5)
  • (modified) mlir/test/Dialect/Tosa/constant-op-fold.mlir (+10-10)
  • (modified) mlir/test/Dialect/Tosa/ops.mlir (+2-2)
  • (modified) mlir/test/Dialect/Tosa/tosa-decompose-depthwise.mlir (+2-2)
  • (modified) mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir (+6-6)
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index e7da35a0c8145ac..f4d9a251fb97839 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -798,7 +798,7 @@ def Tosa_MulOp : Tosa_ElementwiseOp<"mul", [
   let arguments = (ins
     Tosa_Tensor:$input1,
     Tosa_Tensor:$input2,
-    I32Attr:$shift
+    I8Attr:$shift
   );
 
   let results = (outs
diff --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
index b08f4969ef50813..8e0307085f1ce26 100644
--- a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
+++ b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
@@ -447,7 +447,7 @@ func.func @test_simple_f32(%arg0: tensor<1xf32>) -> () {
 
   // CHECK: linalg.generic
   // CHECK: arith.mulf
-  %4 = tosa.mul %0, %1 {shift = 0 : i32} : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
+  %4 = tosa.mul %0, %1 {shift = 0 : i8} : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
 
   // CHECK: linalg.generic
   // CHECK: arith.negf
@@ -570,7 +570,7 @@ func.func @test_simple_i16(%arg0: tensor<1xi16>) -> () {
   // CHECK: arith.extsi
   // CHECK: arith.extsi
   // CHECK: arith.muli
-  %0 = tosa.mul %arg0, %arg0 {shift = 0 : i32} : (tensor<1xi16>, tensor<1xi16>) -> tensor<1xi32>
+  %0 = tosa.mul %arg0, %arg0 {shift = 0 : i8} : (tensor<1xi16>, tensor<1xi16>) -> tensor<1xi32>
 
   return
 }
@@ -598,12 +598,12 @@ func.func @test_simple_i32(%arg0: tensor<1xi32>) -> () {
 
   // CHECK: linalg.generic
   // CHECK: arith.muli
-  %2 = tosa.mul %arg0, %arg0 {shift = 0 : i32} : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
+  %2 = tosa.mul %arg0, %arg0 {shift = 0 : i8} : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
 
   // CHECK: linalg.generic
   // CHECK: arith.constant 2
   // CHECK: apply_scale
-  %3 = tosa.mul %arg0, %arg0 {shift = 2 : i32} : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
+  %3 = tosa.mul %arg0, %arg0 {shift = 2 : i8} : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
 
   // CHECK: linalg.generic
   // CHECK: arith.divsi
diff --git a/mlir/test/Dialect/Tosa/broadcast.mlir b/mlir/test/Dialect/Tosa/broadcast.mlir
index 5dfd6433f5e3730..7613aa3b8dd03d1 100644
--- a/mlir/test/Dialect/Tosa/broadcast.mlir
+++ b/mlir/test/Dialect/Tosa/broadcast.mlir
@@ -174,7 +174,7 @@ func.func @test_broadcast20(%arg0: tensor<3x3x4x1xf32>, %arg1: tensor<4x5xf32>)
 func.func @test_broadcast_mul(%arg0: tensor<15x14xi32>, %arg1: tensor<17x16x15x14xi32>) -> tensor<17x16x15x14xi32> {
   // CHECK-DAG: %[[VAR0:.*]] = tosa.reshape %arg0 {new_shape = array<i64: 1, 1, 15, 14>}
   // CHECK: %[[VAR1:.*]] = tosa.mul %[[VAR0]], %arg1
-  %0 = tosa.mul %arg0, %arg1 {shift = 1 : i32 } : (tensor<15x14xi32>, tensor<17x16x15x14xi32>) -> tensor<17x16x15x14xi32>
+  %0 = tosa.mul %arg0, %arg1 {shift = 1 : i8 } : (tensor<15x14xi32>, tensor<17x16x15x14xi32>) -> tensor<17x16x15x14xi32>
   return %0 : tensor<17x16x15x14xi32>
 }
 
diff --git a/mlir/test/Dialect/Tosa/canonicalize.mlir b/mlir/test/Dialect/Tosa/canonicalize.mlir
index 5ed5a383c6f6fea..323864ea9013048 100644
--- a/mlir/test/Dialect/Tosa/canonicalize.mlir
+++ b/mlir/test/Dialect/Tosa/canonicalize.mlir
@@ -205,7 +205,7 @@ func.func @mul_one_float(%arg0: tensor<2x3xf32>) -> tensor<2x3xf32> {
   // CHECK: return %arg0
   // CHECK-NOT: tosa.mul
   %ones = "tosa.const"() {value = dense<1.0> : tensor<2x3xf32>} : () -> tensor<2x3xf32>
-  %1 = tosa.mul %arg0, %ones {shift = 0 : i32} : (tensor<2x3xf32>, tensor<2x3xf32>) -> tensor<2x3xf32>
+  %1 = tosa.mul %arg0, %ones {shift = 0 : i8} : (tensor<2x3xf32>, tensor<2x3xf32>) -> tensor<2x3xf32>
   return %1 : tensor<2x3xf32>
 }
 
@@ -214,7 +214,7 @@ func.func @mul_bcast_one_float(%arg0: tensor<2x3xf32>) -> tensor<2x3xf32> {
   // CHECK: return %arg0
   // CHECK-NOT: tosa.mul
   %ones = "tosa.const"() {value = dense<1.0> : tensor<1x1xf32>} : () -> tensor<1x1xf32>
-  %1 = tosa.mul %ones, %arg0 {shift = 0 : i32} : (tensor<1x1xf32>, tensor<2x3xf32>) -> tensor<2x3xf32>
+  %1 = tosa.mul %ones, %arg0 {shift = 0 : i8} : (tensor<1x1xf32>, tensor<2x3xf32>) -> tensor<2x3xf32>
   return %1 : tensor<2x3xf32>
 }
 
@@ -223,7 +223,7 @@ func.func @mul_one_int(%arg0: tensor<2x3xi32>) -> tensor<2x3xi32> {
   // CHECK: return %arg0
   // CHECK-NOT: tosa.mul
   %ones = "tosa.const"() {value = dense<1> : tensor<2x3xi32>} : () -> tensor<2x3xi32>
-  %1 = tosa.mul %arg0, %ones {shift = 0 : i32} : (tensor<2x3xi32>, tensor<2x3xi32>) -> tensor<2x3xi32>
+  %1 = tosa.mul %arg0, %ones {shift = 0 : i8} : (tensor<2x3xi32>, tensor<2x3xi32>) -> tensor<2x3xi32>
   return %1 : tensor<2x3xi32>
 }
 
@@ -232,11 +232,11 @@ func.func @mul_zero_broadcast(%arg0: tensor<2x3xf32>) -> (tensor<2x3xf32>, tenso
   // CHECK: %[[ZERO:.*]] = "tosa.const"() <{value = dense<0.000000e+00> : tensor<2x3xf32>}
   // CHECK-NOT: tosa.mul
   %zeros = "tosa.const"() {value = dense<0.0> : tensor<1x1xf32>} : () -> tensor<1x1xf32>
-  %1 = tosa.mul %arg0, %zeros {shift = 0 : i32} : (tensor<2x3xf32>, tensor<1x1xf32>) -> tensor<2x3xf32>
+  %1 = tosa.mul %arg0, %zeros {shift = 0 : i8} : (tensor<2x3xf32>, tensor<1x1xf32>) -> tensor<2x3xf32>
 
   // CHECK-NOT: tosa.mul
   // CHECK: return %[[ZERO]], %[[ZERO]]
-  %2 = tosa.mul %zeros, %arg0 {shift = 0 : i32} : (tensor<1x1xf32>, tensor<2x3xf32>) -> tensor<2x3xf32>
+  %2 = tosa.mul %zeros, %arg0 {shift = 0 : i8} : (tensor<1x1xf32>, tensor<2x3xf32>) -> tensor<2x3xf32>
   return %1, %2 : tensor<2x3xf32>, tensor<2x3xf32>
 }
 
diff --git a/mlir/test/Dialect/Tosa/constant-op-fold.mlir b/mlir/test/Dialect/Tosa/constant-op-fold.mlir
index e66082d83cb907e..56619fbc560e5fa 100644
--- a/mlir/test/Dialect/Tosa/constant-op-fold.mlir
+++ b/mlir/test/Dialect/Tosa/constant-op-fold.mlir
@@ -213,7 +213,7 @@ func.func @fold_div_splat_i32() -> tensor<i32> {
 func.func @fold_mul_zero_rhs_f32(%arg0: tensor<f32>) -> tensor<f32> {
   %zero = "tosa.const"() {value = dense<0.0> : tensor<f32>} : () -> tensor<f32>
   // CHECK: %[[ZERO:.+]] = "tosa.const"() <{value = dense<0.000000e+00>
-  %mul = tosa.mul %arg0, %zero {shift = 0 : i32} : (tensor<f32>, tensor<f32>) -> tensor<f32>
+  %mul = tosa.mul %arg0, %zero {shift = 0 : i8} : (tensor<f32>, tensor<f32>) -> tensor<f32>
   // CHECK: return %[[ZERO]]
   return %mul : tensor<f32>
 }
@@ -224,7 +224,7 @@ func.func @fold_mul_zero_rhs_f32(%arg0: tensor<f32>) -> tensor<f32> {
 func.func @fold_mul_zero_lhs_f32(%arg0: tensor<f32>) -> tensor<f32> {
   %zero = "tosa.const"() {value = dense<0.0> : tensor<f32>} : () -> tensor<f32>
   // CHECK: %[[ZERO:.+]] = "tosa.const"() <{value = dense<0.000000e+00>
-  %mul = tosa.mul %zero, %arg0 {shift = 0 : i32} : (tensor<f32>, tensor<f32>) -> tensor<f32>
+  %mul = tosa.mul %zero, %arg0 {shift = 0 : i8} : (tensor<f32>, tensor<f32>) -> tensor<f32>
   // CHECK: return %[[ZERO]]
   return %mul : tensor<f32>
 }
@@ -235,7 +235,7 @@ func.func @fold_mul_zero_lhs_f32(%arg0: tensor<f32>) -> tensor<f32> {
 func.func @fold_mul_zero_rhs_i32(%arg0: tensor<i32>) -> tensor<i32> {
   %zero = "tosa.const"() {value = dense<0> : tensor<i32>} : () -> tensor<i32>
   // CHECK: %[[ZERO:.+]] = "tosa.const"() <{value = dense<0>
-  %mul = tosa.mul %arg0, %zero {shift = 0 : i32} : (tensor<i32>, tensor<i32>) -> tensor<i32>
+  %mul = tosa.mul %arg0, %zero {shift = 0 : i8} : (tensor<i32>, tensor<i32>) -> tensor<i32>
   // CHECK: return %[[ZERO]]
   return %mul : tensor<i32>
 }
@@ -246,7 +246,7 @@ func.func @fold_mul_zero_rhs_i32(%arg0: tensor<i32>) -> tensor<i32> {
 func.func @fold_mul_zero_lhs_i32(%arg0: tensor<i32>) -> tensor<i32> {
   %zero = "tosa.const"() {value = dense<0> : tensor<i32>} : () -> tensor<i32>
   // CHECK: %[[ZERO:.+]] = "tosa.const"() <{value = dense<0>
-  %mul = tosa.mul %zero, %arg0 {shift = 0 : i32} : (tensor<i32>, tensor<i32>) -> tensor<i32>
+  %mul = tosa.mul %zero, %arg0 {shift = 0 : i8} : (tensor<i32>, tensor<i32>) -> tensor<i32>
   // CHECK: return %[[ZERO]]
   return %mul : tensor<i32>
 }
@@ -256,7 +256,7 @@ func.func @fold_mul_zero_lhs_i32(%arg0: tensor<i32>) -> tensor<i32> {
 // CHECK-LABEL: @fold_mul_one_rhs_f32
 func.func @fold_mul_one_rhs_f32(%arg0: tensor<f32>) -> tensor<f32> {
   %one = "tosa.const"() {value = dense<1.0> : tensor<f32>} : () -> tensor<f32>
-  %mul = tosa.mul %arg0, %one {shift = 0 : i32} : (tensor<f32>, tensor<f32>) -> tensor<f32>
+  %mul = tosa.mul %arg0, %one {shift = 0 : i8} : (tensor<f32>, tensor<f32>) -> tensor<f32>
   // CHECK: return %arg0
   return %mul : tensor<f32>
 }
@@ -266,7 +266,7 @@ func.func @fold_mul_one_rhs_f32(%arg0: tensor<f32>) -> tensor<f32> {
 // CHECK-LABEL: @fold_mul_one_lhs_f32
 func.func @fold_mul_one_lhs_f32(%arg0: tensor<f32>) -> tensor<f32> {
   %one = "tosa.const"() {value = dense<1.0> : tensor<f32>} : () -> tensor<f32>
-  %mul = tosa.mul %one, %arg0 {shift = 0 : i32} : (tensor<f32>, tensor<f32>) -> tensor<f32>
+  %mul = tosa.mul %one, %arg0 {shift = 0 : i8} : (tensor<f32>, tensor<f32>) -> tensor<f32>
   // CHECK: return %arg0
   return %mul : tensor<f32>
 }
@@ -276,7 +276,7 @@ func.func @fold_mul_one_lhs_f32(%arg0: tensor<f32>) -> tensor<f32> {
 // CHECK-LABEL: @fold_mul_one_rhs_i32
 func.func @fold_mul_one_rhs_i32(%arg0: tensor<i32>) -> tensor<i32> {
   %one = "tosa.const"() {value = dense<64> : tensor<i32>} : () -> tensor<i32>
-  %mul = tosa.mul %arg0, %one {shift = 6 : i32} : (tensor<i32>, tensor<i32>) -> tensor<i32>
+  %mul = tosa.mul %arg0, %one {shift = 6 : i8} : (tensor<i32>, tensor<i32>) -> tensor<i32>
   // CHECK: return %arg0
   return %mul : tensor<i32>
 }
@@ -286,7 +286,7 @@ func.func @fold_mul_one_rhs_i32(%arg0: tensor<i32>) -> tensor<i32> {
 // CHECK-LABEL: @fold_mul_one_lhs_i32
 func.func @fold_mul_one_lhs_i32(%arg0: tensor<i32>) -> tensor<i32> {
   %one = "tosa.const"() {value = dense<64> : tensor<i32>} : () -> tensor<i32>
-  %mul = tosa.mul %one, %arg0 {shift = 6 : i32} : (tensor<i32>, tensor<i32>) -> tensor<i32>
+  %mul = tosa.mul %one, %arg0 {shift = 6 : i8} : (tensor<i32>, tensor<i32>) -> tensor<i32>
   // CHECK: return %arg0
   return %mul : tensor<i32>
 }
@@ -297,7 +297,7 @@ func.func @fold_mul_one_lhs_i32(%arg0: tensor<i32>) -> tensor<i32> {
 func.func @fold_mul_splat_i8() -> tensor<10xi32> {
   %one = "tosa.const"() {value = dense<17> : tensor<10xi8>} : () -> tensor<10xi8>
   %two = "tosa.const"() {value = dense<32> : tensor<10xi8>} : () -> tensor<10xi8>
-  %mul = tosa.mul %one, %two {shift = 3 : i32} : (tensor<10xi8>, tensor<10xi8>) -> tensor<10xi32>
+  %mul = tosa.mul %one, %two {shift = 3 : i8} : (tensor<10xi8>, tensor<10xi8>) -> tensor<10xi32>
   // CHECK: %[[THREE:.+]] = "tosa.const"() <{value = dense<68> : tensor<10xi32>}
   // CHECK: return %[[THREE]]
   return %mul : tensor<10xi32>
@@ -309,7 +309,7 @@ func.func @fold_mul_splat_i8() -> tensor<10xi32> {
 func.func @fold_mul_splat_f32() -> tensor<10xf32> {
   %one = "tosa.const"() {value = dense<3.0> : tensor<10xf32>} : () -> tensor<10xf32>
   %two = "tosa.const"() {value = dense<2.0> : tensor<10xf32>} : () -> tensor<10xf32>
-  %mul = tosa.mul %one, %two {shift = 0 : i32} : (tensor<10xf32>, tensor<10xf32>) -> tensor<10xf32>
+  %mul = tosa.mul %one, %two {shift = 0 : i8} : (tensor<10xf32>, tensor<10xf32>) -> tensor<10xf32>
   // CHECK: %[[THREE:.+]] = "tosa.const"() <{value = dense<6.000000e+00> : tensor<10xf32>}
   // CHECK: return %[[THREE]]
   return %mul : tensor<10xf32>
diff --git a/mlir/test/Dialect/Tosa/ops.mlir b/mlir/test/Dialect/Tosa/ops.mlir
index 754843969ef8ef5..7d7f2d31a4244cd 100644
--- a/mlir/test/Dialect/Tosa/ops.mlir
+++ b/mlir/test/Dialect/Tosa/ops.mlir
@@ -224,14 +224,14 @@ func.func @test_min(%arg0: tensor<13x21x3xf32>, %arg1: tensor<1x21x3xf32>) -> te
 // -----
 // CHECK-LABEL: mul
 func.func @test_mul(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x1x3xf32>) -> tensor<13x21x3xf32> {
-  %0 = tosa.mul %arg0, %arg1 {shift = 1 : i32} : (tensor<13x21x3xf32>, tensor<13x1x3xf32>) -> tensor<13x21x3xf32>
+  %0 = tosa.mul %arg0, %arg1 {shift = 1 : i8} : (tensor<13x21x3xf32>, tensor<13x1x3xf32>) -> tensor<13x21x3xf32>
   return %0 : tensor<13x21x3xf32>
 }
 
 // -----
 // CHECK-LABEL: mul
 func.func @test_mul_relaxed_result_type(%arg0: tensor<13x21x3xi16>, %arg1: tensor<13x1x3xi16>) -> tensor<13x21x3xi16> {
-  %0 = "tosa.mul"(%arg0, %arg1)  { shift = 1 : i32 } : (tensor<13x21x3xi16>, tensor<13x1x3xi16>) -> tensor<13x21x3xi16>
+  %0 = "tosa.mul"(%arg0, %arg1)  { shift = 1 : i8 } : (tensor<13x21x3xi16>, tensor<13x1x3xi16>) -> tensor<13x21x3xi16>
   return %0 : tensor<13x21x3xi16>
 }
 
diff --git a/mlir/test/Dialect/Tosa/tosa-decompose-depthwise.mlir b/mlir/test/Dialect/Tosa/tosa-decompose-depthwise.mlir
index b3aed8ae84033e4..c86bf5d056f85ee 100644
--- a/mlir/test/Dialect/Tosa/tosa-decompose-depthwise.mlir
+++ b/mlir/test/Dialect/Tosa/tosa-decompose-depthwise.mlir
@@ -34,7 +34,7 @@ func.func @depthwise_conv2d_as_mul_q(%arg0: tensor<4x10x10x2xi8>, %arg1: tensor<
   // CHECK: %[[sIn:.+]] = tosa.sub %[[cIn]], %[[iZp]]
   // CHECK: %[[sWe:.+]] = tosa.sub %[[cWe]], %[[wZp]]
   // CHECK: %[[resWe:.+]] = tosa.reshape %[[sWe]] {new_shape = array<i64: 1, 1, 1, 2, 3>}
-  // CHECK: %[[mul:.+]] = tosa.mul %[[sIn]], %[[resWe]] {shift = 0 : i32}
+  // CHECK: %[[mul:.+]] = tosa.mul %[[sIn]], %[[resWe]] {shift = 0 : i8}
   // CHECK: %[[reO:.+]] = tosa.reshape %[[mul]] {new_shape = array<i64: 4, 10, 10, 6>}
   // CHECK: %[[reArg2:.+]] = tosa.reshape %arg2 {new_shape = array<i64: 1, 1, 1, 6>}
   // CHECK: %[[add:.+]] = tosa.add %[[reO]], %[[reArg2]]
@@ -51,7 +51,7 @@ func.func @depthwise_conv2d_as_mul_padded(%arg0: tensor<4x10x10x2xf32>, %arg1: t
   // CHECK: %[[reIn:.+]] = tosa.reshape %arg0 {new_shape = array<i64: 4, 10, 10, 2, 1>}
   // CHECK: %[[padded:.+]] = tosa.pad %[[reIn]], %[[pad]], %[[zero]] : (tensor<4x10x10x2x1xf32>, tensor<5x2xi64>, tensor<f32>) -> tensor<4x12x12x2x1xf32>
   // CHECK: %[[reArg1:.+]] = tosa.reshape %arg1 {new_shape = array<i64: 1, 1, 1, 2, 3>}
-  // CHECK: %[[mul:.+]] = tosa.mul %3, %[[reArg1]] {shift = 0 : i32}
+  // CHECK: %[[mul:.+]] = tosa.mul %3, %[[reArg1]] {shift = 0 : i8}
   // CHECK: %[[reOut:.+]] = tosa.reshape %[[mul]] {new_shape = array<i64: 4, 12, 12, 6>}
   // CHECK: %[[reArg2:.+]] = tosa.reshape %arg2 {new_shape = array<i64: 1, 1, 1, 6>}
   // CHECK: %[[add:.+]] = tosa.add %[[reOut]], %[[reArg2]]
diff --git a/mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir b/mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir
index d468ba582483cbe..1ce4defcf4a6e65 100644
--- a/mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir
+++ b/mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir
@@ -114,8 +114,8 @@ func.func @test_binary_scalar_f32(%arg0 : tensor<4xf32>, %arg1 : tensor<f32>) ->
   // CHECK: tosa.minimum %arg0, %arg1 : (tensor<4xf32>, tensor<f32>) -> tensor<4xf32>
   %2 = tosa.minimum %arg0, %arg1 : (tensor<4xf32>, tensor<f32>) -> tensor<*xf32>
 
-  // CHECK: tosa.mul %arg0, %arg1 {shift = 0 : i32} : (tensor<4xf32>, tensor<f32>) -> tensor<4xf32>
-  %3 = tosa.mul %arg0, %arg1 { shift = 0 : i32 } : (tensor<4xf32>, tensor<f32>) -> tensor<*xf32>
+  // CHECK: tosa.mul %arg0, %arg1 {shift = 0 : i8} : (tensor<4xf32>, tensor<f32>) -> tensor<4xf32>
+  %3 = tosa.mul %arg0, %arg1 { shift = 0 : i8 } : (tensor<4xf32>, tensor<f32>) -> tensor<*xf32>
 
   // CHECK: tosa.pow %arg0, %arg1 : (tensor<4xf32>, tensor<f32>) -> tensor<4xf32>
   %4 = tosa.pow %arg0, %arg1 : (tensor<4xf32>, tensor<f32>) -> tensor<*xf32>
@@ -148,8 +148,8 @@ func.func @test_binary_broadcast_f32(%arg0 : tensor<4xf32>, %arg1 : tensor<1xf32
   // CHECK: tosa.minimum %arg0, %arg1 : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xf32>
   %2 = tosa.minimum %arg0, %arg1 : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xf32>
 
-  // CHECK: tosa.mul %arg0, %arg1 {shift = 0 : i32} : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xf32>
-  %3 = tosa.mul %arg0, %arg1 { shift = 0 : i32 } : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xf32>
+  // CHECK: tosa.mul %arg0, %arg1 {shift = 0 : i8} : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xf32>
+  %3 = tosa.mul %arg0, %arg1 { shift = 0 : i8 } : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xf32>
 
   // CHECK: tosa.pow %arg0, %arg1 : (tensor<4xf32>, tensor<1xf32>) -> tensor<4xf32>
   %4 = tosa.pow %arg0, %arg1 : (tensor<4xf32>, tensor<1xf32>) -> tensor<*xf32>
@@ -206,8 +206,8 @@ func.func @test_binary_i32(%arg0 : tensor<4xi32>, %arg1 : tensor<i32>) -> () {
   // CHECK: tosa.minimum %arg0, %arg1 : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
   %10 = tosa.minimum %arg0, %arg1 : (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
 
-  // CHECK: tosa.mul %arg0, %arg1 {shift = 0 : i32} : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
-  %11 = tosa.mul %arg0, %arg1 { shift = 0 : i32 }: (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
+  // CHECK: tosa.mul %arg0, %arg1 {shift = 0 : i8} : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
+  %11 = tosa.mul %arg0, %arg1 { shift = 0 : i8 }: (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>
 
   // CHECK: tosa.pow %arg0, %arg1 : (tensor<4xi32>, tensor<i32>) -> tensor<4xi32>
   %12 = tosa.pow %arg0, %arg1 : (tensor<4xi32>, tensor<i32>) -> tensor<*xi32>

According to specification the `shift` attribute of the Mul operator in
TOSA is of signless i8 type instead of i32.

Signed-off-by: Georgios Pinitas <[email protected]>
@GeorgeARM GeorgeARM changed the title [mlir][tosa] Align shift attribute of TOSA_MulOp with the specifi… [mlir][tosa] Align shift attribute of TOSA_MulOp with the spec Sep 29, 2023
Copy link
Contributor

@eric-k256 eric-k256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eric-k256 eric-k256 merged commit 363c617 into llvm:main Oct 2, 2023
@GeorgeARM GeorgeARM deleted the tosa_mul_fix branch October 3, 2023 08:35
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 6, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 12, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 13, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
antiagainst pushed a commit to iree-org/llvm-project that referenced this pull request Oct 15, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/llvm-project that referenced this pull request Oct 16, 2023
… spec (llvm#67816)"

This reverts commit 363c617.

Temporarily reverting TOSA asm format change to let integrations catch up.
stellaraccident added a commit to iree-org/iree that referenced this pull request Oct 16, 2023
Carrying local reverts for:

* #15083 (fixes still being made)
* llvm/llvm-project#67816 while we sync to a
corresponding TF version
* llvm/llvm-project#67809, which has already
been reverted at HEAD and will drop on its own

Landing with local revert: #15207

---------

Co-authored-by: Kunwar Grover <[email protected]>
Co-authored-by: Julian Walker <[email protected]>
ramiro050 pushed a commit to ramiro050/iree that referenced this pull request Dec 19, 2023
Carrying local reverts for:

* iree-org#15083 (fixes still being made)
* llvm/llvm-project#67816 while we sync to a
corresponding TF version
* llvm/llvm-project#67809, which has already
been reverted at HEAD and will drop on its own

Landing with local revert: iree-org#15207

---------

Co-authored-by: Kunwar Grover <[email protected]>
Co-authored-by: Julian Walker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants