[Mlir-commits] [mlir] [mlir][side effect] refactor(*): Include more precise side effects (PR #94213)

Matthias Springer llvmlistbot at llvm.org
Tue Jun 4 12:11:41 PDT 2024


================
@@ -2546,20 +2550,27 @@ SoftmaxOp::reifyResultShapes(OpBuilder &b,
 void SoftmaxOp::getEffects(
     SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
         &effects) {
-  for (Value operand : getDpsInputs()) {
+  SmallVector<Value> inputOperands = getDpsInputs();
+  for (auto [index, operand] : llvm::enumerate(inputOperands)) {
     if (!llvm::isa<MemRefType>(operand.getType()))
       continue;
-    effects.emplace_back(MemoryEffects::Read::get(), operand, /*stage=*/0,
+    effects.emplace_back(MemoryEffects::Read::get(),
+                         &getOperation()->getOpOperand(index), /*stage=*/0,
                          /*effectOnFullRegion=*/true,
                          SideEffects::DefaultResource::get());
   }
-  for (Value operand : getDpsInits()) {
+
+  unsigned inputOperandSize = inputOperands.size();
+  for (auto [index, operand] : llvm::enumerate(getDpsInits())) {
----------------
matthias-springer wrote:

I think you should be able to write something like `for (OpOperand *operand : getDpsInitsMutable())`. Same above.


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


More information about the Mlir-commits mailing list