Skip to content

Commit

Permalink
[BE] QNNPACK Test - Sparsegemm tests, use ASSERT_NEAR (pytorch#104650)
Browse files Browse the repository at this point in the history
Compare fp numbers using assert_near with reference * 10e-3. Somewhat arbitrary threhold which makes the test to pass on SSE2, given the absolute numbers are in somewhat wider range.

Differential Revision: [D47195288](https://our.internmc.facebook.com/intern/diff/D47195288/)

Pull Request resolved: pytorch#104650
Approved by: https://github.com/mcr229
  • Loading branch information
digantdesai authored and pytorchmergebot committed Jul 6, 2023
1 parent ce1a405 commit cbad55f
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,10 @@ class GemmBlockSparseMicrokernelTester {

for (size_t mIndex = 0; mIndex < m(); mIndex++) {
for (size_t nIndex = 0; nIndex < n(); nIndex++) {
ASSERT_FLOAT_EQ(
ASSERT_NEAR(
c[mIndex * cStride() + nIndex],
acc[mIndex * n() + nIndex])
acc[mIndex * n() + nIndex],
std::abs(acc[mIndex * n() + nIndex]) * 1.0e-3f)
<< "at " << mIndex << ", " << nIndex
<< ": reference = " << acc[mIndex * n() + nIndex]
<< ", optimized = " << c[mIndex * cStride() + nIndex]
Expand Down

0 comments on commit cbad55f

Please sign in to comment.