MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / remainder

Method remainder

dnn/include/megdnn/dtype/half.hpp:1078–1104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1076 /// \param y second operand
1077 /// \return Half-precision division remainder stored in single-precision
1078 MEGDNN_HOST MEGDNN_DEVICE static expr remainder(float x, float y)
1079 {
1080#if defined(__CUDA_ARCH__)
1081 return expr(remainderf(x, y));
1082#elif HALF_ENABLE_CPP11_CMATH
1083 return expr(std::remainder(x, y));
1084#else
1085 if(builtin_isnan(x) || builtin_isnan(y))
1086 return expr(std::numeric_limits<float>::quiet_NaN());
1087 float ax = fabs(x), ay = fabs(y);
1088 if(ax >= 65536.0f || ay < ldexp(1.0f, -24))
1089 return expr(std::numeric_limits<float>::quiet_NaN());
1090 if(ay >= 65536.0f)
1091 return expr(x);
1092 if(ax == ay)
1093 return expr(builtin_signbit(x) ? -0.0f : 0.0f);
1094 ax = fmod(ax, ay+ay);
1095 float y2 = 0.5f * ay;
1096 if(ax > y2)
1097 {
1098 ax -= ay;
1099 if(ax >= y2)
1100 ax -= ay;
1101 }
1102 return expr(builtin_signbit(x) ? -ax : ax);
1103#endif
1104 }
1105
1106 /// Remainder implementation.
1107 /// \param x first operand

Callers

nothing calls this directly

Calls 7

exprClass · 0.70
remainderFunction · 0.70
builtin_isnanFunction · 0.70
fabsFunction · 0.70
ldexpFunction · 0.70
builtin_signbitFunction · 0.70
fmodFunction · 0.70

Tested by

no test coverage detected