Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove assert on zero_point dtype of quantize/dequantize op #6475

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions torch_xla/experimental/quantized.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ def _check_scale_zp(input, scale, zero_point, axis, dtype):
# The followings are checked:
# 1. scale, zp are 1D tensor.
# 2. Lenghth of scale, zp matched the (de)quant dim.
# 3. zp dtype is the same as the quantized integer type.
# 3. dtype must be integer type
# 4. zero_point values must be within the range of dtype.
assert len(scale.shape) == 1 and len(zero_point.shape) == 1
assert zero_point.dtype == dtype
assert 'int' in str(dtype)
assert torch.equal(
zero_point,
torch.clamp(zero_point,
torch.iinfo(dtype).min,
torch.iinfo(dtype).max))
if axis == -1:
assert scale.numel() == 1 and zero_point.numel() == 1
else:
Expand Down
Loading