[mlir][StandardToSPIRV] Add support for lowering memref<?xi1> to SPIR-V

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D100452
This commit is contained in:
Hanhan Wang 2021-04-14 07:22:41 -07:00
parent 34367dd253
commit 7c4de2e9b9
2 changed files with 9 additions and 8 deletions

View File

@ -375,12 +375,6 @@ static Type convertTensorType(const spirv::TargetEnv &targetEnv,
static Type convertBoolMemrefType(const spirv::TargetEnv &targetEnv,
const SPIRVTypeConverter::Options &options,
MemRefType type) {
if (!type.hasStaticShape()) {
LLVM_DEBUG(llvm::dbgs()
<< type << " dynamic shape on i1 is not supported yet\n");
return nullptr;
}
Optional<spirv::StorageClass> storageClass =
SPIRVTypeConverter::getStorageClassForMemorySpace(
type.getMemorySpaceAsInt());
@ -411,6 +405,12 @@ static Type convertBoolMemrefType(const spirv::TargetEnv &targetEnv,
return nullptr;
}
if (!type.hasStaticShape()) {
auto arrayType =
spirv::RuntimeArrayType::get(arrayElemType, *arrayElemSize);
return wrapInStructAndGetPointer(arrayType, *storageClass);
}
int64_t memrefSize = (type.getNumElements() * numBoolBits + 7) / 8;
auto arrayElemCount = (memrefSize + *arrayElemSize - 1) / *arrayElemSize;
auto arrayType =

View File

@ -511,9 +511,10 @@ module attributes {
// CHECK-SAME: memref<*xi32>
func @unranked_memref(%arg0: memref<*xi32>) { return }
// Check that dynamic dims on i1 are not supported.
// CHECK-LABEL: func @memref_1bit_type
// CHECK-SAME: memref<?xi1>
// CHECK-SAME: !spv.ptr<!spv.struct<(!spv.rtarray<i32, stride=4> [0])>, StorageBuffer>
// NOEMU-LABEL: func @memref_1bit_type
// NOEMU-SAME: memref<?xi1>
func @memref_1bit_type(%arg0: memref<?xi1>) { return }
// CHECK-LABEL: func @dynamic_dim_memref