[Mlir-commits] [mlir] Const custom asm (PR #226141)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Sep 24 05:29:37 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Yuvaraj Venkatesh (Yuvaraj-Venkatesh)
<details>
<summary>Changes</summary>
---
Patch is 138.71 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/226141.diff
20 Files Affected:
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td (+4)
- (modified) mlir/test/Conversion/TosaToSPIRVTosa/graph-constant-mark.mlir (+3-3)
- (modified) mlir/test/Dialect/Tosa/canonicalize.mlir (+26-26)
- (modified) mlir/test/Dialect/Tosa/constant_folding.mlir (+58-58)
- (modified) mlir/test/Dialect/Tosa/ops.mlir (+1-1)
- (modified) mlir/test/Dialect/Tosa/tosa-arith-const-to-tosa-const.mlir (+8-8)
- (modified) mlir/test/Dialect/Tosa/tosa-convert-integer-type-to-signless.mlir (+6-6)
- (modified) mlir/test/Dialect/Tosa/tosa-decompose-depthwise.mlir (+6-6)
- (modified) mlir/test/Dialect/Tosa/tosa-decompose-transpose-conv.mlir (+14-14)
- (modified) mlir/test/Dialect/Tosa/tosa-gather-scatter-hardening.mlir (+21-21)
- (modified) mlir/test/Dialect/Tosa/tosa-infer-shapes.mlir (+5-5)
- (modified) mlir/test/Dialect/Tosa/tosa-layerwise-constant-fold-dense-resource.mlir (+12-12)
- (modified) mlir/test/Dialect/Tosa/tosa-layerwise-constant-fold.mlir (+58-58)
- (modified) mlir/test/Dialect/Tosa/tosa-narrow-f32-to-f16-aggressive.mlir (+2-2)
- (modified) mlir/test/Dialect/Tosa/tosa-narrow-f32-to-f16.mlir (+2-2)
- (modified) mlir/test/Dialect/Tosa/tosa-narrow-f64-to-f32-aggressive.mlir (+2-2)
- (modified) mlir/test/Dialect/Tosa/tosa-narrow-f64-to-f32.mlir (+2-2)
- (modified) mlir/test/Dialect/Tosa/tosa-narrow-i64-to-i32-aggressive.mlir (+2-2)
- (modified) mlir/test/Dialect/Tosa/tosa-narrow-i64-to-i32.mlir (+2-2)
- (modified) mlir/test/Dialect/Tosa/tosa-reduce-transposes.mlir (+15-15)
``````````diff
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index 7cbe8e0b6c70e7..01ef662cc4f71e 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -2700,6 +2700,10 @@ def Tosa_ConstOp : Tosa_Op<"const", [ConstantLike, Pure,
let hasFolder = 1;
let hasVerifier = 1;
+
+ let assemblyFormat =
+ "operands `values` `(` $values `)` attr-dict `:` "
+ "functional-type(operands, results)";
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/test/Conversion/TosaToSPIRVTosa/graph-constant-mark.mlir b/mlir/test/Conversion/TosaToSPIRVTosa/graph-constant-mark.mlir
index ceab987ab08b57..11a128f2b3b6e6 100644
--- a/mlir/test/Conversion/TosaToSPIRVTosa/graph-constant-mark.mlir
+++ b/mlir/test/Conversion/TosaToSPIRVTosa/graph-constant-mark.mlir
@@ -2,7 +2,7 @@
// CHECK-LABEL: func.func @large_const
func.func @large_const() -> tensor<17xi32> {
- // CHECK: "tosa.const"() <{values = {{.*}}> {grapharm.graph_constant_id = 0 : i32} : () -> tensor<17xi32>
+ // CHECK: tosa.const values({{.*}}) {grapharm.graph_constant_id = 0 : i32} : () -> tensor<17xi32>
%res = "tosa.const"() <{values = dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]> : tensor<17xi32>}> : () -> tensor<17xi32>
return %res : tensor<17xi32>
}
@@ -38,9 +38,9 @@ func.func @small_const_shape() -> !tosa.shape<32> {
// CHECK-LABEL: func.func @mixed_large_constants
func.func @mixed_large_constants() -> (tensor<17xi32>, tensor<18xi32>, !tosa.shape<33>) {
- // CHECK: "tosa.const"() <{values = {{.*}}> {grapharm.graph_constant_id = 0 : i32} : () -> tensor<17xi32>
+ // CHECK: tosa.const values({{.*}}) {grapharm.graph_constant_id = 0 : i32} : () -> tensor<17xi32>
%const0 = "tosa.const"() <{values = dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]> : tensor<17xi32>}> : () -> tensor<17xi32>
- // CHECK: "tosa.const"() <{values = {{.*}}> {grapharm.graph_constant_id = 1 : i32} : () -> tensor<18xi32>
+ // CHECK: tosa.const values({{.*}}) {grapharm.graph_constant_id = 1 : i32} : () -> tensor<18xi32>
%const1 = "tosa.const"() <{values = dense<[20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37]> : tensor<18xi32>}> : () -> tensor<18xi32>
// CHECK: tosa.const_shape values({{.*}}) {grapharm.graph_constant_id = 2 : i32} : () -> !tosa.shape<33>
%shape = "tosa.const_shape"() <{values = dense<[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]> : tensor<33xindex>}> : () -> !tosa.shape<33>
diff --git a/mlir/test/Dialect/Tosa/canonicalize.mlir b/mlir/test/Dialect/Tosa/canonicalize.mlir
index 44327c6d500ce9..8776182bf16c58 100644
--- a/mlir/test/Dialect/Tosa/canonicalize.mlir
+++ b/mlir/test/Dialect/Tosa/canonicalize.mlir
@@ -11,7 +11,7 @@ func.func @argmax_nofold(%arg0: tensor<?x1xf32>) -> tensor<1xi32> {
// CHECK-LABEL: @test_argmax_fold_i64_index
func.func @test_argmax_fold_i64_index(%arg0: tensor<1xi8>) -> tensor<i64> {
- // CHECK: "tosa.const"() <{values = dense<0> : tensor<i64>}> : () -> tensor<i64>
+ // CHECK: tosa.const values(dense<0> : tensor<i64>) : () -> tensor<i64>
%0 = tosa.argmax %arg0 axis(0) : (tensor<1xi8>) -> tensor<i64>
return %0 : tensor<i64>
}
@@ -532,7 +532,7 @@ func.func @pad_noop_type_mismatch_nofold(%arg0: tensor<10xf32>) -> tensor<?xf32>
// CHECK-LABEL: @pad_determine_val_i32
func.func @pad_determine_val_i32(%arg0: tensor<?x?xi32>, %arg1 : tensor<2x2xi32>) -> tensor<?x?xi32> {
- // CHECK-DAG: %[[ZERO:.+]] = "tosa.const"() <{values = dense<0> : tensor<1xi32>}
+ // CHECK-DAG: %[[ZERO:.+]] = tosa.const values(dense<0> : tensor<1xi32>)
// CHECK-DAG: %[[PADDING:.+]] = tosa.const_shape values(dense<[1, 0, 0, 1]> : tensor<4xindex>) : () -> !tosa.shape<4>
// CHECK: tosa.pad %arg0, %[[PADDING]], %[[ZERO]]
%pad_const = "tosa.const"() <{values = dense<0> : tensor<1xi32>}> : () -> tensor<1xi32>
@@ -545,7 +545,7 @@ func.func @pad_determine_val_i32(%arg0: tensor<?x?xi32>, %arg1 : tensor<2x2xi32>
// CHECK-LABEL: @pad_determine_val_f32
func.func @pad_determine_val_f32(%arg0: tensor<?x?xf32>, %arg1 : tensor<2x2xi32>) -> tensor<?x?xf32> {
- // CHECK-DAG: %[[ZERO:.+]] = "tosa.const"() <{values = dense<3.140000e+00> : tensor<1xf32>}
+ // CHECK-DAG: %[[ZERO:.+]] = tosa.const values(dense<3.140000e+00> : tensor<1xf32>)
// CHECK-DAG: %[[PADDING:.+]] = tosa.const_shape values(dense<[1, 0, 0, 1]> : tensor<4xindex>) : () -> !tosa.shape<4>
// CHECK: tosa.pad %arg0, %[[PADDING]], %[[ZERO]]
%pad_const = "tosa.const"() <{values = dense<3.14> : tensor<1xf32>}> : () -> tensor<1xf32>
@@ -558,7 +558,7 @@ func.func @pad_determine_val_f32(%arg0: tensor<?x?xf32>, %arg1 : tensor<2x2xi32>
// CHECK-LABEL: @pad_determine_val_quant
func.func @pad_determine_val_quant(%arg0: tensor<?x?xi32>, %arg1 : tensor<2x2xi32>) -> tensor<?x?xi32> {
- // CHECK-DAG: %[[ZERO:.+]] = "tosa.const"() <{values = dense<3> : tensor<1xi32>}
+ // CHECK-DAG: %[[ZERO:.+]] = tosa.const values(dense<3> : tensor<1xi32>)
// CHECK-DAG: %[[PADDING:.+]] = tosa.const_shape values(dense<[1, 0, 0, 1]> : tensor<4xindex>) : () -> !tosa.shape<4>
// CHECK: tosa.pad %arg0, %[[PADDING]], %[[ZERO]]
%pad_const = "tosa.const"() <{values =dense<3> : tensor<1xi32>}> : () -> tensor<1xi32>
@@ -725,7 +725,7 @@ func.func @reshape_canonicalize_double(%arg0: tensor<?x10xf32>) -> tensor<?x5xf3
// CHECK-LABEL: @reshape_canonicalize_const
func.func @reshape_canonicalize_const() -> tensor<1x5xi32> {
- // CHECK: %[[VAR0:.+]] = "tosa.const"() <{values = dense<{{\[\[}}0, 1, 2, 3, 4]]> : tensor<1x5xi32>}
+ // CHECK: %[[VAR0:.+]] = tosa.const values(dense<{{\[\[}}0, 1, 2, 3, 4]]> : tensor<1x5xi32>)
// CHECK: return %[[VAR0]]
%0 = "tosa.const"() <{values = dense<[0, 1, 2, 3, 4]> : tensor<5xi32>}> : () -> tensor<5xi32>
%1 = "tosa.const_shape"() <{values = dense<[1, 5]> : tensor<2xindex>}> : () -> !tosa.shape<2>
@@ -748,8 +748,8 @@ func.func @reshape_canonicalize_const_dynamic() -> tensor<1x?xi32> {
// CHECK-LABEL: @reshape_canonicalize_const_splat
func.func @reshape_canonicalize_const_splat() -> (tensor<10xi32>, tensor<1x10xi32>) {
- // CHECK-DAG: %[[VAR0:.+]] = "tosa.const"() <{values = dense<0> : tensor<10xi32>}
- // CHECK-DAG: %[[VAR1:.+]] = "tosa.const"() <{values = dense<0> : tensor<1x10xi32>}
+ // CHECK-DAG: %[[VAR0:.+]] = tosa.const values(dense<0> : tensor<10xi32>)
+ // CHECK-DAG: %[[VAR1:.+]] = tosa.const values(dense<0> : tensor<1x10xi32>)
// CHECK: return %[[VAR0]], %[[VAR1]]
%0 = "tosa.const"() <{values = dense<0> : tensor<10xi32>}> : () -> tensor<10xi32>
%2 = "tosa.const_shape"() <{values = dense<[1, 10]> : tensor<2xindex>}> : () -> !tosa.shape<2>
@@ -773,7 +773,7 @@ func.func @reshape_canonicalize_const_sparse() -> (tensor<3xi32>, tensor<1x3xi32
// CHECK-LABEL: @reshape_canonicalize_quant_nofold
func.func @reshape_canonicalize_quant_nofold() -> (tensor<1x3x!quant.uniform<i8:f32, 1.000000e+00>>) {
// disabled folding for quantized element types
- // CHECK{LITERAL}: "tosa.const"() <{values = dense<[1, 2, 3]> : tensor<3xi8>}> : () -> tensor<3x!quant.uniform<i8:f32, 1.000000e+00>>
+ // CHECK{LITERAL}: tosa.const values(dense<[1, 2, 3]> : tensor<3xi8>) : () -> tensor<3x!quant.uniform<i8:f32, 1.000000e+00>>
// CHECK{LITERAL}: tosa.reshape %0, %1 : (tensor<3x!quant.uniform<i8:f32, 1.000000e+00>>, !tosa.shape<2>) -> tensor<1x3x!quant.uniform<i8:f32, 1.000000e+00>>
%0 = "tosa.const"() <{values = dense<[1, 2, 3]> : tensor<3xi8>}> : ()-> tensor<3x!quant.uniform<i8:f32, 1.000000e+00>>
%2 = "tosa.const_shape"() <{values = dense<[1, 3]> : tensor<2xindex>}> : () -> !tosa.shape<2>
@@ -786,7 +786,7 @@ func.func @reshape_canonicalize_quant_nofold() -> (tensor<1x3x!quant.uniform<i8:
// CHECK-LABEL: @transpose_canonicalize_strip_quant
func.func @transpose_canonicalize_strip_quant() -> (tensor<2x1x3x!quant.uniform<i8:f32, 1.000000e+00>>) {
// CHECK-DAG: %[[SHAPE:.*]] = tosa.const_shape values(dense<[2, 1, 3]> : tensor<3xindex>) : () -> !tosa.shape<3>
- // CHECK-DAG: %[[CONST:.*]] = "tosa.const"() <{values = dense<0> : tensor<1x2x3xi8>}> : () -> tensor<1x2x3x!quant.uniform<i8:f32, 1.000000e+00>>
+ // CHECK-DAG: %[[CONST:.*]] = tosa.const values(dense<0> : tensor<1x2x3xi8>) : () -> tensor<1x2x3x!quant.uniform<i8:f32, 1.000000e+00>>
// CHECK: tosa.reshape %[[CONST]], %[[SHAPE]] : (tensor<1x2x3x!quant.uniform<i8:f32, 1.000000e+00>>, !tosa.shape<3>) -> tensor<2x1x3x!quant.uniform<i8:f32, 1.000000e+00>>
%0 = "tosa.const"() <{values = dense<0> : tensor<1x2x3xi8>}> : ()-> tensor<1x2x3x!quant.uniform<i8:f32, 1.000000e+00>>
%1 = tosa.transpose %0 perms([1, 0, 2]) : (tensor<1x2x3x!quant.uniform<i8:f32, 1.000000e+00>>) -> tensor<2x1x3x!quant.uniform<i8:f32, 1.000000e+00>>
@@ -903,7 +903,7 @@ func.func @transpose_is_reshape_unknown_dim(%arg0: tensor<1x4x?x1xf32>) -> tenso
// CHECK-LABEL: @single_bit_reshape
// https://github.com/llvm/llvm-project/issues/55440
func.func @single_bit_reshape() -> tensor<1xi1> {
- // CHECK: "tosa.const"() <{values = dense<true> : tensor<1xi1>}
+ // CHECK: tosa.const values(dense<true> : tensor<1xi1>)
%0 = arith.constant dense<true> : tensor<1x1xi1>
%2 = "tosa.const_shape"() <{values = dense<1> : tensor<1xindex>}> : () -> !tosa.shape<1>
%1 = tosa.reshape %0, %2 : (tensor<1x1xi1>, !tosa.shape<1>) -> tensor<1xi1>
@@ -1077,7 +1077,7 @@ func.func @canonicalize_concat_slice_on_non_concat_axis(%arg0 : tensor<1x12x12xf
// -----
// CHECK-LABEL: @canonicalize_pad_slice_overlap
-// CHECK-DAG: %[[PAD_CONST:.*]] = "tosa.const"() <{values = dense<0.000000e+00> : tensor<1xf32>}> : () -> tensor<1xf32>
+// CHECK-DAG: %[[PAD_CONST:.*]] = tosa.const values(dense<0.000000e+00> : tensor<1xf32>) : () -> tensor<1xf32>
// CHECK-DAG: %[[ZERO:.*]] = tosa.const_shape values(dense<0> : tensor<4xindex>) : () -> !tosa.shape<4>
// CHECK-DAG: %[[PADDING:.*]] = tosa.const_shape values(dense<[0, 0, 0, 0, 1, 1, 0, 0]> : tensor<8xindex>)
// CHECK-DAG: %[[SLICE_SIZE:.*]] = tosa.const_shape values(dense<[-1, 14, 18, 3]> : tensor<4xindex>)
@@ -1113,7 +1113,7 @@ func.func @canonicalize_pad_slice_inside(%arg0: tensor<1x16x16x3xf32>) -> tensor
// -----
// CHECK-LABEL: func @canonicalize_pad_slice_exact
-// CHECK-DAG: %[[PAD_CONST:.*]] = "tosa.const"() <{values = dense<0.000000e+00> : tensor<1xf32>}> : () -> tensor<1xf32>
+// CHECK-DAG: %[[PAD_CONST:.*]] = tosa.const values(dense<0.000000e+00> : tensor<1xf32>) : () -> tensor<1xf32>
// CHECK-DAG: %[[ZERO:.*]] = tosa.const_shape values(dense<0> : tensor<4xindex>) : () -> !tosa.shape<4>
// CHECK-DAG: %[[PADDING:.*]] = tosa.const_shape values(dense<[0, 0, 0, 0, 2, 2, 0, 0]> : tensor<8xindex>)
// CHECK-DAG: %[[SLICE_SIZE:.*]] = tosa.const_shape values(dense<[1, 16, 20, 2]> : tensor<4xindex>)
@@ -1249,7 +1249,7 @@ func.func @sub_quant_nofold() -> tensor<!quant.uniform<i8:f32, 3.075740460189990
// CHECK-LABEL: @greater_quant_fold
func.func @greater_quant_fold() -> tensor<i1> {
%0 = "tosa.const"() <{values = dense<0> : tensor<i8>}> : () -> tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>
- // CHECK: "tosa.const"() <{values = dense<false>
+ // CHECK: tosa.const values(dense<false>
%2 = "tosa.greater"(%0, %0) : (tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>, tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>) -> tensor<i1>
return %2 : tensor<i1>
}
@@ -1259,7 +1259,7 @@ func.func @greater_quant_fold() -> tensor<i1> {
// CHECK-LABEL: @greater_equal_quant_fold
func.func @greater_equal_quant_fold() -> tensor<i1> {
%0 = "tosa.const"() <{values = dense<0> : tensor<i8>}> : () -> tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>
- // CHECK: "tosa.const"() <{values = dense<true>
+ // CHECK: tosa.const values(dense<true>
%2 = "tosa.greater_equal"(%0, %0) : (tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>, tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>) -> tensor<i1>
return %2 : tensor<i1>
}
@@ -1269,7 +1269,7 @@ func.func @greater_equal_quant_fold() -> tensor<i1> {
// CHECK-LABEL: @equal_quant_fold
func.func @equal_quant_fold() -> tensor<i1> {
%0 = "tosa.const"() <{values = dense<0> : tensor<i8>}> : () -> tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>
- // CHECK: "tosa.const"() <{values = dense<true>
+ // CHECK: tosa.const values(dense<true>
%2 = "tosa.equal"(%0, %0) : (tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>, tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>) -> tensor<i1>
return %2 : tensor<i1>
}
@@ -1288,7 +1288,7 @@ func.func @cast_quant_nofold() -> tensor<!quant.uniform<i8:f32, 3.07574046018999
// CHECK-LABEL: @reverse_quant_fold
func.func @reverse_quant_fold() -> tensor<1x!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>> {
- // CHECK: %[[CST:.*]] = "tosa.const"() <{values = dense<0> : tensor<1xi8>}> : () -> tensor<1x!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>
+ // CHECK: %[[CST:.*]] = tosa.const values(dense<0> : tensor<1xi8>) : () -> tensor<1x!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>
// CHECK: return %[[CST]]
%0 = "tosa.const"() <{values = dense<0> : tensor<1xi8>}> : () -> tensor<1x!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>
%1 = "tosa.reverse"(%0) <{ axis = 0 : i32 }> : (tensor<1x!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>) -> tensor<1x!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>
@@ -1330,7 +1330,7 @@ func.func @reverse_nofold_splat_type_unmatch() -> tensor<*xf32> {
// CHECK-LABEL: @select_quant_fold
func.func @select_quant_fold() -> tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>> {
- // CHECK: %[[CONST_0:.*]] = "tosa.const"() <{values = dense<0> : tensor<i8>}> : () -> tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>
+ // CHECK: %[[CONST_0:.*]] = tosa.const values(dense<0> : tensor<i8>) : () -> tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>
// CHECK: return %[[CONST_0]]
%0 = "tosa.const"() <{values = dense<true> : tensor<i1>}> : () -> tensor<i1>
%1 = "tosa.const"() <{values = dense<0> : tensor<i8>}> : () -> tensor<!quant.uniform<i8:f32, 3.0757404601899907E-5:-128>>
@@ -1356,7 +1356,7 @@ func.func @mul_quant_nofold() -> tensor<1x!quant.uniform<i8:f32, 3.0757404601899
// CHECK-LABEL: @fold_reciprocal
func.func nested @fold_reciprocal() -> tensor<3x600x1200xf32> {
- // CHECK: %[[VAL_0:.*]] = "tosa.const"() <{values = dense<8.620690e-03> : tensor<3x600x1200xf32>}> : () -> tensor<3x600x1200xf32>
+ // CHECK: %[[VAL_0:.*]] = tosa.const values(dense<8.620690e-03> : tensor<3x600x1200xf32>) : () -> tensor<3x600x1200xf32>
// CHECK: return %[[VAL_0]] : tensor<3x600x1200xf32>
// CHECK: }
%0 = "tosa.const"()<{ values = dense<116.0>: tensor<3x600x1200xf32> }>: () -> tensor<3x600x1200xf32>
@@ -1403,7 +1403,7 @@ func.func @slice_dynamic_size_static_output_canonicalize(%arg0: tensor<2x60x59x?
// -----
// CHECK-LABEL: @fold_mul_shift
-// CHECK-DAG: "tosa.const"() <{values = dense<1> : tensor<i32>}> : () -> tensor<i32>
+// CHECK-DAG: tosa.const values(dense<1> : tensor<i32>) : () -> tensor<i32>
func.func @fold_mul_shift() -> tensor<i32> {
%0 = "tosa.const"() <{values = dense<-23661> : tensor<i32>}> : () -> tensor<i32>
%1 = "tosa.const"() <{values = dense<-33022> : tensor<i32>}> : () -> tensor<i32>
@@ -1415,7 +1415,7 @@ func.func @fold_mul_shift() -> tensor<i32> {
// -----
// CHECK-LABEL: @fold_mul_no_shift
-// CHECK-DAG: "tosa.const"() <{values = dense<781333542> : tensor<i32>}> : () -> tensor<i32>
+// CHECK-DAG: tosa.const values(dense<781333542> : tensor<i32>) : () -> tensor<i32>
func.func @fold_mul_no_shift() -> tensor<i32> {
%0 = "tosa.const"() <{values = dense<-23661> : tensor<i32>}> : () -> tensor<i32>
%1 = "tosa.const"() <{values = dense<-33022> : tensor<i32>}> : () -> tensor<i32>
@@ -1427,9 +1427,9 @@ func.func @fold_mul_no_shift() -> tensor<i32> {
// -----
// CHECK-LABEL: @no_fold_mul_result_exceeds_i32
-// CHECK-DAG: %[[LHS:.*]] = "tosa.const"() <{values = dense<23661> : tensor<i32>}> : () -> tensor<i32>
-// CHECK-DAG: %[[RHS:.*]] = "tosa.const"() <{values = dense<330222> : tensor<i32>}> : () -> tensor<i32>
-// CHECK-DAG: %[[SHIFT:.*]] = "tosa.const"() <{values = dense<1> : tensor<1xi8>}> : () -> tensor<1xi8>
+// CHECK-DAG: %[[LHS:.*]] = tosa.const values(dense<23661> : tensor<i32>) : () -> tensor<i32>
+// CHECK-DAG: %[[RHS:.*]] = tosa.const values(dense<330222> : tensor<i32>) : () -> tensor<i32>
+// CHECK-DAG: %[[SHIFT:.*]] = tosa.const values(dense<1> : tensor<1xi8>) : () -> tensor<1xi8>
// CHECK: tosa.mul %[[LHS]], %[[RHS]], %[[SHIFT]] : (tensor<i32>, tensor<i32>, tensor<1xi8>) -> tensor<i32>
func.func @no_fold_mul_result_exceeds_i32() -> tensor<i32> {
%0 = "tosa.const"() <{values = dense<23661> : tensor<i32>}> : () -> tensor<i32>
@@ -1467,7 +1467,7 @@ func.func @no_fold_intdiv_dynamic_result() -> tensor<?xi32> {
// -----
// CHECK-LABEL: @test_fold_i1_to_i32_cast
-// CHECK: %[[OUT:.*]] = "tosa.const"() <{values = dense<1> : tensor<i32>}> : () -> tensor<i32>
+// CHECK: %[[OUT:.*]] = tosa.const values(dense<1> : tensor<i32>) : () -> tensor<i32>
// CHECK: return %[[OUT]] : tensor<i32>
func.func @test_fold_i1_to_i32_cast() -> tensor<i32> {
%0 = "tosa.const"() <{values = dense<1> : tensor<i1>}> : () -> tensor<i1>
@@ -1478,7 +1478,7 @@ func.func @test_fold_i1_to_i32_cast() -> tensor<i32> {
// -----
// CHECK-LABEL: @test_fold_i32_to_i1_cast
-// CHECK: %[[OUT:.*]] = "tosa.const"() <{values = dense<true> : tensor<i1>}> : () -> tensor<i1>
+// CHECK: %[[OUT:.*]] = tosa.const values(dense<true> : tensor<i1>) : () -> tensor<i1>
// CHECK: return %[[OUT]] : tensor<i1>
func.func @test_fold_i32_to_i1_cast() -> tensor<i1> {
%0 = "tosa.const"() <{values = dense<10> : tensor<i32>}> : () -> tensor<i32>
@@ -2328,7 +2328,7 @@ func.func @test_partially_foldable(%arg0: tensor<1x1x8x8xf32>, %arg1: tensor<1x2
// CHECK-LABEL: @reverse_block_scaled_splat
func.func @reverse_block_scaled_splat() -> tensor<64x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f8E4M3FN>> {
- // CHECK: %[[CST:.*]] = "tosa.const"
+ // CHECK: %[[CST:.*]] = tosa.const values(
%0 = "tosa.const"() <{values = dense<tensor<64x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f8E4M3FN, {1.0, 2.0}>> : 1.0 : f8E4M3FN>}> : () -> tensor<64x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f8E4M3FN>>
// CHECK: %[[REV:.*]] = tosa.reverse %[[CST]]
// CHECK: return %[[REV]]
diff --git a/mlir/test/Dialect/Tosa/constant_folding.mlir b/mlir/test/Dialect/Tosa/constant_folding.mlir
index eb339d09d77d84..9d5d98df74ab00 100644
--- a/mlir/test/Dialect/Tosa/constant_folding.mlir
+++ b/mlir/test/Dialect/Tosa/constant_folding.mlir
@@ -113,7 +113,7 @@ func.func @fold_add_splat_i32() -> tensor<10xi32> {
%one = "tosa.const"() <{values = dense<1> : tensor<10xi32>}> : () -> tensor<10xi32>
%two = "tosa.const"() <{values = dense<2> : tensor<10xi32>}> : () -> tensor<10xi32>
%add = tosa.add %one, %two : (tensor<10xi32>, tensor<10xi32>) -> tensor<10xi32>
- // CHECK: %[[THREE:.+]] = "tosa.const"() <{values = dense<3> : tensor<10xi32>}
+ // CHECK: %[[THREE:.+]] = tosa.const values(dense<3> : tensor<10xi32>)
// CHECK: return %[[THREE]]
return %add : tensor<10xi32>
}
@@ -125,7 +125,7 @@ func.func @fold_add_splat_f32() -> tensor<10xf32> {
%one = "tosa.const"() <{values = dense<1.0> : tensor<10xf32>}> : () -> tensor<10xf32>
%two = "tosa.const"() <{values = dense<2.0> : tensor<10xf32>}> : () -> tensor<10xf32>
%add = tosa.add %one, %two : (tensor<10xf32>, tensor<10xf32>) -> tensor<10xf32>
- // CHECK: %[[THREE:.+]] = "tosa.const"() <{values = dense<3.000000e+00>
+ // CHECK: %[[THREE:.+]] = tosa.const values(dense<3.000000e+00>
// CHECK: return %[[THREE]]
return %add : tensor<10xf32>
}
@@ -158,7 +158,7 @@ func.func @fold_add_splat_i32_negative_overflow() -> tensor<10xi32> {
func.func @fold_add_splat_ui8() -> tensor<10xui8> {
%one = "tosa.const"() <{values = dense<1> : tensor<10xui8>}> : () -> tensor<10xui8>
%two = "tosa.const"() <{values = dense<254> : tensor<10xui8>}> : () -> tensor<10xui8>
- // CHECK: "tosa.const"() <{values = dense<255> : tensor<10xui8>}> : () -> tensor<10xui8>
+ // CHECK: tosa.const values(dense<255> : tensor<10xui8>) : () -> tensor<10...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/226141
More information about the Mlir-commits
mailing list