Skip to content

Commit 04745c7

Browse files
committed
Update the activation test compare check to include NaN case
1 parent bc4d50b commit 04745c7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

onnxruntime/test/mlas/unittest/test_activation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ class MlasActivationTest : public MlasTestBase {
247247
for (unsigned i = 0; i < _countof(TestData); i++) {
248248
// Sensitive to comparing positive/negative zero and NaNs.
249249
float error = std::min(std::fabs((Buffer[i].f - TestData[i][kind].f) / TestData[i][kind].f), std::fabs(Buffer[i].f - TestData[i][kind].f));
250-
EXPECT_TRUE(Buffer[i].u == TestData[i][kind].u || Buffer[i].f == TestData[i][kind].f || error < 0.000001f)
250+
EXPECT_TRUE(Buffer[i].u == TestData[i][kind].u || Buffer[i].f == TestData[i][kind].f || error < 0.000001f ||
251+
(std::isnan(TestData[i][kind].f) && std::isnan(error)))
251252
<< ", Scalar Activation Kind:" << (int)kind << ", i=" << i << ", value:"
252253
<< std::setw(8) << std::setfill('0') << std::hex << Buffer[i].u << ", expecting:"
253254
<< std::setw(8) << std::setfill('0') << std::hex << TestData[i][kind].u;

0 commit comments

Comments
 (0)