Skip to content

Instantly share code, notes, and snippets.

@vaibkumr
Created October 11, 2019 18:03
Show Gist options
  • Save vaibkumr/38dd865605f1a20222a3be3b57a08d76 to your computer and use it in GitHub Desktop.
Save vaibkumr/38dd865605f1a20222a3be3b57a08d76 to your computer and use it in GitHub Desktop.
import torch
t = torch.tensor([1.111111111])
t_q = torch.quantize_per_tensor(t, 0.1, 10, torch.quint8)
#output: tensor([21], dtype=torch.uint8)
print(t_q.int_repr())
#output: tensor([1.1000], size=(1,), dtype=torch.quint8, quantization_scheme=torch.per_tensor_affine, scale=0.1, zero_point=10)
print(t_q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment