[Mlir-commits] [mlir] [mlir][Linalg] implement bufferization for `linalg.pack` (PR #177982)

Matthias Springer llvmlistbot at llvm.org
Tue Jan 27 03:05:45 PST 2026


================
@@ -191,6 +191,47 @@ struct SoftmaxOpInterface
     return success();
   }
 };
+
+struct PackOpInterface
+    : public DstBufferizableOpInterfaceExternalModel<PackOpInterface,
+                                                     linalg::PackOp> {
+  bool bufferizesToMemoryRead(Operation *op, OpOperand &opOperand,
+                              const AnalysisState &state) const {
+    auto packOp = cast<linalg::PackOp>(op);
+    return !packOp.isDpsInit(&opOperand);
+  }
+
+  LogicalResult bufferize(Operation *op, RewriterBase &rewriter,
+                          const BufferizationOptions &options,
+                          BufferizationState &state) const {
+    auto packOp = cast<linalg::PackOp>(op);
+    if (packOp.hasPureBufferSemantics())
----------------
matthias-springer wrote:

I believe this can be an assertion: `assert(!packOp.hasPureBufferSemantics() && "expected op with tensors");`


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


More information about the Mlir-commits mailing list