[Mlir-commits] [mlir] [mlir][vector] Add pattern for dropping unit dims from for loops (PR #109585)

Han-Chung Wang llvmlistbot at llvm.org
Mon Sep 23 15:23:42 PDT 2024


================
@@ -107,6 +107,17 @@ LoopNest buildLoopNest(OpBuilder &builder, Location loc, ValueRange lbs,
                        function_ref<void(OpBuilder &, Location, ValueRange)>
                            bodyBuilder = nullptr);
 
+/// Perform a replacement of one iter OpOperand of an scf.for to the
+/// `replacement` value with a different type. A callback is used to insert
+/// cast ops inside the block to account for type differences.
+using ValueTypeCastFnTy =
+    std::function<Value(OpBuilder &, Location loc, Type, Value)>;
+SmallVector<Value> replaceAndCastForOpIterArg(RewriterBase &rewriter,
+                                              scf::ForOp forOp,
+                                              OpOperand &operand,
----------------
hanhanW wrote:

Do we need to pass it by reference? I'd avoid it if we are not modifying the object. It looks like it can just be `OpOperand` or `const OpOperand &` type. I think `OpOperand` is enough because it is a pointer-like type.

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


More information about the Mlir-commits mailing list