MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Log2Floor32_Portable

Function Log2Floor32_Portable

tensorflow/core/lib/strings/ordered_code.cc:419–433  ·  view source on GitHub ↗

Portable slow version

Source from the content-addressed store, hash-verified

417#else
418// Portable slow version
419static int Log2Floor32_Portable(uint32 n) {
420 if (n == 0) return -1;
421 int log = 0;
422 uint32 value = n;
423 for (int i = 4; i >= 0; --i) {
424 int shift = (1 << i);
425 uint32 x = value >> shift;
426 if (x != 0) {
427 value = x;
428 log += shift;
429 }
430 }
431 assert(value == 1);
432 return log;
433}
434// Returns floor(lg(n)). Returns -1 if n == 0.
435static int Log2Floor64(uint64 n) {
436 const uint32 topbits = static_cast<uint32>(n >> 32);

Callers 1

Log2Floor64Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected