mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-24 22:17:32 +00:00
Don't change global FPU state during round-half-to-even (#5376)
* Don't change global FPU state * Handle infinity properly
This commit is contained in:
parent
67315d8ae0
commit
fabe02ddc2
1 changed files with 5 additions and 3 deletions
|
|
@ -43,9 +43,11 @@ void QGemm(
|
|||
concurrency::ThreadPool* thread_pool);
|
||||
|
||||
inline float RoundHalfToEven(float input) {
|
||||
std::fesetround(FE_TONEAREST);
|
||||
auto result = std::nearbyintf(input);
|
||||
return result;
|
||||
if (!std::isfinite(input)) {
|
||||
return input;
|
||||
}
|
||||
// std::remainder returns x - n, where n is the integral value nearest to x. When |x - n| = 0.5, n is chosen to be even
|
||||
return input - std::remainderf(input, 1.f);
|
||||
}
|
||||
|
||||
} // namespace onnxruntime
|
||||
|
|
|
|||
Loading…
Reference in a new issue