提交 683b3e30 编写于 作者: M Megvii Engine Team

fix(mge/quantization): disable creation of qint8 dtype with zeropoint

GitOrigin-RevId: d3b87c303f91ae333e8ba42c23180b9626836d39
上级 b245e4ed
......@@ -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)}},
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册