Skip to content

Commit 05efa5b

Browse files
committed
Change CHECK-MULTI to CHECK-ALWAYS and add comments
1 parent 82fcc35 commit 05efa5b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// RUN: mlir-opt --split-input-file --tosa-layerwise-constant-fold %s | FileCheck %s
2-
// RUN: mlir-opt --split-input-file --tosa-layerwise-constant-fold="fold-splat-or-single-use-only=0" %s | FileCheck %s --check-prefix CHECK-MULTI
1+
// RUN: mlir-opt --tosa-layerwise-constant-fold %s | FileCheck %s
2+
// RUN: mlir-opt --tosa-layerwise-constant-fold="fold-splat-or-single-use-only=0" %s \
3+
// RUN: | FileCheck %s --check-prefix CHECK-ALWAYS
34

45
// CHECK-LABEL: @reshape_single_user
56
func.func @reshape_single_user() -> tensor<1x2xf32> {
@@ -10,6 +11,7 @@ func.func @reshape_single_user() -> tensor<1x2xf32> {
1011
return %1 : tensor<1x2xf32>
1112
}
1213

14+
// Splat constants are always folded, even when they have multiple users.
1315
// CHECK-LABEL: @reshape_multi_user_splat
1416
func.func @reshape_multi_user_splat() -> (tensor<1x2xf32>, tensor<2xf32>) {
1517
// CHECK-DAG: %[[RES:.*]] = "tosa.const"{{.*}}-> tensor<2xf32>
@@ -20,14 +22,16 @@ func.func @reshape_multi_user_splat() -> (tensor<1x2xf32>, tensor<2xf32>) {
2022
return %1, %0 : tensor<1x2xf32>, tensor<2xf32>
2123
}
2224

25+
// Non-splat constants with multiple users are only folded when
26+
// fold-splat-or-single-use-only=0 is set.
2327
// CHECK-LABEL: @reshape_multi_user_non_splat
2428
func.func @reshape_multi_user_non_splat() -> (tensor<1x2xf32>, tensor<2xf32>) {
2529
// CHECK: %[[CONST:.*]] = "tosa.const"{{.*}}-> tensor<2xf32>
2630
// CHECK: %[[RES:.*]] = tosa.reshape
2731
// CHECK: return %[[RES]], %[[CONST]]
28-
// CHECK-MULTI-DAG: %[[RES:.*]] = "tosa.const"{{.*}}-> tensor<2xf32>
29-
// CHECK-MULTI-DAG: %[[RESHAPED:.*]] = "tosa.const"{{.*}}-> tensor<1x2xf32>
30-
// CHECK-MULTI: return %[[RESHAPED]], %[[RES]]
32+
// CHECK-ALWAYS-DAG: %[[RES:.*]] = "tosa.const"{{.*}}-> tensor<2xf32>
33+
// CHECK-ALWAYS-DAG: %[[RESHAPED:.*]] = "tosa.const"{{.*}}-> tensor<1x2xf32>
34+
// CHECK-ALWAYS: return %[[RESHAPED]], %[[RES]]
3135
%0 = "tosa.const"() {value = dense<[4.0, 3.0]> : tensor<2xf32>} : () -> tensor<2xf32>
3236
%1 = tosa.reshape %0 {new_shape = array<i64: 1, 2>}: (tensor<2xf32>) -> tensor<1x2xf32>
3337
return %1, %0 : tensor<1x2xf32>, tensor<2xf32>

0 commit comments

Comments
 (0)