[Mlir-commits] [mlir] faf77f8 - [mlir][nfc] Clarify the limitation on scalable vectors
Andrzej Warzynski
llvmlistbot at llvm.org
Wed Jul 19 00:01:42 PDT 2023
Author: Andrzej Warzynski
Date: 2023-07-19T07:00:35Z
New Revision: faf77f8dec2f83ada139a0d6fe7acb9b3902ae8b
URL: https://github.com/llvm/llvm-project/commit/faf77f8dec2f83ada139a0d6fe7acb9b3902ae8b
DIFF: https://github.com/llvm/llvm-project/commit/faf77f8dec2f83ada139a0d6fe7acb9b3902ae8b.diff
LOG: [mlir][nfc] Clarify the limitation on scalable vectors
When converting/lowering to LLVM, MLIR does not support n-D scalable
vectors at the moment. This patch simply clarifies an assert that's
meant to catch such unsupported cases.
Note that we may want to relax this condition in the future.
Differential Revision: https://reviews.llvm.org/D154302
Added:
Modified:
mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
index 4ca5c7510d9eda..9e03e2ffbacf83 100644
--- a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
@@ -457,6 +457,9 @@ Type LLVMTypeConverter::convertMemRefToBarePtr(BaseMemRefType type) {
/// * 1-D `vector<axT>` remains as is while,
/// * n>1 `vector<ax...xkxT>` convert via an (n-1)-D array type to
/// `!llvm.array<ax...array<jxvector<kxT>>>`.
+/// As LLVM does not support arrays of scalable vectors, it is assumed that
+/// scalable vectors are always 1-D. This condition could be relaxed once the
+/// missing functionality is added in LLVM
Type LLVMTypeConverter::convertVectorType(VectorType type) {
auto elementType = convertType(type.getElementType());
if (!elementType)
@@ -467,8 +470,9 @@ Type LLVMTypeConverter::convertVectorType(VectorType type) {
type.getScalableDims().back());
assert(LLVM::isCompatibleVectorType(vectorType) &&
"expected vector type compatible with the LLVM dialect");
- assert((type.isScalable() == type.allDimsScalable()) &&
- "expected scalable vector with all dims scalable");
+ assert(
+ (!type.isScalable() || (type.getRank() == 1)) &&
+ "expected 1-D scalable vector (n-D scalable vectors are not supported)");
auto shape = type.getShape();
for (int i = shape.size() - 2; i >= 0; --i)
vectorType = LLVM::LLVMArrayType::get(vectorType, shape[i]);
More information about the Mlir-commits
mailing list