-
Notifications
You must be signed in to change notification settings - Fork 24.9k
fix at::from_blob_quantized_per_tensor_affine strides calculation #79314
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
Conversation
🔗 Helpful links
✅ No Failures (0 Pending)As of commit 9525d80 (more details on the Dr. CI page): Expand to see more💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
This pull request was exported from Phabricator. Differential Revision: D37061355 |
…torch#79314) Summary: Pull Request resolved: pytorch#79314 There seems to be a off-by-one bug in `at::from_blob_quantized_per_tensor_affine`. For an input with sizes {N, C, H, W}, before strides would be calculated as {NCH, CH, H, 1}, now strides is calculated as {CHW, HW, W, 1}. The updated unit test catches this problem. Test Plan: ``` buck test mode/dev-nosan //caffe2:quantized_test ``` before fix: ``` ✓ ListingSuccess: caffe2:quantized_test : 9 tests discovered (15.632) ✓ Pass: caffe2:quantized_test - TestQTensor.QuantDequantAPIs (0.004) ✗ Fail: caffe2:quantized_test - TestQTensor.FromBlobQuantizedPerTensor (0.002) Test output: > caffe2/aten/src/ATen/test/quantized_test.cpp:247 Expected equality of these values: qtensor[h][w].item<float>() Which is: -0.5 (custom_data[i] - zero_point) * scale Which is: 0 stdout: Note: Google Test filter = TestQTensor.FromBlobQuantizedPerTensor [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from TestQTensor [ RUN ] TestQTensor.FromBlobQuantizedPerTensor caffe2/aten/src/ATen/test/quantized_test.cpp:247: Failure Expected equality of these values: qtensor[h][w].item<float>() Which is: -0.5 (custom_data[i] - zero_point) * scale Which is: 0 [ FAILED ] TestQTensor.FromBlobQuantizedPerTensor (2 ms) [----------] 1 test from TestQTensor (2 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (2 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] TestQTensor.FromBlobQuantizedPerTensor 1 FAILED TEST ``` after fix: ``` ✓ ListingSuccess: caffe2:quantized_test : 9 tests discovered (16.051) ✓ Pass: caffe2:quantized_test - TestQTensor.RoundingMode (0.002) ✓ Pass: caffe2:quantized_test - TestQTensor.QuantizePerChannel4dChannelsLast (0.217) ✓ Pass: caffe2:quantized_test - TestQTensor.QuantDequantAPIs (0.003) ✓ Pass: caffe2:quantized_test - TestQTensor.EmptyPerchannelQuantized (0.003) ✓ Pass: caffe2:quantized_test - TestQTensor.EmptyQuantized (0.002) ✓ Pass: caffe2:quantized_test - TestQTensor.FromBlobQuantizedPerChannel (0.004) ✓ Pass: caffe2:quantized_test - TestQTensor.QuantizePerChannel4d (0.005) ✓ Pass: caffe2:quantized_test - TestQTensor.FromBlobQuantizedPerTensor (0.003) ✓ Pass: caffe2:quantized_test - TestQTensor.Item (0.002) Summary Pass: 9 ListingSuccess: 1 ``` Reviewed By: jerryzh168 Differential Revision: D37061355 fbshipit-source-id: 7ed77159192c2ce238905c2b3cebff3c0ef6898f
This pull request was exported from Phabricator. Differential Revision: D37061355 |
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
@pytorchbot successfully started a merge job. Check the current status here |
Hey @yzyz. |
…9314) Summary: Pull Request resolved: #79314 There seems to be a off-by-one bug in `at::from_blob_quantized_per_tensor_affine`. For an input with sizes {N, C, H, W}, before strides would be calculated as {NCH, CH, H, 1}, now strides is calculated as {CHW, HW, W, 1}. The updated unit test catches this problem. Test Plan: ``` buck test mode/dev-nosan //caffe2:quantized_test ``` before fix: ``` ✓ ListingSuccess: caffe2:quantized_test : 9 tests discovered (15.632) ✓ Pass: caffe2:quantized_test - TestQTensor.QuantDequantAPIs (0.004) ✗ Fail: caffe2:quantized_test - TestQTensor.FromBlobQuantizedPerTensor (0.002) Test output: > caffe2/aten/src/ATen/test/quantized_test.cpp:247 Expected equality of these values: qtensor[h][w].item<float>() Which is: -0.5 (custom_data[i] - zero_point) * scale Which is: 0 stdout: Note: Google Test filter = TestQTensor.FromBlobQuantizedPerTensor [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from TestQTensor [ RUN ] TestQTensor.FromBlobQuantizedPerTensor caffe2/aten/src/ATen/test/quantized_test.cpp:247: Failure Expected equality of these values: qtensor[h][w].item<float>() Which is: -0.5 (custom_data[i] - zero_point) * scale Which is: 0 [ FAILED ] TestQTensor.FromBlobQuantizedPerTensor (2 ms) [----------] 1 test from TestQTensor (2 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (2 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] TestQTensor.FromBlobQuantizedPerTensor 1 FAILED TEST ``` after fix: ``` ✓ ListingSuccess: caffe2:quantized_test : 9 tests discovered (16.051) ✓ Pass: caffe2:quantized_test - TestQTensor.RoundingMode (0.002) ✓ Pass: caffe2:quantized_test - TestQTensor.QuantizePerChannel4dChannelsLast (0.217) ✓ Pass: caffe2:quantized_test - TestQTensor.QuantDequantAPIs (0.003) ✓ Pass: caffe2:quantized_test - TestQTensor.EmptyPerchannelQuantized (0.003) ✓ Pass: caffe2:quantized_test - TestQTensor.EmptyQuantized (0.002) ✓ Pass: caffe2:quantized_test - TestQTensor.FromBlobQuantizedPerChannel (0.004) ✓ Pass: caffe2:quantized_test - TestQTensor.QuantizePerChannel4d (0.005) ✓ Pass: caffe2:quantized_test - TestQTensor.FromBlobQuantizedPerTensor (0.003) ✓ Pass: caffe2:quantized_test - TestQTensor.Item (0.002) Summary Pass: 9 ListingSuccess: 1 ``` Reviewed By: jerryzh168 Differential Revision: D37061355 fbshipit-source-id: c37b1f0459cfe948cdbafc9253701de9610ba0ad
Summary: There seems to be a off-by-one bug in
at::from_blob_quantized_per_tensor_affine
. For an input with sizes {N, C, H, W}, before strides would be calculated as {NCH, CH, H, 1}, now strides is calculated as {CHW, HW, W, 1}. The updated unit test catches this problem.Test Plan:
before fix:
after fix:
Differential Revision: D37061355