diff options
author | srcarroll <50210727+srcarroll@users.noreply.github.com> | 2024-03-22 12:37:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-22 12:37:39 -0500 |
commit | bbcfe6f4311af8cf6095a5bc5937fa68a87b4289 (patch) | |
tree | c6f7ed88eeb57cb6e40ab8506edf95f529e7d268 /mlir/lib | |
parent | 36a6afdd2c7fa02548260ebe4c993b705c6e6e38 (diff) | |
download | llvm-bbcfe6f4311af8cf6095a5bc5937fa68a87b4289.zip llvm-bbcfe6f4311af8cf6095a5bc5937fa68a87b4289.tar.gz llvm-bbcfe6f4311af8cf6095a5bc5937fa68a87b4289.tar.bz2 |
[mlir][transform] Emit error message with `emitSilenceableFailure` (#86146)
The previous implementation used a `notifyMatchFailure` to emit failure
message inappropriately and then used the
`emitDefaultSilenceableFailure`. This patch changes this to use the more
appropriate `emitSilenceableFailure` with error message. Additionally a
failure test has been added.
Diffstat (limited to 'mlir/lib')
-rw-r--r-- | mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp index ecf9983..88819cd9 100644 --- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp +++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp @@ -3269,22 +3269,24 @@ DiagnosedSilenceableFailure transform::FlattenElementwiseLinalgOp::applyToOne( transform::ApplyToEachResultList &results, transform::TransformState &state) { rewriter.setInsertionPoint(target); - if (!isElementwise(target)) { - failed(rewriter.notifyMatchFailure( - target, "only elementwise flattening is supported")); - return emitDefaultSilenceableFailure(target); - } + if (!isElementwise(target)) + return mlir::emitSilenceableFailure(target->getLoc()) + << "only elementwise flattening is supported"; + // If rank <= 1, do nothing if (target.getNumLoops() <= 1) { results.push_back(target); return DiagnosedSilenceableFailure::success(); } + + // Attempt to flatten all dims to one. ReassociationIndices reassociation(target.getNumLoops()); std::iota(reassociation.begin(), reassociation.end(), 0); auto maybeFlattened = collapseOpIterationDims(target, reassociation, rewriter); if (failed(maybeFlattened)) - return emitDefaultSilenceableFailure(target); + return mlir::emitSilenceableFailure(target->getLoc()) + << "attempted to flatten, but failed"; results.push_back(maybeFlattened->collapsedOp); rewriter.replaceOp(target, maybeFlattened->results); return DiagnosedSilenceableFailure::success(); |