We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d00ee41 commit 535ac19Copy full SHA for 535ac19
torchao/quantization/quant_primitives.py
@@ -944,10 +944,16 @@ def _choose_qparams_affine(
944
else:
945
zero_point = torch.full_like(scale, int((quant_max + quant_min + 1) / 2))
946
scale = torch.clamp(scale, min=eps)
947
+ if torch.is_floating_point(scale):
948
+ # Prevent 1.0 / scale to become Inf.
949
+ scale = torch.clamp(scale, min=2 * torch.finfo(scale.dtype).tiny)
950
951
assert mapping_type == MappingType.ASYMMETRIC.name
952
scale = (max_val_pos - min_val_neg) / float(quant_max - quant_min)
953
954
955
956
957
if zero_point_domain == ZeroPointDomain.NONE.name:
958
zero_point = None
959
0 commit comments