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

Function round_half_to_even

dnn/src/naive/remap/opr_impl.cpp:141–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139namespace {
140
141inline float round_half_to_even(float f) {
142 const float round_away_from_zero = std::round(f);
143 const float diff = round_away_from_zero - f;
144
145 if ((diff != 0.5f) && (diff != -0.5f)) {
146 return round_away_from_zero;
147 }
148
149 if (std::fmod(round_away_from_zero, 2.0f) == 0.0f) {
150 return round_away_from_zero;
151 }
152
153 return f - diff;
154}
155
156} // anonymous namespace
157

Callers 2

remap_NEARESTFunction · 0.85

Calls 2

roundFunction · 0.50
fmodFunction · 0.50

Tested by

no test coverage detected