[mlir/Quant] Allows to use 32 bits storage type
authorFeng Liu <liufeng.ee@gmail.com>
Wed, 22 Apr 2020 21:14:29 +0000 (14:14 -0700)
committerFeng Liu <liufeng.ee@gmail.com>
Thu, 23 Apr 2020 18:18:05 +0000 (11:18 -0700)
Differential Revision: https://reviews.llvm.org/D78671

mlir/lib/Dialect/Quant/Utils/FakeQuantSupport.cpp

index 51ed441..71b7e04 100644 (file)
@@ -35,6 +35,15 @@ static bool getDefaultStorageParams(unsigned numBits, bool narrowRange,
       qmin = 0;
       qmax = 65535;
     }
+  } else if (numBits <= 32) {
+    storageType = IntegerType::get(32, ctx);
+    if (isSigned) {
+      qmin = std::numeric_limits<int32_t>::min();
+      qmax = std::numeric_limits<int32_t>::max();
+    } else {
+      qmin = std::numeric_limits<uint32_t>::min();
+      qmax = std::numeric_limits<uint32_t>::max();
+    }
   } else {
     return true;
   }