[Mlir-commits] [mlir] [MLIR][TOSA] Enable strict property assembly format (PR #217291)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Aug 19 03:53:37 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-tosa
Author: Mehdi Amini (joker-eph)
<details>
<summary>Changes</summary>
Enable strict properties-in-assembly-format mode for TOSA. Bind TOSA operation properties directly in declarative assembly formats so strict parsing does not rely on property dictionaries.
Update the TOSA tests to use the direct property spelling.
Assisted-by: Codex
---
Patch is 1.22 MiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/217291.diff
45 Files Affected:
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td (+2-4)
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td (+86-18)
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaShapeOps.td (+13)
- (modified) mlir/lib/Dialect/Tosa/IR/TosaOps.cpp (+16)
- (modified) mlir/test/Conversion/TosaToArith/tosa-to-arith.mlir (+1-1)
- (modified) mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-invalid.mlir (+7-7)
- (modified) mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-named.mlir (+33-33)
- (modified) mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-pipeline.mlir (+1-1)
- (modified) mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-resize.mlir (+57-57)
- (modified) mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir (+83-83)
- (modified) mlir/test/Conversion/TosaToSCF/tosa-to-scf.mlir (+2-2)
- (modified) mlir/test/Conversion/TosaToTensor/tosa-to-tensor-invalid.mlir (+2-2)
- (modified) mlir/test/Conversion/TosaToTensor/tosa-to-tensor.mlir (+52-52)
- (modified) mlir/test/Dialect/MemRef/resolve-dim-ops.mlir (+2-2)
- (modified) mlir/test/Dialect/Tosa/canonicalize.mlir (+310-310)
- (modified) mlir/test/Dialect/Tosa/constant-reciprocal-fold.mlir (+9-9)
- (modified) mlir/test/Dialect/Tosa/constant_folding.mlir (+257-257)
- (modified) mlir/test/Dialect/Tosa/dynamic_extension.mlir (+16-16)
- (modified) mlir/test/Dialect/Tosa/error_if_check.mlir (+65-65)
- (modified) mlir/test/Dialect/Tosa/inlining.mlir (+1-1)
- (modified) mlir/test/Dialect/Tosa/invalid.mlir (+251-251)
- (modified) mlir/test/Dialect/Tosa/invalid_extension.mlir (+84-84)
- (modified) mlir/test/Dialect/Tosa/level_check.mlir (+203-203)
- (modified) mlir/test/Dialect/Tosa/ops.mlir (+234-234)
- (modified) mlir/test/Dialect/Tosa/profile_all_unsupported.mlir (+26-26)
- (modified) mlir/test/Dialect/Tosa/profile_pro_fp_unsupported.mlir (+27-27)
- (modified) mlir/test/Dialect/Tosa/profile_pro_int_unsupported.mlir (+32-32)
- (modified) mlir/test/Dialect/Tosa/quant-test.mlir (+3-3)
- (modified) mlir/test/Dialect/Tosa/tosa-convert-integer-type-to-signless.mlir (+1-1)
- (modified) mlir/test/Dialect/Tosa/tosa-decompose-depthwise.mlir (+25-25)
- (modified) mlir/test/Dialect/Tosa/tosa-decompose-transpose-conv.mlir (+61-67)
- (modified) mlir/test/Dialect/Tosa/tosa-infer-shapes-fold-shape-expressions.mlir (+9-9)
- (modified) mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir (+254-254)
- (modified) mlir/test/Dialect/Tosa/tosa-layerwise-constant-fold.mlir (+53-53)
- (modified) mlir/test/Dialect/Tosa/tosa-narrow-f64-to-f32.mlir (+11-11)
- (modified) mlir/test/Dialect/Tosa/tosa-narrow-i64-to-i32.mlir (+16-16)
- (modified) mlir/test/Dialect/Tosa/tosa-reduce-transposes.mlir (+115-115)
- (modified) mlir/test/Dialect/Tosa/tosa-validation-valid-strict.mlir (+2-2)
- (modified) mlir/test/Dialect/Tosa/tosa-validation-valid.mlir (+3-3)
- (modified) mlir/test/Dialect/Tosa/tosa-validation-version-1p0-invalid.mlir (+23-23)
- (modified) mlir/test/Dialect/Tosa/tosa-validation-version-1p1-invalid.mlir (+10-10)
- (modified) mlir/test/Dialect/Tosa/tosa-validation-version-1p1-pro-fp-valid.mlir (+2-2)
- (modified) mlir/test/Dialect/Tosa/tosa-validation-version-1p1-valid.mlir (+57-57)
- (modified) mlir/test/Dialect/Tosa/transpose-fold.mlir (+9-9)
- (modified) mlir/test/Dialect/Tosa/verifier.mlir (+254-254)
``````````diff
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td
index 63acbb09b7a04..9733982a6ef0e 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td
@@ -53,6 +53,7 @@ def Tosa_Dialect : Dialect {
let hasConstantMaterializer = 1;
let useDefaultAttributePrinterParser = 1;
let useDefaultTypePrinterParser = 1;
+ let useStrictPropertiesInAssemblyFormat = 1;
}
//===----------------------------------------------------------------------===//
@@ -486,9 +487,6 @@ class Tosa_InferShapedTypeOp<string mnemonic, list<Trait> traits = []>
// for multiple zero points in convolution ops.
class Tosa_ConvOp<string mnemonic, list<Trait> traits = []>
: Tosa_InferShapedTypeOp<mnemonic, !listconcat(traits,
- [SameVariadicOperandSize, NoMemoryEffect])> {
- let assemblyFormat =
- "operands attr-dict `:` functional-type(operands, results)";
-}
+ [SameVariadicOperandSize, NoMemoryEffect])> {}
#endif // TOSA_OP_BASE
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index 2edacfa02b576..22d8ec983497d 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -109,7 +109,11 @@ def Tosa_AvgPool2dOp : Tosa_InferShapedTypeOp<"avg_pool2d", [NoMemoryEffect]> {
let hasCanonicalizer = 1;
let assemblyFormat =
- "operands attr-dict `:` functional-type(operands, results)";
+ "operands `kernel` `(` custom<TosaAttr>($kernel) `)` "
+ "`stride` `(` custom<TosaAttr>($stride) `)` "
+ "`pad` `(` custom<TosaAttr>($pad) `)` "
+ "`acc_type` `(` custom<TosaAttr>($acc_type) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -149,7 +153,8 @@ def Tosa_AvgPool2dAdaptiveOp
let hasCanonicalizer = 1;
let assemblyFormat =
- "operands attr-dict `:` functional-type(operands, results)";
+ "operands `acc_type` `(` custom<TosaAttr>($acc_type) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -196,6 +201,15 @@ def Tosa_Conv2DOp : Tosa_ConvOp<"conv2d"> {
let hasCanonicalizer = 1;
let hasVerifier = 1;
+
+ let assemblyFormat =
+ "operands `pad` `(` custom<TosaAttr>($pad) `)` "
+ "`stride` `(` custom<TosaAttr>($stride) `)` "
+ "`dilation` `(` custom<TosaAttr>($dilation) `)` "
+ "`acc_type` `(` custom<TosaAttr>($acc_type) `)` "
+ "oilist(`local_bound` `(` custom<TosaAttr>($local_bound) `)`) "
+ "attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -278,6 +292,15 @@ def Tosa_Conv3DOp : Tosa_ConvOp<"conv3d"> {
let builders = [Tosa_ConvOpQuantInfoBuilder];
let hasVerifier = 1;
+
+ let assemblyFormat =
+ "operands `pad` `(` custom<TosaAttr>($pad) `)` "
+ "`stride` `(` custom<TosaAttr>($stride) `)` "
+ "`dilation` `(` custom<TosaAttr>($dilation) `)` "
+ "`acc_type` `(` custom<TosaAttr>($acc_type) `)` "
+ "oilist(`local_bound` `(` custom<TosaAttr>($local_bound) `)`) "
+ "attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -324,6 +347,15 @@ def Tosa_DepthwiseConv2DOp : Tosa_ConvOp<"depthwise_conv2d"> {
let hasCanonicalizer = 1;
let hasVerifier = 1;
+
+ let assemblyFormat =
+ "operands `pad` `(` custom<TosaAttr>($pad) `)` "
+ "`stride` `(` custom<TosaAttr>($stride) `)` "
+ "`dilation` `(` custom<TosaAttr>($dilation) `)` "
+ "`acc_type` `(` custom<TosaAttr>($acc_type) `)` "
+ "oilist(`local_bound` `(` custom<TosaAttr>($local_bound) `)`) "
+ "attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -364,14 +396,18 @@ def Tosa_FFT2dOp : Tosa_InferShapedTypeOp<"fft2d", [
);
let assemblyFormat = [{
- $input_real `,` $input_imag attr-dict `:` `(` type($input_real) `,`
+ $input_real `,` $input_imag `inverse` `(` custom<TosaAttr>($inverse) `)`
+ oilist(`local_bound` `(` custom<TosaAttr>($local_bound) `)`) attr-dict `:` `(` type($input_real) `,`
type($input_imag) `)` `->` `(` type($output_real) `,` type($output_imag) `)`
}];
let hasVerifier = 1;
let assemblyFormat =
- "operands attr-dict `:` functional-type(operands, results)";
+ "operands `inverse` `(` custom<TosaAttr>($inverse) `)` "
+ "oilist(`local_bound` `(` custom<TosaAttr>($local_bound) `)`) "
+ "attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -578,13 +614,15 @@ def Tosa_RFFT2dOp : Tosa_InferShapedTypeOp<"rfft2d", [
);
let assemblyFormat = [{
- $input_real attr-dict `:` `(` type($input_real) `)` `->` `(` type($output_real) `,` type($output_imag) `)`
+ $input_real oilist(`local_bound` `(` custom<TosaAttr>($local_bound) `)`) attr-dict `:`
+ `(` type($input_real) `)` `->` `(` type($output_real) `,` type($output_imag) `)`
}];
let hasVerifier = 1;
let assemblyFormat =
- "operands attr-dict `:` functional-type(operands, results)";
+ "operands oilist(`local_bound` `(` custom<TosaAttr>($local_bound) `)`) attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -628,6 +666,14 @@ def Tosa_TransposeConv2DOp : Tosa_ConvOp<"transpose_conv2d"> {
let builders = [Tosa_TransConvOpQuantInfoBuilder];
let hasVerifier = 1;
+
+ let assemblyFormat =
+ "operands `out_pad` `(` custom<TosaAttr>($out_pad) `)` "
+ "`stride` `(` custom<TosaAttr>($stride) `)` "
+ "`acc_type` `(` custom<TosaAttr>($acc_type) `)` "
+ "oilist(`local_bound` `(` custom<TosaAttr>($local_bound) `)`) "
+ "attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -811,7 +857,9 @@ def Tosa_ArithmeticRightShiftOp : Tosa_ElementwiseOp<"arithmetic_right_shift",
Tosa_Tensor:$output
);
- let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
+ let assemblyFormat =
+ "operands `round` `(` $round `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -1734,7 +1782,9 @@ def Tosa_ReduceAllOp : Tosa_InferTensorTypeOp<"reduce_all", [Pure]> {
}
}];
- let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
+ let assemblyFormat =
+ "operands `axis` `(` custom<TosaAttr>($axis) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -1770,7 +1820,9 @@ def Tosa_ReduceAnyOp : Tosa_InferTensorTypeOp<"reduce_any", [Pure]> {
}
}];
- let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
+ let assemblyFormat =
+ "operands `axis` `(` custom<TosaAttr>($axis) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -1883,7 +1935,9 @@ def Tosa_ReduceProductOp : Tosa_InferTensorTypeOp<"reduce_product", [NoMemoryEff
}
}];
- let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
+ let assemblyFormat =
+ "operands `axis` `(` custom<TosaAttr>($axis) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -1922,7 +1976,9 @@ def Tosa_ReduceSumOp : Tosa_InferTensorTypeOp<"reduce_sum", [NoMemoryEffect]> {
}
}];
- let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
+ let assemblyFormat =
+ "operands `axis` `(` custom<TosaAttr>($axis) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -1958,7 +2014,9 @@ def Tosa_ConcatOp : Tosa_InferTensorTypeOp<"concat", [Pure]> {
static bool isCompatibleReturnTypes(TypeRange l, TypeRange r);
}];
- let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
+ let assemblyFormat =
+ "operands `axis` `(` custom<TosaAttr>($axis) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -2075,7 +2133,8 @@ def Tosa_ReshapeBlockScaledOp
}];
let assemblyFormat =
- "operands attr-dict `:` functional-type(operands, results)";
+ "operands `block_size` `(` custom<TosaAttr>($block_size) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -2108,7 +2167,9 @@ def Tosa_ReverseOp: Tosa_Op<"reverse", [
let hasFolder = 1;
let hasVerifier = 1;
- let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
+ let assemblyFormat =
+ "operands `axis` `(` custom<TosaAttr>($axis) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -2201,7 +2262,8 @@ def Tosa_TransposeOp : Tosa_InferShapedTypeOp<"transpose",
let hasVerifier = 1;
let assemblyFormat =
- "operands attr-dict `:` functional-type(operands, results)";
+ "operands `perms` `(` custom<TosaAttr>($perms) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -2304,7 +2366,8 @@ def Tosa_RowGatherBlockScaledOp
let hasVerifier = 1;
let assemblyFormat =
- "operands attr-dict `:` functional-type(operands, results)";
+ "operands `block_size` `(` custom<TosaAttr>($block_size) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -2423,7 +2486,8 @@ def Tosa_CastOp: Tosa_Op<"cast", [Pure, SameOperandsAndResultShape,
Tosa_Tensor:$output
);
- let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
+ let assemblyFormat =
+ "operands prop-dict attr-dict `:` functional-type(operands, results)";
let hasFolder = 1;
let hasCanonicalizer = 1;
@@ -2673,7 +2737,11 @@ def Tosa_CustomOp : Tosa_Op<"custom"> {
Variadic<Tosa_Tensor>:$output_list
);
- let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
+ let assemblyFormat =
+ "operands `operator_name` `(` $operator_name `)` "
+ "`domain_name` `(` $domain_name `)` "
+ "`implementation_attrs` `(` $implementation_attrs `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaShapeOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaShapeOps.td
index 1bbfdc5776f2e..282e52a61e1e4 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaShapeOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaShapeOps.td
@@ -112,6 +112,10 @@ def Tosa_ConstShapeOp : Tosa_ShapeOp<"const_shape", [ConstantLike, Pure]> {
let hasVerifier = 1;
let hasFolder = 1;
+
+ let assemblyFormat =
+ "operands `values` `(` custom<TosaAttr>($values) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -134,6 +138,10 @@ def Tosa_DimOp : Tosa_ShapeOp<"dim", [Pure]> {
let hasVerifier = 1;
let hasFolder = 1;
+
+ let assemblyFormat =
+ "operands `axis` `(` custom<TosaAttr>($axis) `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
@@ -372,6 +380,11 @@ def Tosa_AssertEqualShapeOp
BoolAttr:$allow_broadcast);
let results = (outs);
+
+ let assemblyFormat =
+ "operands `allow_broadcast` `(` custom<TosaAttr>($allow_broadcast) "
+ "`)` attr-dict `:` "
+ "functional-type(operands, results)";
}
#endif // TOSA_SHAPE_OPS
diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
index 46f84940d4718..d2040f32ae732 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
@@ -6174,5 +6174,21 @@ LogicalResult tosa::SliceShapeOp::verify() {
// TOSA Operator Definitions.
//===----------------------------------------------------------------------===//
+template <typename AttrT>
+static ParseResult parseTosaAttr(OpAsmParser &parser, AttrT &attr) {
+ Attribute parsedAttr;
+ if (parser.parseAttribute(parsedAttr))
+ return failure();
+ attr = dyn_cast<AttrT>(parsedAttr);
+ if (!attr)
+ return parser.emitError(parser.getNameLoc(), "expected TOSA attribute");
+ return success();
+}
+
+template <typename AttrT>
+static void printTosaAttr(OpAsmPrinter &printer, Operation *op, AttrT attr) {
+ printer << attr;
+}
+
#define GET_OP_CLASSES
#include "mlir/Dialect/Tosa/IR/TosaOps.cpp.inc"
diff --git a/mlir/test/Conversion/TosaToArith/tosa-to-arith.mlir b/mlir/test/Conversion/TosaToArith/tosa-to-arith.mlir
index 48d8d52ddc39a..5736706dea697 100644
--- a/mlir/test/Conversion/TosaToArith/tosa-to-arith.mlir
+++ b/mlir/test/Conversion/TosaToArith/tosa-to-arith.mlir
@@ -4,7 +4,7 @@
// CHECK-LABEL: func @const_test
func.func @const_test() -> (tensor<i32>) {
// CHECK: [[C3:%.+]] = arith.constant dense<3> : tensor<i32>
- %result = "tosa.const"() {values = dense<3> : tensor<i32>} : () -> tensor<i32>
+ %result = "tosa.const"() <{values = dense<3> : tensor<i32>}> : () -> tensor<i32>
// CHECK: return [[C3]]
return %result : tensor<i32>
diff --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-invalid.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-invalid.mlir
index ecfd953f9ef1f..a29a9d253f68e 100644
--- a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-invalid.mlir
+++ b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-invalid.mlir
@@ -3,7 +3,7 @@
// CHECK-LABEL: @avg_pool2d_with_unsupported_quant_type
func.func @avg_pool2d_with_unsupported_quant_type(%arg0: tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>>, %arg1: tensor<1xi8>, %arg2: tensor<1xi8>) -> tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>> {
// expected-error at +1 {{failed to legalize operation 'tosa.avg_pool2d'}}
- %0 = "tosa.avg_pool2d"(%arg0, %arg1, %arg2) {acc_type = i32, kernel = array<i64: 2, 2>, pad = array<i64: 0, 1, 0, 1>, stride = array<i64: 1, 1>} : (tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>>, tensor<1xi8>, tensor<1xi8>) -> tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>>
+ %0 = "tosa.avg_pool2d"(%arg0, %arg1, %arg2) <{acc_type = i32, kernel = array<i64: 2, 2>, pad = array<i64: 0, 1, 0, 1>, stride = array<i64: 1, 1>}> : (tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>>, tensor<1xi8>, tensor<1xi8>) -> tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>>
return %0 : tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>>
}
@@ -24,7 +24,7 @@ func.func @unranked_add(%arg0 : tensor<10x10xf32> , %arg1 : tensor<10x10xf32>, %
%reduce = tosa.reduce_max %arg0 {axis = 1 : i32} : (tensor<10x10xf32>) -> tensor<10x1xf32>
%1 = tosa.add %reduce, %arg1 : (tensor<10x1xf32>, tensor<10x10xf32>) -> tensor<10x10xf32>
%0 = tosa.add %1, %arg2 : (tensor<10x10xf32>, tensor<*xf32>) -> tensor<*xf32>
- %s = tosa.const_shape {values = dense<[10, 10]> : tensor<2xindex>} : () -> !tosa.shape<2>
+ %s = tosa.const_shape values(dense<[10, 10]> : tensor<2xindex>) : () -> !tosa.shape<2>
%2 = tosa.reshape %0, %s : (tensor<*xf32>, !tosa.shape<2>) -> tensor<10x10xf32>
return %2 : tensor<10x10xf32>
}
@@ -33,10 +33,10 @@ func.func @unranked_add(%arg0 : tensor<10x10xf32> , %arg1 : tensor<10x10xf32>, %
// CHECK-LABEL: @rescale_unsupported_type
func.func @rescale_unsupported_type(%arg0: tensor<13x21x3x!quant.uniform<u8:f32, 0.015655439347028732:127>>) -> tensor<13x21x3x!quant.uniform<i8:f32, 0.015655439347028732:-1>> {
- %multiplier = "tosa.const"() {values = dense<1073741824> : tensor<1xi32> } : () -> tensor<1xi32>
- %shift = "tosa.const"() {values = dense<30> : tensor<1xi8> } : () -> tensor<1xi8>
- %input_zp = "tosa.const"() {values = dense<127> : tensor<1xi8>} : () -> tensor<1xi8>
- %output_zp = "tosa.const"() {values = dense<-1> : tensor<1xi8>} : () -> tensor<1xi8>
+ %multiplier = "tosa.const"() <{values = dense<1073741824> : tensor<1xi32> }> : () -> tensor<1xi32>
+ %shift = "tosa.const"() <{values = dense<30> : tensor<1xi8> }> : () -> tensor<1xi8>
+ %input_zp = "tosa.const"() <{values = dense<127> : tensor<1xi8>}> : () -> tensor<1xi8>
+ %output_zp = "tosa.const"() <{values = dense<-1> : tensor<1xi8>}> : () -> tensor<1xi8>
// expected-error at +1 {{failed to legalize operation 'tosa.rescale'}}
%0 = tosa.rescale %arg0, %multiplier, %shift, %input_zp, %output_zp {rounding_mode = SINGLE_ROUND, per_channel = false, scale32 = true, input_unsigned = true, output_unsigned = false} : (tensor<13x21x3x!quant.uniform<u8:f32, 0.015655439347028732:127>>, tensor<1xi32>, tensor<1xi8>, tensor<1xi8>, tensor<1xi8>) -> tensor<13x21x3x!quant.uniform<i8:f32, 0.015655439347028732:-1>>
return %0 : tensor<13x21x3x!quant.uniform<i8:f32, 0.015655439347028732:-1>>
@@ -62,7 +62,7 @@ func.func @cast_unsupported_type(%arg0: tensor<13x21x3xi32>) -> tensor<13x21x3x!
func.func @unranked_reduce(%arg0: tensor<*xf32>) -> tensor<*xf32> {
// expected-error at +1 {{failed to legalize operation 'tosa.reduce_sum'}}
- %0 = tosa.reduce_sum %arg0 {axis = 0 : i32} : (tensor<*xf32>) -> tensor<*xf32>
+ %0 = tosa.reduce_sum %arg0 axis(0 : i32) : (tensor<*xf32>) -> tensor<*xf32>
return %0 : tensor<*xf32>
}
diff --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-named.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-named.mlir
index 801144c01829a..622a7dd925c4c 100644
--- a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-named.mlir
+++ b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-named.mlir
@@ -304,7 +304,7 @@ func.func @avg_pool_f32(%arg0: tensor<1x6x34x62xf32>) -> (tensor<1x5x33x62xf32>)
// CHECK: linalg.yield %[[DIV]]
%input_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>
%output_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>
- %0 = tosa.avg_pool2d %arg0, %input_zp, %output_zp {acc_type = f32, pad = array<i64: 1, 1, 1, 1>, kernel = array<i64: 4, 4>, stride = array<i64: 1, 1>} : (tensor<1x6x34x62xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<1x5x33x62xf32>
+ %0 = tosa.avg_pool2d %arg0, %input_zp, %output_zp kernel(array<i64: 4, 4>) stride(array<i64: 1, 1>) pad(array<i64: 1, 1, 1, 1>) acc_type(f32) : (tensor<1x6x34x62xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<1x5x33x62xf32>
return %0 : tensor<1x5x33x62xf32>
}
@@ -391,7 +391,7 @@ func.func @avg_pool_f16_f32acc(%arg0: tensor<1x6x34x62xf16>) -> (tensor<1x5x33x6
// CHECK: linalg.yield %[[TRUNC]]
%input_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf16>}> : () -> tensor<1xf16>
%output_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf16>}> : () -> tensor<1xf16>
- %0 = tosa.avg_pool2d %arg0, %input_zp, %output_zp {acc_type = f32, pad = array<i64: 1, 1, 1, 1>, kernel = array<i64: 4, 4>, stride = array<i64: 1, 1>} : (tensor<1x6x34x62xf16>, tensor<1xf16>, tensor<1xf16>) -> tensor<1x5x33x62xf16>
+ %0 = tosa.avg_pool2d %arg0, %input_zp, %output_zp kernel(array<i64: 4, 4>) stride(array<i64: 1, 1>) pad(array<i64: 1, 1, 1, 1>) acc_type(f32) : (tensor<1x6x34x62xf16>, tensor<1xf16>, tensor<1xf16>) -> tensor<1x5x33x62xf16>
return %0 : tensor<1x5x33x62xf16>
}
@@ -434,7 +434,7 @@ func.func @avg_pool_i8(%arg0: tensor<1x6x34x62xi8>) -> (tensor<1x5x33x62xi8>) {
// CHECK: linalg.yield %[[TRUNC]]
%input_zp = "tosa.const"() <{values = dense<0> : tensor<1xi8>}> : () -> tensor<1xi...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/217291
More information about the Mlir-commits
mailing list