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

[quant] Compute scale and zero point automatically in testing::_quantize #46232

Closed
wants to merge 5 commits into from

Conversation

z-a-f
Copy link
Contributor

@z-a-f z-a-f commented Oct 13, 2020

Stack from ghstack:

Differential Revision: D24271061

@dr-ci
Copy link

dr-ci bot commented Oct 13, 2020

💊 CI failures summary and remediations

As of commit f027bc5 (more details on the Dr. CI page):


  • 2/2 failures possibly* introduced in this PR
    • 2/2 non-CircleCI failure(s)

Extra GitHub checks: 1 failed


codecov.io: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 12 times.

@codecov
Copy link

codecov bot commented Oct 13, 2020

Codecov Report

Merging #46232 into gh/z-a-f/74/base will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@                 Coverage Diff                  @@
##           gh/z-a-f/74/base   #46232      +/-   ##
====================================================
- Coverage             68.34%   68.33%   -0.01%     
====================================================
  Files                   410      410              
  Lines                 53804    53813       +9     
====================================================
+ Hits                  36770    36771       +1     
- Misses                17034    17042       +8     
Impacted Files Coverage Δ
torch/testing/_internal/common_quantized.py 85.41% <ø> (-6.54%) ⬇️
torch/testing/_internal/expecttest.py 77.55% <0.00%> (-1.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd6ee10...f027bc5. Read the comment docs.

qx = np.round(x / scale + zero_point).astype(np.int64)
qx = np.clip(qx, qmin, qmax)
qx = qx.astype(dtype)
return qx
return qx, scale, zero_point
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we actually using the returned scale and zero_point anywhere in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only in one case I needed it -- this is optional, but because the current function returns the int_repr of the x, it losses information about the scale and zero_point, especially if it is inferred internally in this function

@@ -21,16 +21,27 @@ def _conv_output_shape(input_size, kernel_size, padding, stride, dilation,
* (dilation - 1)) / stride) + 2 * output_padding + 1

# Quantization references
def _quantize(x, scale, zero_point, qmin=None, qmax=None, dtype=np.uint8):
def _quantize(x, scale=None, zero_point=None, qmin=None, qmax=None,
dtype=np.uint8):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to update the docstring for this function to reflect the new behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the comment here? This is just an internal function for testing -- do we have a docstring?

@z-a-f z-a-f requested a review from supriyar October 14, 2020 19:08
@github-actions
Copy link

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions bot added the Stale label Apr 12, 2022
@github-actions github-actions bot closed this May 12, 2022
@facebook-github-bot facebook-github-bot deleted the gh/z-a-f/74/head branch June 12, 2022 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants