MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / logb

Method logb

samples/common/half.h:2258–2282  ·  view source on GitHub ↗

Exponent implementation. \param arg number to query \return floating point exponent

Source from the content-addressed store, hash-verified

2256 /// \param arg number to query
2257 /// \return floating point exponent
2258 static half logb(half arg)
2259 {
2260 int abs = arg.data_ & 0x7FFF;
2261 if (!abs)
2262 return half(binary, 0xFC00);
2263 if (abs < 0x7C00)
2264 {
2265 int exp = (abs >> 10) - 15;
2266 if (abs < 0x400)
2267 for (; abs < 0x200; abs <<= 1, --exp)
2268 ;
2269 uint16 bits = (exp < 0) << 15;
2270 if (exp)
2271 {
2272 uint32_t m = std::abs(exp) << 6, e = 18;
2273 for (; m < 0x400; m <<= 1, --e)
2274 ;
2275 bits |= (e << 10) + m;
2276 }
2277 return half(binary, bits);
2278 }
2279 if (abs > 0x7C00)
2280 return arg;
2281 return half(binary, 0x7C00);
2282 }
2283
2284 /// Enumeration implementation.
2285 /// \param from number to increase/decrease

Callers

nothing calls this directly

Calls 2

halfClass · 0.70
absFunction · 0.70

Tested by

no test coverage detected