Skip to content

Commit 82fcc35

Browse files
mgehre-amdTinaAMD
andauthored
Apply suggestions from code review
Co-authored-by: Tina Jung <[email protected]>
1 parent 73a79e8 commit 82fcc35

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

mlir/lib/Dialect/Tosa/Transforms/TosaFolders.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,8 @@ struct TosaFoldConstantReshape
586586
// Check that we can apply folding
587587
auto preCondCheck =
588588
notifyIfNoTosaDenseConstantTensor(inputTensor, op, rewriter);
589-
if (failed(preCondCheck)) {
589+
if (failed(preCondCheck))
590590
return preCondCheck;
591-
}
592591

593592
// Extract the tensor values
594593
DenseElementsAttr inputValues;
@@ -1756,9 +1755,9 @@ void mlir::tosa::populateTosaFoldConstantPatterns(
17561755
bool foldSplatOrSingleUseOnly,
17571756
bool enableIntCastFolding) {
17581757

1759-
patterns.add<TosaFoldConstantReshape>(ctx, foldSplatOrSingleUseOnly);
17601758
patterns.add<TosaFoldConstantTranspose>(ctx, foldSplatOrSingleUseOnly);
17611759
patterns.add<TosaFoldConstantReciprocal>(ctx, foldSplatOrSingleUseOnly);
1760+
patterns.add<TosaFoldConstantReshape>(ctx, foldSplatOrSingleUseOnly);
17621761
patterns.add<TosaFoldConstantRSQRT>(ctx, foldSplatOrSingleUseOnly);
17631762
patterns.add<TosaFoldConstantLogicalNot>(ctx, foldSplatOrSingleUseOnly);
17641763
patterns.add<TosaFoldConstantPow>(ctx, foldSplatOrSingleUseOnly);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: mlir-opt --split-input-file --tosa-layerwise-constant-fold %s | FileCheck %s
22
// RUN: mlir-opt --split-input-file --tosa-layerwise-constant-fold="fold-splat-or-single-use-only=0" %s | FileCheck %s --check-prefix CHECK-MULTI
3+
34
// CHECK-LABEL: @reshape_single_user
45
func.func @reshape_single_user() -> tensor<1x2xf32> {
56
// CHECK: %[[RES:.*]] = "tosa.const"{{.*}}-> tensor<1x2xf32>
@@ -9,7 +10,7 @@ func.func @reshape_single_user() -> tensor<1x2xf32> {
910
return %1 : tensor<1x2xf32>
1011
}
1112

12-
// CHECK-LABEL: @reshape_multi_user
13+
// CHECK-LABEL: @reshape_multi_user_splat
1314
func.func @reshape_multi_user_splat() -> (tensor<1x2xf32>, tensor<2xf32>) {
1415
// CHECK-DAG: %[[RES:.*]] = "tosa.const"{{.*}}-> tensor<2xf32>
1516
// CHECK-DAG: %[[RESHAPED:.*]] = "tosa.const"{{.*}}-> tensor<1x2xf32>

0 commit comments

Comments
 (0)