[Mlir-commits] [mlir] [mlir][linalg] Propagate filter tensor encoding in im2col (PR #160099)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Sep 24 09:37:25 PDT 2025


================
@@ -560,11 +572,17 @@ rewriteInIm2Col(RewriterBase &rewriter, linalg::Conv2DNhwcFhwcOp convOp) {
 
   Location loc = convOp.getLoc();
 
+  if (!isa<RankedTensorType>(filterType))
+    return rewriter.notifyMatchFailure(
+        convOp, "expected filter type to be a ranked tensor");
+  auto tensorFilterType = cast<RankedTensorType>(filterType);
+
   // Reshape output and filter to the LHS and result of a "row-wise" matrix
   // multiplication.
   SmallVector<ReassociationIndices> filterReassocIndices = {{0}, {1, 2, 3}};
   auto reshapedFilterType =
-      RankedTensorType::get({oc, fh * fw * ic}, filterType.getElementType());
+      RankedTensorType::get({oc, fh * fw * ic}, filterType.getElementType(),
+                            tensorFilterType.getEncoding());
----------------
fabrizio-indirli wrote:

Added a test case

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


More information about the Mlir-commits mailing list