Skip to content

Commit a9553fc

Browse files
authored
skip unaryop round halfway cases for powerpc (#5814)
1 parent 769008b commit a9553fc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_unaryop.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,26 @@ static int test_unaryop(const ncnn::Mat& _a)
3939
// smaller range for tan asin acos
4040
Randomize(a, -1.f, 1.f);
4141
}
42+
#if __powerpc__
43+
// nearbyintf produces wrong result in halfway cases, why ?
44+
// too troublesome to resolve the compiler or qemu problem
45+
// so just skip them --- nihui
46+
if (op_type == 18)
47+
{
48+
// drop 0.4 ~ 0.6
49+
for (int i = 0; i < a.total(); i++)
50+
{
51+
float v = a[i];
52+
float vv = fabs(v - (int)v);
53+
while (vv > 0.4f && vv < 0.6f)
54+
{
55+
v = RandomFloat(-15, 15);
56+
vv = fabs(v - (int)v);
57+
}
58+
a[i] = v;
59+
}
60+
}
61+
#endif // __powerpc__
4262

4363
ncnn::ParamDict pd;
4464
pd.set(0, op_type);

0 commit comments

Comments
 (0)