[Mlir-commits] [mlir] 1ae7342 - [mlir][linalg] Fix windows build issue in hoist padding.

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Nov 30 07:22:25 PST 2021


Author: gysit
Date: 2021-11-30T15:21:53Z
New Revision: 1ae7342a7dd44561c86dcd2de456169185e1ce80

URL: https://github.com/llvm/llvm-project/commit/1ae7342a7dd44561c86dcd2de456169185e1ce80
DIFF: https://github.com/llvm/llvm-project/commit/1ae7342a7dd44561c86dcd2de456169185e1ce80.diff

LOG: [mlir][linalg] Fix windows build issue in hoist padding.

Iterating backwardSlice and removing elements at the same time can fail on windows for specific build configurations (the code was introduced in https://reviews.llvm.org/D114420). This revision introduces a second vector to collect all operations and removes them after finishing the reverse iteration.

Reviewed By: hpmorgan

Differential Revision: https://reviews.llvm.org/D114775

Added: 
    

Modified: 
    mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp b/mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp
index 29cc48350938..6b8490b6a833 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp
@@ -272,6 +272,7 @@ HoistingAnalysis::dropNonIndexDependencies(PadTensorOp padTensorOp,
   // After iterating `backwardSlice` we obtain:
   // indexEdges = [%i, %j, %ubi, %ubj]
   // backwardSlice = backwardSlice / [linalg.fill(%cst, %arg1), scf.for %k]
+  SetVector<Operation *> operationsToRemove;
   for (Operation *op : llvm::reverse(backwardSlice)) {
     // Add the index operands of `padTensorOp` and `sliceOp` to start the
     // exploration of the index computation.
@@ -308,11 +309,12 @@ HoistingAnalysis::dropNonIndexDependencies(PadTensorOp padTensorOp,
       }
       continue;
     }
-    // Remove all other operation not used by the index computation except for
-    // constant operations that may be padding values used by `padTensorOp`.
+    // Remove all other operations not used by the index computation. An
+    // exception are constant operations that may be used by `padTensorOp`.
     if (!isa<arith::ConstantOp>(op))
-      backwardSlice.remove(op);
+      operationsToRemove.insert(op);
   }
+  backwardSlice.set_subtract(operationsToRemove);
   return success();
 }
 


        


More information about the Mlir-commits mailing list