Skip to content

Commit

Permalink
Properly compare floats in fully-connected-operator-tester (pytorch#8…
Browse files Browse the repository at this point in the history
…2688)

Need to use `ASSERT_FLOAT_EQ` for floats.

Right now the test often fails internally like this:

```
xplat/caffe2/aten/src/ATen/native/quantized/cpu/qnnpack/test/fully-connected-operator-tester.h:362
Expected equality of these values:
  output_dynamic[i * outputChannels() + c]
    Which is: -601.09
  ((float)accumulators[i * outputChannels() + c] * requantization_scales[c]) + float(bias[c])
    Which is: -601.09
at 0, 18: reference = -601.0899658203125, optimized = -601.09002685546875
```

```
xplat/caffe2/aten/src/ATen/native/quantized/cpu/qnnpack/test/fully-connected-operator-tester.h:362
Expected equality of these values:
  output_dynamic[i * outputChannels() + c]
    Which is: -65.6251
  ((float)accumulators[i * outputChannels() + c] * requantization_scales[c]) + float(bias[c])
    Which is: -65.6251
at 0, 7: reference = -65.625106811523438, optimized = -65.625099182128906
```
Pull Request resolved: pytorch#82688
Approved by: https://github.com/mehtanirav
  • Loading branch information
kit1980 authored and pytorchmergebot committed Aug 3, 2022
1 parent d3e7d09 commit 9647bec
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class FullyConnectedOperatorTester {
}
for (size_t i = 0; i < batchSize(); i++) {
for (size_t c = 0; c < outputChannels(); c++) {
ASSERT_EQ(
ASSERT_FLOAT_EQ(
output_dynamic[i * outputChannels() + c],
((float)accumulators[i * outputChannels() + c] *
requantization_scales[c]) + float(bias[c]))
Expand Down

0 comments on commit 9647bec

Please sign in to comment.