[Mlir-commits] [mlir] [mlir][tensor] move tensor insert canonicalization to pattern (PR #142671)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Jun 3 15:16:55 PDT 2025
================
@@ -176,6 +176,9 @@ void populateFoldConstantExtractSlicePatterns(
return false;
});
+/// Patterns to fold inserts into a constant into a new constant.
+void populateFoldInsertAfterConstant(RewritePatternSet &patterns);
----------------
asraa wrote:
OK - fair enough, exposing a populate*Pattern method and the pattern itself.
There's a similar pass in memref ops like `-fold-memref-alias-ops` (the constant -> insert one is different, but the extract from tensor.collapse_shape falls in that bucket). All the patterns I want are some kind of tensor folding operations.
I'm also lowering StableHLO -> linalg and want to add a few canonicalizations for
* collapsing a constant tensor folds to a collapsed constant
* broadcasting a constant tensor folds to a broadcasted constant
* a linalg.fill of a scalar constant folds to a tensor constant
Maybe a dedicated tensor folder pass would be good to start? `-fold-tensor-ops`?
https://github.com/llvm/llvm-project/pull/142671
More information about the Mlir-commits
mailing list