[Mlir-commits] [mlir] [mlir][vector] Add `SwapShapeCastOfTranspose` canonicalizer pattern (PR #100933)
Benjamin Maxwell
llvmlistbot at llvm.org
Mon Jul 29 07:41:41 PDT 2024
================
@@ -5480,12 +5480,100 @@ class ShapeCastBroadcastFolder final : public OpRewritePattern<ShapeCastOp> {
}
};
+/// Returns an iterator over the dims (inc scalability) of a VectorType.
+static auto getDims(VectorType vType) {
+ return llvm::zip_equal(vType.getShape(), vType.getScalableDims());
+}
+
+/// Helper to drop (fixed-size) unit dims from a VectorType.
+static VectorType dropUnitDims(VectorType vType) {
+ SmallVector<bool> scalableFlags;
+ SmallVector<int64_t> dimSizes;
+ for (auto dim : getDims(vType)) {
+ if (dim == std::make_tuple(1, false))
+ continue;
+ auto [size, scalableFlag] = dim;
----------------
MacDue wrote:
This is done deliberately as a more convenience way to compare dim sizes (as there's no good vector API for it).
I prefer the tuple to `size == 1 && !scalableFlag` (which I find takes longer to grok).
https://github.com/llvm/llvm-project/pull/100933
More information about the Mlir-commits
mailing list