[Mlir-commits] [mlir] [MLIR] Extend vector.scatter to accept tensor as base (PR #165548)

Han-Chung Wang llvmlistbot at llvm.org
Wed Nov 12 11:24:01 PST 2025


================
@@ -126,6 +127,51 @@ struct TransferWriteOpInterface
   }
 };
 
+/// Bufferization of vector.scatter. Replaced with a new vector.scatter that
+/// operates on a memref.
+struct ScatterOpInterface
+    : public BufferizableOpInterface::ExternalModel<ScatterOpInterface,
+                                                    vector::ScatterOp> {
+  bool bufferizesToMemoryRead(Operation *op, OpOperand &opOperand,
+                              const AnalysisState &state) const {
+    assert(isa<RankedTensorType>(opOperand.get().getType()) &&
+           "only tensor types expected");
+    return true;
+  }
+  bool bufferizesToMemoryWrite(Operation *op, OpOperand &opOperand,
+                               const AnalysisState &state) const {
+    assert(isa<RankedTensorType>(opOperand.get().getType()) &&
+           "only tensor types expected");
+    return true;
+  }
+  AliasingValueList getAliasingValues(Operation *op, OpOperand &opOperand,
+                                      const AnalysisState &state) const {
+    auto scatterOp = cast<vector::ScatterOp>(op);
+    if (&opOperand != &scatterOp.getBaseMutable())
+      return {};
+    if (op->getNumResults() == 0)
+      return {};
+    return {{scatterOp.getResult(), BufferRelation::Equivalent}};
+  }
----------------
hanhanW wrote:

style nit: add braces between these functions.

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


More information about the Mlir-commits mailing list