[Mlir-commits] [mlir] [MLIR] [Transforms] Let `transform.structured.convert_to_loops` return handles to loops (PR #83984)

Quinn Dawkins llvmlistbot at llvm.org
Tue Mar 5 06:58:41 PST 2024


================
@@ -2122,6 +2122,9 @@ DiagnosedSilenceableFailure transform::ConvertToLoopsOp::applyToOne(
   if (failed(loops))
     return emitDefaultDefiniteFailure(target);
   rewriter.eraseOp(target);
+  for (auto &loop : *loops) {
+    results.push_back(loop);
+  }
----------------
qedawkins wrote:

I'm not sure this is assigning the loops to the results correctly. This is appending to a `transform::ApplyToEachResultList` for each payload operation, which then gets mapped 1:1 with the results of the transform op. This will only work if all converted linalg ops produce the same number of loops. This seems undesirable to me in cases where users just want to convert all linalg ops to loops, or can't guarantee they know the rank of the linalg op they are converting. I see 2 options

1. Remove the `TransformEachOpTrait` and collect all of the converted loops into a single handle.
2. Remove the `TransformEachOpTrait` and ignore the loop handles if `convert_to_loops` has no results.

https://github.com/llvm/llvm-project/blob/a64975f9660e02f5f6688f8bcc55daf9eaa99fda/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp#L1462
and where it checks the exact number of results: https://github.com/llvm/llvm-project/blob/a64975f9660e02f5f6688f8bcc55daf9eaa99fda/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp#L1511

https://github.com/llvm/llvm-project/pull/83984


More information about the Mlir-commits mailing list