Skip to content

Commit 16a8051

Browse files
Use ASSERT_FLOAT_EQ
1 parent 003ac9e commit 16a8051

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/dnnl/TestApiOps.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ TEST(TestApiOps, div) {
6060
for (auto i = 0; i < 64; i++) {
6161
for (auto j = 0; j < 32; j++) {
6262
for (auto k = 0; k < 32; k++) {
63-
ASSERT_EQ(arg1[i][j][k] / arg2[i][j][k], arg3[i][j][k]);
63+
ASSERT_FLOAT_EQ(arg1[i][j][k] / arg2[i][j][k], arg3[i][j][k]);
6464
}
6565
}
6666
}
@@ -113,7 +113,7 @@ TEST(TestApiOps, matMul) {
113113
// Compare the results
114114
for (auto i = 0; i < 512; i++) {
115115
for (auto j = 0; j < 64; j++) {
116-
ASSERT_EQ(expected[i][j], argOut[i][j]);
116+
ASSERT_FLOAT_EQ(expected[i][j], argOut[i][j]);
117117
}
118118
}
119119
}
@@ -135,7 +135,7 @@ TEST(TestApiOps, mul) {
135135
exec("mul.json", inputs, outputs);
136136

137137
for (auto i = 0; i < 128; i++) {
138-
ASSERT_EQ(arg3[i], static_cast<std::float32_t>(i * i));
138+
ASSERT_FLOAT_EQ(arg3[i], static_cast<std::float32_t>(i * i));
139139
}
140140
}
141141

@@ -157,7 +157,7 @@ TEST(TestApiOps, sub) {
157157
exec("sub.json", inputs, outputs);
158158

159159
for (auto i = 0; i < 128; i++) {
160-
ASSERT_EQ(arg3[i], arg1[i] - arg2[i]);
160+
ASSERT_FLOAT_EQ(arg3[i], arg1[i] - arg2[i]);
161161
}
162162
}
163163

@@ -176,7 +176,7 @@ TEST(TestApiOps, pow) {
176176
exec("pow.json", inputs, outputs);
177177

178178
for (auto i = 0; i < 64; i++) {
179-
ASSERT_EQ(arg1[i] * arg1[i], arg2[i]);
179+
ASSERT_FLOAT_EQ(arg1[i] * arg1[i], arg2[i]);
180180
}
181181
}
182182

@@ -196,7 +196,7 @@ TEST(TestApiOps, relu) {
196196
exec("relu.json", inputs, outputs);
197197

198198
for (auto i = 0; i < 128; i++) {
199-
ASSERT_EQ(arg1[i] < 0 ? 0 : arg1[i], arg2[i]);
199+
ASSERT_FLOAT_EQ(arg1[i] < 0 ? 0 : arg1[i], arg2[i]);
200200
}
201201
}
202202

@@ -233,7 +233,7 @@ TEST(TestApiOps, reduceMean) {
233233

234234
for (auto x = 0; x < 16; x++) {
235235
for (auto z = 0; z < 32; z++) {
236-
ASSERT_EQ(expected[x][0][z], arg2[x][0][z]);
236+
ASSERT_FLOAT_EQ(expected[x][0][z], arg2[x][0][z]);
237237
}
238238
}
239239
}
@@ -270,7 +270,7 @@ TEST(TestApiOps, reduceSum) {
270270

271271
for (auto x = 0; x < 16; x++) {
272272
for (auto z = 0; z < 32; z++) {
273-
ASSERT_EQ(expected[x][0][z], arg2[x][0][z]);
273+
ASSERT_FLOAT_EQ(expected[x][0][z], arg2[x][0][z]);
274274
}
275275
}
276276
}
@@ -290,7 +290,7 @@ TEST(TestApiOps, sigmoid) {
290290
exec("sigmoid.json", inputs, outputs);
291291

292292
for (auto i = 0; i < 128; i++) {
293-
ASSERT_EQ(1.f / (1.f + std::exp(-arg1[i])), arg2[i]);
293+
ASSERT_FLOAT_EQ(1.f / (1.f + std::exp(-arg1[i])), arg2[i]);
294294
}
295295
}
296296

0 commit comments

Comments
 (0)