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

Make the CUDA fake quantize logic consistent with CPU fake quantize logic #49808

Closed
wants to merge 2 commits into from

Commits on Dec 23, 2020

  1. Make the CUDA fake quantize logic consistent with CPU fake quantize l…

    …ogic
    
    In PyTorch, it uses `dst = std::nearbyint(src * inv_scale) + zero_point` instead of the LEGACY  `dst = std::nearbyint(src * inv_scale + zero_point)`. However, the CUDA implementation doesn't match this. This Diff makes the CPU and CUDA implementation consistent.
    
    - FBGEMM code pointer: https://github.com/pytorch/FBGEMM/blob/master/include/fbgemm/QuantUtils.h#L76-L80
    - PyTorch code pointer:
    https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/quantized/affine_quantizer.cpp#L306
    
    Differential Revision: [D25694235](https://our.internmc.facebook.com/intern/diff/D25694235/)
    
    **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D25694235/)!
    
    [ghstack-poisoned]
    jianyuh committed Dec 23, 2020
    Configuration menu
    Copy the full SHA
    ffb2db0 View commit details
    Browse the repository at this point in the history
  2. Update on "Make the CUDA fake quantize logic consistent with CPU fake…

    … quantize logic"
    
    In PyTorch, it uses `dst = std::nearbyint(src * inv_scale) + zero_point` instead of the LEGACY  `dst = std::nearbyint(src * inv_scale + zero_point)`. However, the CUDA implementation doesn't match this. This Diff makes the CPU and CUDA implementation consistent.
    
    - FBGEMM code pointer: https://github.com/pytorch/FBGEMM/blob/master/include/fbgemm/QuantUtils.h#L76-L80
    - PyTorch code pointer:
    https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/quantized/affine_quantizer.cpp#L306
    
    Differential Revision: [D25694235](https://our.internmc.facebook.com/intern/diff/D25694235/)
    
    **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D25694235/)!
    
    [ghstack-poisoned]
    jianyuh committed Dec 23, 2020
    Configuration menu
    Copy the full SHA
    9435306 View commit details
    Browse the repository at this point in the history