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

Benjamin Maxwell llvmlistbot at llvm.org
Mon Sep 23 10:05:39 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)>;
----------------
MacDue wrote:

I think this can be a `function_ref` rather than a `std::function` (which may heap alloc any captures), since helper does not store the function anywhere.  
```suggestion
using ValueTypeCastFnTy =
    llvm::function_ref<Value(OpBuilder &, Location loc, Type, Value)>;
```



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


More information about the Mlir-commits mailing list