Maybe there is a precision issue with torch.quantize_per_channel?

757.5/15 = 50.5 torch.round(50.5) = 50
The result here should be 50, why is the actual output 51?

The quantize_per_channel function uses std::lrint for rounding with the default round_mode, which rounds to the nearest integer. However, torch.round employs the half_to_even mode for rounding.

The source code seems to use torch.round

Please refer to C++/cuda source code if you are in eager mode

1 Like