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

Hanhan Wang llvmlistbot at llvm.org
Wed Apr 14 07:23:09 PDT 2021


Author: Hanhan Wang
Date: 2021-04-14T07:22:49-07:00
New Revision: 7c4de2e9b9b469b073e6f5f044977b23ac1b26c6

URL: https://github.com/llvm/llvm-project/commit/7c4de2e9b9b469b073e6f5f044977b23ac1b26c6
DIFF: https://github.com/llvm/llvm-project/commit/7c4de2e9b9b469b073e6f5f044977b23ac1b26c6.diff

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

Reviewed By: antiagainst

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

Added: 
    

Modified: 
    mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
    mlir/test/Conversion/StandardToSPIRV/std-types-to-spirv.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
index 9de45e7200bd..5a590216678b 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
@@ -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 =

diff  --git a/mlir/test/Conversion/StandardToSPIRV/std-types-to-spirv.mlir b/mlir/test/Conversion/StandardToSPIRV/std-types-to-spirv.mlir
index aa4999d660a9..bb253a16947e 100644
--- a/mlir/test/Conversion/StandardToSPIRV/std-types-to-spirv.mlir
+++ b/mlir/test/Conversion/StandardToSPIRV/std-types-to-spirv.mlir
@@ -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


        


More information about the Mlir-commits mailing list