Skip to content

Commit 7d8b478

Browse files
author
MaheshRavishankar
committed
[mlir][Linalg] Drop spurious error message
Drop usage of `emitRemark` and use `notifyMatchFailure` instead to avoid unnecessary spew during compilation. Differential Revision: https://reviews.llvm.org/D99485
1 parent 24c44c3 commit 7d8b478

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,10 @@ struct FoldProducerReshapeOpByLinearization
880880

881881
// Further check that the resulting index maps can be fused and
882882
// inverted. Without this the resultant op is not legal.
883-
if (!inversePermutation(concatAffineMaps(fusedIndexMaps)))
884-
return op.emitRemark("fused op loop bound computation failed");
883+
if (!inversePermutation(concatAffineMaps(fusedIndexMaps))) {
884+
return rewriter.notifyMatchFailure(
885+
op, "fused op loop bound computation failed");
886+
}
885887

886888
rewriter.startRootUpdate(op);
887889
op->setOperands(fusedOperands);
@@ -973,15 +975,19 @@ struct FoldConsumerReshapeOpByLinearization
973975
linearizeCollapsedDims(invMap, reshapeOp.getSrcType().getShape(),
974976
reshapeOp.getReassociationMaps());
975977
for (AffineExpr expr : modifiedMap.getResults()) {
976-
if (!expr.isPureAffine())
977-
return producer.emitRemark("fused op indexing map is not affine");
978+
if (!expr.isPureAffine()) {
979+
return rewriter.notifyMatchFailure(
980+
producer, "fused op indexing map is not affine");
981+
}
978982
}
979983
fusedIndexMaps.back() = modifiedMap;
980984

981985
// Further check that the resulting index maps can be fused and
982986
// inverted. Without this the resultant op is not legal.
983-
if (!inversePermutation(concatAffineMaps(fusedIndexMaps)))
984-
return reshapeOp.emitRemark("fused op loop bound computation failed");
987+
if (!inversePermutation(concatAffineMaps(fusedIndexMaps))) {
988+
return rewriter.notifyMatchFailure(
989+
producer, "fused op loop bound computation failed");
990+
}
985991

986992
Location loc = producer.getLoc();
987993
Value output = rewriter.create<TensorReshapeOp>(

mlir/test/Dialect/Linalg/reshape_linearization_fusion.mlir

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt -split-input-file -linalg-fold-reshape-ops-by-linearization -verify-diagnostics %s | FileCheck %s
1+
// RUN: mlir-opt -split-input-file -linalg-fold-reshape-ops-by-linearization %s | FileCheck %s
22

33
#map0 = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
44
func @generic_op_reshape_producer_fusion(%arg0 : tensor<?x?x?xf32>,
@@ -257,7 +257,6 @@ func @generic_op_reshape_consumer_nofusion(%arg0 : tensor<?x?x?x5xf32>,
257257
%arg1 : tensor<?x?x?x5xf32>) ->
258258
tensor<?x?xf32>
259259
{
260-
// expected-remark @+1 {{fused op indexing map is not affine}}
261260
%0 = linalg.generic {
262261
indexing_maps = [#map0, #map0, #map0],
263262
iterator_types = ["parallel", "parallel", "parallel", "parallel"]}
@@ -272,3 +271,10 @@ func @generic_op_reshape_consumer_nofusion(%arg0 : tensor<?x?x?x5xf32>,
272271
tensor<?x?x?x5xf32> into tensor<?x?xf32>
273272
return %1 : tensor<?x?xf32>
274273
}
274+
// CHECK-LABEL: func @generic_op_reshape_consumer_nofusion
275+
// CHECK-SAME: %[[ARG0:[a-zA-Z0-9_]+]]: tensor<?x?x?x5xf32>
276+
// CHECK-SAME: %[[ARG1:[a-zA-Z0-9_]+]]: tensor<?x?x?x5xf32>
277+
// CHECK: %[[NOFUSE:.+]] = linalg.generic
278+
// CHECK-SAME: ins(%[[ARG0]], %[[ARG1]]
279+
// CHECK: %[[RESULT:.+]] = linalg.tensor_reshape %[[NOFUSE]]
280+
// CHECK: return %[[RESULT]]

0 commit comments

Comments
 (0)