[PATCH] D143729: [mlir][MemRef][TransformOps] Fix error reporting for multibuffer
Quentin Colombet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 10 04:58:24 PST 2023
qcolombet created this revision.
qcolombet added reviewers: kile, ThomasRaoux, nicolasvasilache, ftynse.
qcolombet added a project: MLIR.
Herald added subscribers: Moerafaat, bzcheeseman, sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, thopre.
Herald added a project: All.
qcolombet requested review of this revision.
Herald added a subscriber: stephenneuendorffer.
Multibuffer will fail to apply on allocs that are used outside of loops.
This was properly catched in the current implementation but the way we report
it was broken.
Notes cannot be emitted on their own, they need to be attached to another
main diagnostic.
Long story short, change the severity of the report from Note to Remark.
Note: I'm making another patch to not even bother running the multibuffer transformation on such allocs
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143729
Files:
mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp
mlir/test/Dialect/MemRef/transform-ops.mlir
Index: mlir/test/Dialect/MemRef/transform-ops.mlir
===================================================================
--- mlir/test/Dialect/MemRef/transform-ops.mlir
+++ mlir/test/Dialect/MemRef/transform-ops.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -test-transform-dialect-interpreter -verify-diagnostics -allow-unregistered-dialect | FileCheck %s
+// RUN: mlir-opt %s -test-transform-dialect-interpreter -verify-diagnostics -allow-unregistered-dialect -split-input-file | FileCheck %s
// CHECK-DAG: #[[$MAP0:.*]] = affine_map<(d0) -> ((d0 floordiv 4) mod 2)>
// CHECK-DAG: #[[$MAP1:.*]] = affine_map<(d0)[s0] -> (d0 + s0)>
@@ -35,3 +35,40 @@
// Verify that the returned handle is usable.
transform.test_print_remark_at_operand %1, "transformed" : !pdl.operation
}
+
+// -----
+
+// Trying to use multibuffer on alloc that are used outside of loops is
+// going to fail.
+// Check that we emit a proper remark for that.
+func.func @multi_buffer_uses_outside_of_loop(%in: memref<16xf32>) {
+ // CHECK: %[[A:.*]] = memref.alloc() : memref<2x4xf32>
+ // expected-remark @below {{op failed to multibuffer}}
+ %tmp = memref.alloc() : memref<4xf32>
+
+ "some_outside_loop_use"(%tmp) : (memref<4xf32>) -> ()
+
+ // CHECK: %[[C0:.*]] = arith.constant 0 : index
+ // CHECK: %[[C4:.*]] = arith.constant 4 : index
+ %c0 = arith.constant 0 : index
+ %c4 = arith.constant 4 : index
+ %c16 = arith.constant 16 : index
+
+ // CHECK: scf.for %[[IV:.*]] = %[[C0]]
+ scf.for %i0 = %c0 to %c16 step %c4 {
+ // CHECK: %[[I:.*]] = affine.apply #[[$MAP0]](%[[IV]])
+ // CHECK: %[[SV:.*]] = memref.subview %[[A]][%[[I]], 0] [1, 4] [1, 1] : memref<2x4xf32> to memref<4xf32, strided<[1], offset: ?>>
+ %1 = memref.subview %in[%i0] [4] [1] : memref<16xf32> to memref<4xf32, affine_map<(d0)[s0] -> (d0 + s0)>>
+ // CHECK: memref.copy %{{.*}}, %[[SV]] : memref<4xf32, #[[$MAP1]]> to memref<4xf32, strided<[1], offset: ?>>
+ memref.copy %1, %tmp : memref<4xf32, affine_map<(d0)[s0] -> (d0 + s0)>> to memref<4xf32>
+
+ "some_use"(%tmp) : (memref<4xf32>) ->()
+ }
+ return
+}
+
+transform.sequence failures(propagate) {
+^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["memref.alloc"]} in %arg1 : (!pdl.operation) -> !pdl.operation
+ %1 = transform.memref.multibuffer %0 {factor = 2 : i64}
+}
Index: mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp
===================================================================
--- mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp
+++ mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp
@@ -26,7 +26,7 @@
transform::TransformState &state) {
auto newBuffer = memref::multiBuffer(target, getFactor());
if (failed(newBuffer)) {
- Diagnostic diag(target->getLoc(), DiagnosticSeverity::Note);
+ Diagnostic diag(target->getLoc(), DiagnosticSeverity::Remark);
diag << "op failed to multibuffer";
return DiagnosedSilenceableFailure::silenceableFailure(std::move(diag));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143729.496432.patch
Type: text/x-patch
Size: 3000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230210/1d7f45c8/attachment.bin>
More information about the llvm-commits
mailing list