Fix rounding error flakiness in quantized_test (#47468)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/47468
**Summary:** QuantizePerChannel4d and QuantizePerChannel4dChannelsLast have issues with flakiness on both ARM and x86 builds.
The flakiness stems from two sources:
1. The rounding strategy used by quantization for half values is to round the number to the nearest even integer (e.g. `4.5->4`, `5.5 -> 6`, `6.5->6`; however the above tests are incorrect by expecting the values to be rounded away from zero.
2. On ARM devices, `quantize_val_arm` calculates `zero_point + round(val / scale)` which behaves differently from `quantize_val`, which calculates `zero_point + round(val * (1.0f/scale))`. This small distinction leaves enough room for the floating point arithmetic errors to change rounding behavior (e.g. `3 / .24 = 12.5` whereas `3 * (1.0f / .24) = 12.500001`).
**Test Plan:**
For local builds:
```
python setup.py develop
./build/bin/quantized_test --gtest_filter='TestQTensor.QuantizePerChannel4d*' --gtest_repeat=10000 | grep FAILURE
```
For ARM Neon:
```
BUILD_MOBILE_BENCHMARK=1 BUILD_MOBILE_TEST=1 ANDROID_DEBUG_SYMBOLS=1 BUILD_PYTORCH_MOBILE=1 ANDROID_ABI="armeabi-v7a with NEON" ./scripts/build_android.sh -DANDROID_CCACHE=$(which ccache) -DBUILD_BINARY=ON
adb push ./build/bin/quantized_test /data/local/tmp
adb shell "/data/local/tmp/quantized_test --gtest_filter='TestQTensor.QuantizePerChannel4d*' --gtest_repeat=1000 | grep FAILURE"
```
For ARM64:
```
BUILD_MOBILE_BENCHMARK=1 BUILD_MOBILE_TEST=1 ANDROID_DEBUG_SYMBOLS=1 BUILD_PYTORCH_MOBILE=1 ANDROID_ABI=arm64-v8a ./scripts/build_android.sh -DANDROID_CCACHE=$(which ccache) -DBUILD_BINARY=ON
adb push ./build/bin/quantized_test /data/local/tmp
adb shell "/data/local/tmp/quantized_test --gtest_filter='TestQTensor.QuantizePerChannel4d*' --gtest_repeat=1000 | grep FAILURE"
```
**Reviewers:**
**Subscribers:**
**Tasks:** T79019469
**Tags:**
Test Plan: Imported from OSS
Reviewed By: kimishpatel
Differential Revision: D24769889
Pulled By: AJLiu
fbshipit-source-id: 417e7339bac70df5b9f630a1e286fad435e49240