diff --git a/imperative/python/megengine/core/tensor/dtype.py b/imperative/python/megengine/core/tensor/dtype.py index ea9eb358564c4904edcb2916d140e922ab88f306..ba3d569596d3c1377a489acd9ac5306d5ff7e1b2 100644 --- a/imperative/python/megengine/core/tensor/dtype.py +++ b/imperative/python/megengine/core/tensor/dtype.py @@ -146,6 +146,13 @@ def create_quantized_dtype( else: # Don't trick to combine with is_unsigned. Metadata should not contain # invalid field to keep consistent with c dtype. + if zp is not None: + raise ValueError( + "'{}' only supports symmetric quantization, " + "zero_point should be None, but actually got '{}'".format( + dtype_meta.name, zp + ) + ) return np.dtype( dtype_meta.np_dtype_str, metadata={"mgb_dtype": {"name": dtype_meta.cname, "scale": float(scale)}}, diff --git a/imperative/python/megengine/quantization/utils.py b/imperative/python/megengine/quantization/utils.py index 00699d3fba3de85d414bc80fae23dd759d53fc76..216c2172a99ac6f3344a863a7dd5215252cf5a69 100644 --- a/imperative/python/megengine/quantization/utils.py +++ b/imperative/python/megengine/quantization/utils.py @@ -210,6 +210,9 @@ def fake_quant_bias(bias: Tensor, inp: Tensor, w_qat: Tensor) -> Tensor: if inp_params.scale is None or w_params.scale is None: return b_qat + if inp_params.mode != QuantMode.SYMMERTIC: + return b_qat + # TODO: support different mode if inp_params.mode != w_params.mode: return b_qat