summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Dialect/QuantOps
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib/Dialect/QuantOps')
-rw-r--r--mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp2
-rw-r--r--mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp12
2 files changed, 10 insertions, 4 deletions
diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp
index 0c93146a232..32d8c8a81c1 100644
--- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp
+++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp
@@ -70,7 +70,7 @@ public:
UniformQuantizedType uniformElementType = fakeQuantAttrsToType(
fqOp.getLoc(), fqOp.num_bits().getSExtValue(),
fqOp.min().convertToFloat(), fqOp.max().convertToFloat(),
- fqOp.narrow_range(), converter.expressedType);
+ fqOp.narrow_range(), converter.expressedType, fqOp.is_signed());
if (!uniformElementType) {
// Note that the fakeQuantAttrsToType will have emitted the error.
diff --git a/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp b/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp
index 13c622e50d1..2667da98242 100644
--- a/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp
+++ b/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp
@@ -45,9 +45,15 @@ mlir::quant::fakeQuantAttrsToType(Location loc, unsigned numBits, double rmin,
}
} else if (numBits <= 16) {
storageType = IntegerType::get(16, ctx);
- flags = QuantizationFlags::Signed;
- qmin = -32768;
- qmax = 32767;
+ if (isSigned) {
+ flags = QuantizationFlags::Signed;
+ qmin = -32768;
+ qmax = 32767;
+ } else {
+ flags = 0;
+ qmin = 0;
+ qmax = 65535;
+ }
} else {
emitError(loc, "unsupported FakeQuant number of bits: ") << numBits;
return nullptr;
OpenPOWER on IntegriCloud