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

donald chen llvmlistbot at llvm.org
Mon Jun 10 04:53:46 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())) {
----------------
cxy-1993 wrote:

Nice catch, done

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


More information about the Mlir-commits mailing list