Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix unaryop round build with old glibc #4963

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/layer/arm/unaryop_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,14 @@ struct unary_op_round
#endif
return y;
#else
#ifdef FE_TONEAREST
int old_rm = fegetround();
fesetround(FE_TONEAREST);
#endif
float y = nearbyintf(x);
#ifdef FE_TONEAREST
fesetround(old_rm);
#endif
return y;
#endif
}
Expand All @@ -431,13 +435,17 @@ struct unary_op_round
#else
float tmp[4];
vst1q_f32(tmp, x);
#ifdef FE_TONEAREST
int old_rm = fegetround();
fesetround(FE_TONEAREST);
#endif
tmp[0] = nearbyintf(tmp[0]);
tmp[1] = nearbyintf(tmp[1]);
tmp[2] = nearbyintf(tmp[2]);
tmp[3] = nearbyintf(tmp[3]);
#ifdef FE_TONEAREST
fesetround(old_rm);
#endif
float32x4_t y = vld1q_f32(tmp);
return y;
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/layer/arm/unaryop_arm_asimdhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,14 @@ struct unary_op_round_fp16s
:);
return y;
#else
#ifdef FE_TONEAREST
int old_rm = fegetround();
fesetround(FE_TONEAREST);
#endif
__fp16 y = (__fp16)nearbyintf(x);
#ifdef FE_TONEAREST
fesetround(old_rm);
#endif
return y;
#endif
}
Expand Down
4 changes: 4 additions & 0 deletions src/layer/loongarch/unaryop_loongarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,14 @@ struct unary_op_round
:);
return y;
#else
#ifdef FE_TONEAREST
int old_rm = fegetround();
fesetround(FE_TONEAREST);
#endif
float y = nearbyintf(x);
#ifdef FE_TONEAREST
fesetround(old_rm);
#endif
return y;
#endif
}
Expand Down
4 changes: 4 additions & 0 deletions src/layer/mips/unaryop_mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,14 @@ struct unary_op_round
:);
return y;
#else
#ifdef FE_TONEAREST
int old_rm = fegetround();
fesetround(FE_TONEAREST);
#endif
float y = nearbyintf(x);
#ifdef FE_TONEAREST
fesetround(old_rm);
#endif
return y;
#endif
}
Expand Down
4 changes: 4 additions & 0 deletions src/layer/unaryop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,14 @@ struct unary_op_round
float operator()(const float& x) const
{
// round to nearest even
#ifdef FE_TONEAREST
int old_rm = fegetround();
fesetround(FE_TONEAREST);
#endif
float y = nearbyintf(x);
#ifdef FE_TONEAREST
fesetround(old_rm);
#endif
return y;
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/layer/x86/unaryop_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,14 @@ struct unary_op_round
{
// round to nearest even
// return (x + 12582912.f) - 12582912.f;
#ifdef FE_TONEAREST
int old_rm = fegetround();
fesetround(FE_TONEAREST);
#endif
float y = nearbyintf(x);
#ifdef FE_TONEAREST
fesetround(old_rm);
#endif
return y;
}
#if __SSE2__
Expand Down
Loading