[Mlir-commits] [mlir] [TOSA] Introduce Tosa_ElementwiseUnaryOp with Type and Shape Enforcement (PR #115784)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Nov 11 14:49:10 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Peng Sun (psunn)
<details>
<summary>Changes</summary>
* Enforce that Tosa_ElementwiseUnaryOp requires output tensors to match the input tensor's type and shape.
* Update the following ops to conform to Tosa_ElementwiseUnaryOp: clamp, erf, sigmoid, tanh, cos, sin, abs, bitwise_not, ceil, clz, exp, floor, log, logical_not, negate, reciprocal, rsqrt.
* Add invalid tests for each operator to ensure compliance with TOSA v1.0 Specification.
---
Patch is 20.87 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/115784.diff
4 Files Affected:
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td (+5)
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td (+17-27)
- (modified) mlir/test/Dialect/Tosa/invalid.mlir (+252)
- (modified) mlir/test/Dialect/Tosa/ops.mlir (+1)
``````````diff
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td
index 67b41187e5bfb7..f5536927dc251d 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td
@@ -234,6 +234,11 @@ class Tosa_ElementwiseOp<string mnemonic, list<Trait> traits = []> :
"operands attr-dict `:` functional-type(operands, results)";
}
+class Tosa_ElementwiseUnaryOp<string mnemonic, list<Trait> traits = []> :
+ Tosa_ElementwiseOp<mnemonic, !listconcat(traits, [
+ SameOperandsAndResultShape,
+ SameOperandsAndResultElementType])> {}
+
class Tosa_InferTensorTypeOp<string mnemonic, list<Trait> traits = []>
: Tosa_Op<mnemonic, !listconcat(traits, [InferTensorTypeAdaptor, Pure])> {
let assemblyFormat =
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index 6e7d575ac26df1..db6c4732a15837 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -367,7 +367,7 @@ def Tosa_TransposeConv2DOp : Tosa_InferShapedTypeOp<"transpose_conv2d"> {
//===----------------------------------------------------------------------===//
// Operator: clamp
//===----------------------------------------------------------------------===//
-def Tosa_ClampOp : Tosa_ElementwiseOp<"clamp"> {
+def Tosa_ClampOp : Tosa_ElementwiseUnaryOp<"clamp"> {
let summary = "Computes clamp(features, min, max).";
let description = [{
@@ -397,7 +397,7 @@ def Tosa_ClampOp : Tosa_ElementwiseOp<"clamp"> {
//===----------------------------------------------------------------------===//
// Operator: sigmoid
//===----------------------------------------------------------------------===//
-def Tosa_SigmoidOp : Tosa_ElementwiseOp<"sigmoid"> {
+def Tosa_SigmoidOp : Tosa_ElementwiseUnaryOp<"sigmoid"> {
let summary = "Computes elementwise sigmoid of input.";
let description = [{
@@ -420,7 +420,7 @@ def Tosa_SigmoidOp : Tosa_ElementwiseOp<"sigmoid"> {
//===----------------------------------------------------------------------===//
// Operator: tanh
//===----------------------------------------------------------------------===//
-def Tosa_TanhOp : Tosa_ElementwiseOp<"tanh", [SameOperandsAndResultElementType]> {
+def Tosa_TanhOp : Tosa_ElementwiseUnaryOp<"tanh"> {
let summary = "Computes elementwise hyperbolic tangent of input";
let description = [{
@@ -442,10 +442,7 @@ def Tosa_TanhOp : Tosa_ElementwiseOp<"tanh", [SameOperandsAndResultElementType]>
//===----------------------------------------------------------------------===//
// Operator: erf
//===----------------------------------------------------------------------===//
-def Tosa_ErfOp : Tosa_Op<"erf", [
- DeclareOpInterfaceMethods<InferShapedTypeOpInterface,
- ["inferReturnTypeComponents"]>,
- Pure]> {
+def Tosa_ErfOp : Tosa_ElementwiseUnaryOp<"erf"> {
let summary = "Computes gauss error function of input";
let description = [{
@@ -906,7 +903,7 @@ def Tosa_TableOp : Tosa_InferShapedTypeOp<"table"> {
//===----------------------------------------------------------------------===//
// Operator: abs
//===----------------------------------------------------------------------===//
-def Tosa_AbsOp : Tosa_ElementwiseOp<"abs", [SameOperandsAndResultElementType]> {
+def Tosa_AbsOp : Tosa_ElementwiseUnaryOp<"abs"> {
let summary = "Elementwise abs op";
let description = [{
@@ -933,8 +930,7 @@ def Tosa_AbsOp : Tosa_ElementwiseOp<"abs", [SameOperandsAndResultElementType]> {
//===----------------------------------------------------------------------===//
// Operator: bitwise_not
//===----------------------------------------------------------------------===//
-def Tosa_BitwiseNotOp : Tosa_ElementwiseOp<"bitwise_not",
- [SameOperandsAndResultElementType]> {
+def Tosa_BitwiseNotOp : Tosa_ElementwiseUnaryOp<"bitwise_not"> {
let summary = "Bitwise NOT operator";
let description = [{
@@ -953,7 +949,7 @@ def Tosa_BitwiseNotOp : Tosa_ElementwiseOp<"bitwise_not",
//===----------------------------------------------------------------------===//
// Operator: ceil
//===----------------------------------------------------------------------===//
-def Tosa_CeilOp : Tosa_ElementwiseOp<"ceil", [SameOperandsAndResultElementType]> {
+def Tosa_CeilOp : Tosa_ElementwiseUnaryOp<"ceil"> {
let summary = "Elementwise ceil op";
let description = [{
@@ -972,7 +968,7 @@ def Tosa_CeilOp : Tosa_ElementwiseOp<"ceil", [SameOperandsAndResultElementType]>
//===----------------------------------------------------------------------===//
// Operator: clz
//===----------------------------------------------------------------------===//
-def Tosa_ClzOp : Tosa_ElementwiseOp<"clz", [SameOperandsAndResultElementType]> {
+def Tosa_ClzOp : Tosa_ElementwiseUnaryOp<"clz"> {
let summary = "Elementwise count leading zero op";
let description = [{
@@ -991,8 +987,7 @@ def Tosa_ClzOp : Tosa_ElementwiseOp<"clz", [SameOperandsAndResultElementType]> {
//===----------------------------------------------------------------------===//
// Operator: cos
//===----------------------------------------------------------------------===//
-def Tosa_CosOp : Tosa_ElementwiseOp<"cos",
- [SameOperandsAndResultElementType]> {
+def Tosa_CosOp : Tosa_ElementwiseUnaryOp<"cos"> {
let summary = "Elementwise cos op";
let description = [{
@@ -1011,7 +1006,7 @@ def Tosa_CosOp : Tosa_ElementwiseOp<"cos",
//===----------------------------------------------------------------------===//
// Operator: exp
//===----------------------------------------------------------------------===//
-def Tosa_ExpOp : Tosa_ElementwiseOp<"exp", [SameOperandsAndResultElementType]> {
+def Tosa_ExpOp : Tosa_ElementwiseUnaryOp<"exp"> {
let summary = "Elementwise exp op";
let description = [{
@@ -1032,7 +1027,7 @@ def Tosa_ExpOp : Tosa_ElementwiseOp<"exp", [SameOperandsAndResultElementType]> {
//===----------------------------------------------------------------------===//
// Operator: floor
//===----------------------------------------------------------------------===//
-def Tosa_FloorOp : Tosa_ElementwiseOp<"floor", [SameOperandsAndResultElementType]> {
+def Tosa_FloorOp : Tosa_ElementwiseUnaryOp<"floor"> {
let summary = "Elementwise floor op";
let description = [{
@@ -1051,7 +1046,7 @@ def Tosa_FloorOp : Tosa_ElementwiseOp<"floor", [SameOperandsAndResultElementType
//===----------------------------------------------------------------------===//
// Operator: log
//===----------------------------------------------------------------------===//
-def Tosa_LogOp : Tosa_ElementwiseOp<"log", [SameOperandsAndResultElementType]> {
+def Tosa_LogOp : Tosa_ElementwiseUnaryOp<"log"> {
let summary = "Elementwise log op";
let description = [{
@@ -1072,8 +1067,7 @@ def Tosa_LogOp : Tosa_ElementwiseOp<"log", [SameOperandsAndResultElementType]> {
//===----------------------------------------------------------------------===//
// Operator: logical_not
//===----------------------------------------------------------------------===//
-def Tosa_LogicalNotOp : Tosa_ElementwiseOp<"logical_not",
- [SameOperandsAndResultElementType]> {
+def Tosa_LogicalNotOp : Tosa_ElementwiseUnaryOp<"logical_not"> {
let summary = "Returns the truth value of NOT x element-wise.";
let description = [{
@@ -1092,8 +1086,7 @@ def Tosa_LogicalNotOp : Tosa_ElementwiseOp<"logical_not",
//===----------------------------------------------------------------------===//
// Operator: negate
//===----------------------------------------------------------------------===//
-def Tosa_NegateOp : Tosa_ElementwiseOp<"negate",
- [SameOperandsAndResultElementType]> {
+def Tosa_NegateOp : Tosa_ElementwiseUnaryOp<"negate"> {
let summary = "Elementwise negate op";
let description = [{
@@ -1117,8 +1110,7 @@ def Tosa_NegateOp : Tosa_ElementwiseOp<"negate",
//===----------------------------------------------------------------------===//
// Operator: reciprocal
//===----------------------------------------------------------------------===//
-def Tosa_ReciprocalOp : Tosa_ElementwiseOp<"reciprocal",
- [SameOperandsAndResultElementType]> {
+def Tosa_ReciprocalOp : Tosa_ElementwiseUnaryOp<"reciprocal"> {
let summary = "Elementwise reciprocal op";
let description = [{
@@ -1149,8 +1141,7 @@ def Tosa_ReciprocalOp : Tosa_ElementwiseOp<"reciprocal",
//===----------------------------------------------------------------------===//
// Operator: rsqrt
//===----------------------------------------------------------------------===//
-def Tosa_RsqrtOp : Tosa_ElementwiseOp<"rsqrt",
- [SameOperandsAndResultElementType]> {
+def Tosa_RsqrtOp : Tosa_ElementwiseUnaryOp<"rsqrt"> {
let summary = "Elementwise 1/sqrt op";
let description = [{
@@ -1170,8 +1161,7 @@ def Tosa_RsqrtOp : Tosa_ElementwiseOp<"rsqrt",
//===----------------------------------------------------------------------===//
// Operator: sin
//===----------------------------------------------------------------------===//
-def Tosa_SinOp : Tosa_ElementwiseOp<"sin",
- [SameOperandsAndResultElementType]> {
+def Tosa_SinOp : Tosa_ElementwiseUnaryOp<"sin"> {
let summary = "Elementwise sin op";
let description = [{
diff --git a/mlir/test/Dialect/Tosa/invalid.mlir b/mlir/test/Dialect/Tosa/invalid.mlir
index c7a1e9b8770914..79bb7fce5755ef 100644
--- a/mlir/test/Dialect/Tosa/invalid.mlir
+++ b/mlir/test/Dialect/Tosa/invalid.mlir
@@ -628,3 +628,255 @@ func.func @test_unsupported_int64_data_type(%arg0: tensor<1x13x13x5xf32>) -> ten
// expected-error at +1 {{'func.return' op is not profile-aligned: element type 'i64' is not legal}}
return %0 : tensor<1x13x13xi64>
}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_data_type_clamp
+func.func @test_mismatch_in_out_data_type_clamp(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.clamp' op requires the same element type for all operands and results}}
+ %0 = tosa.clamp %arg0 {min_fp = 0.0 : f32, max_fp = 1.0: f32, min_int = 0 : i64, max_int = 1 : i64} : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_shape_clamp
+func.func @test_mismatch_in_out_shape_clamp(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.clamp' op requires the same shape for all operands and results}}
+ %0 = tosa.clamp %arg0 {min_fp = 0.0 : f32, max_fp = 1.0: f32, min_int = 0 : i64, max_int = 1 : i64} : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_data_type_erf
+func.func @test_mismatch_in_out_data_type_erf(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.erf' op requires the same element type for all operands and results}}
+ %0 = tosa.erf %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_shape_erf
+func.func @test_mismatch_in_out_shape_erf(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.erf' op requires the same shape for all operands and results}}
+ %0 = tosa.erf %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_data_type_sigmoid
+func.func @test_mismatch_in_out_data_type_sigmoid(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.sigmoid' op requires the same element type for all operands and results}}
+ %0 = tosa.sigmoid %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_shape_sigmoid
+func.func @test_mismatch_in_out_shape_sigmoid(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.sigmoid' op requires the same shape for all operands and results}}
+ %0 = tosa.sigmoid %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_data_type_tanh
+func.func @test_mismatch_in_out_data_type_tanh(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.tanh' op requires the same element type for all operands and results}}
+ %0 = tosa.tanh %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_shape_tanh
+func.func @test_mismatch_in_out_shape_tanh(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.tanh' op requires the same shape for all operands and results}}
+ %0 = tosa.tanh %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_data_type_cos
+func.func @test_mismatch_in_out_data_type_cos(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.cos' op requires the same element type for all operands and results}}
+ %0 = tosa.cos %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_shape_cos
+func.func @test_mismatch_in_out_shape_cos(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.cos' op requires the same shape for all operands and results}}
+ %0 = tosa.cos %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_data_type_sin
+func.func @test_mismatch_in_out_data_type_sin(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.sin' op requires the same element type for all operands and results}}
+ %0 = tosa.sin %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_shape_sin
+func.func @test_mismatch_in_out_shape_sin(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.sin' op requires the same shape for all operands and results}}
+ %0 = tosa.sin %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_data_type_abs
+func.func @test_mismatch_in_out_data_type_abs(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.abs' op requires the same element type for all operands and results}}
+ %0 = tosa.abs %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_shape_abs
+func.func @test_mismatch_in_out_shape_abs(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.abs' op requires the same shape for all operands and results}}
+ %0 = tosa.abs %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_data_type_bitwise_not
+func.func @test_mismatch_in_out_data_type_bitwise_not(%arg0: tensor<13x21x1xi32>) -> tensor<13x21x1xi16> {
+ // expected-error at +1 {{'tosa.bitwise_not' op requires the same element type for all operands and results}}
+ %0 = tosa.bitwise_not %arg0 : (tensor<13x21x1xi32>) -> tensor<13x21x1xi16>
+ return %0 : tensor<13x21x1xi16>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_shape_bitwise_not
+func.func @test_mismatch_in_out_shape_bitwise_not(%arg0: tensor<13x21x1xi32>) -> tensor<13x21x3xi32> {
+ // expected-error at +1 {{'tosa.bitwise_not' op requires the same shape for all operands and results}}
+ %0 = tosa.bitwise_not %arg0 : (tensor<13x21x1xi32>) -> tensor<13x21x3xi32>
+ return %0 : tensor<13x21x3xi32>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_data_type_ceil
+func.func @test_mismatch_in_out_data_type_ceil(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.ceil' op requires the same element type for all operands and results}}
+ %0 = tosa.ceil %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_shape_ceil
+func.func @test_mismatch_in_out_shape_ceil(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.ceil' op requires the same shape for all operands and results}}
+ %0 = tosa.ceil %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_data_type_clz
+func.func @test_mismatch_in_out_data_type_clz(%arg0: tensor<13x21x3xi32>) -> tensor<13x21x3xi16> {
+ // expected-error at +1 {{'tosa.clz' op requires the same element type for all operands and results}}
+ %0 = tosa.clz %arg0 : (tensor<13x21x3xi32>) -> tensor<13x21x3xi16>
+ return %0 : tensor<13x21x3xi16>
+}
+
+// -----
+
+// CHECK-LABEL: test_mismatch_in_out_shape_clz
+func.func @test_mismatch_in_out_shape_clz(%arg0: tensor<13x21x3xi32>) -> tensor<13x21x1xi32> {
+ // expected-error at +1 {{'tosa.clz' op requires the same shape for all operands and results}}
+ %0 = tosa.clz %arg0 : (tensor<13x21x3xi32>) -> tensor<13x21x1xi32>
+ return %0 : tensor<13x21x1xi32>
+}
+
+// -----
+// CHECK-LABEL: test_mismatch_in_out_data_type_cos
+func.func @test_mismatch_in_out_data_type_cos(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.cos' op requires the same element type for all operands and results}}
+ %0 = tosa.cos %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+// CHECK-LABEL: test_mismatch_in_out_shape_cos
+func.func @test_mismatch_in_out_shape_cos(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.cos' op requires the same shape for all operands and results}}
+ %0 = tosa.cos %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+// CHECK-LABEL: test_mismatch_in_out_data_type_exp
+func.func @test_mismatch_in_out_data_type_exp(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.exp' op requires the same element type for all operands and results}}
+ %0 = tosa.exp %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+// CHECK-LABEL: test_mismatch_in_out_shape_exp
+func.func @test_mismatch_in_out_shape_exp(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.exp' op requires the same shape for all operands and results}}
+ %0 = tosa.exp %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+// CHECK-LABEL: test_mismatch_in_out_data_type_floor
+func.func @test_mismatch_in_out_data_type_floor(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.floor' op requires the same element type for all operands and results}}
+ %0 = tosa.floor %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+// CHECK-LABEL: test_mismatch_in_out_shape_floor
+func.func @test_mismatch_in_out_shape_floor(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.floor' op requires the same shape for all operands and results}}
+ %0 = tosa.floor %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+// CHECK-LABEL: test_mismatch_in_out_data_type_log
+func.func @test_mismatch_in_out_data_type_log(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf16> {
+ // expected-error at +1 {{'tosa.log' op requires the same element type for all operands and results}}
+ %0 = tosa.log %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf16>
+ return %0 : tensor<13x21x3xf16>
+}
+
+// -----
+// CHECK-LABEL: test_mismatch_in_out_shape_log
+func.func @test_mismatch_in_out_shape_log(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x1xf32> {
+ // expected-error at +1 {{'tosa.log' op requires the same shape for all operands and results}}
+ %0 = tosa.log %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x1xf32>
+ return %0 : tensor<13x21x1xf32>
+}
+
+// -----
+// CHECK-LABEL...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/115784
More information about the Mlir-commits
mailing list