summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp
diff options
context:
space:
mode:
authorFeng Liu <fengliuai@google.com>2019-07-18 11:25:53 -0700
committerMehdi Amini <joker.eph@gmail.com>2019-07-19 11:39:54 -0700
commit701266c47abab7180d36ae174f19d76a113a77a4 (patch)
tree697c3673664e24484f80ba7a58fdc74c68c1531a /mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp
parent90b5a381ce1ae04c4d67071c1098c946848cb342 (diff)
downloadbcm5719-llvm-701266c47abab7180d36ae174f19d76a113a77a4.tar.gz
bcm5719-llvm-701266c47abab7180d36ae174f19d76a113a77a4.zip
Add an "is_signed" attribute to the quant_ConstFakeQuant op
Some TensorFlow simulated quantize ops such as QuantizeAndDequantizeV2Op have attribute for the sign of the quantization, so quant_ConstFakeQuant should be able to represent it with the new attribute is added. The method for converting these attributes to an QuantizedType is updated to handle this new argument. PiperOrigin-RevId: 258810290
Diffstat (limited to 'mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp')
-rw-r--r--mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp12
1 files changed, 9 insertions, 3 deletions
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