[Mlir-commits] [mlir] [MLIR][Vector]Generalize DropUnitDimFromElementwiseOps (PR #92934)
Benjamin Maxwell
llvmlistbot at llvm.org
Tue May 21 10:27:55 PDT 2024
================
@@ -1607,7 +1607,23 @@ struct ChainedReduction final : OpRewritePattern<vector::ReductionOp> {
}
};
-/// For vectors with either leading or trailing unit dim, replaces:
+FailureOr<VectorType> dropNonScalableUnitDimType(VectorType VT) {
+ VectorType newVT = VT;
+ int removed = 0;
+ auto shape = VT.getShape();
+ for (unsigned i = 0; i < shape.size(); i++) {
+ if (shape[i] == 1 && !VT.getScalableDims()[i]) {
+ newVT = VectorType::Builder(newVT).dropDim(i - removed);
----------------
MacDue wrote:
Can you move the `VectorType::Builder()` outside the loop, so in the loop you just call `builder.dropDim`? Right now, this is constructing a new vector type every time it removes a dimension.
https://github.com/llvm/llvm-project/pull/92934
More information about the Mlir-commits
mailing list