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

Function HumanReadableNum

tensorflow/core/lib/strings/numbers.cc:435–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433}
434
435string HumanReadableNum(int64 value) {
436 string s;
437 if (value < 0) {
438 s += "-";
439 value = -value;
440 }
441 if (value < 1000) {
442 Appendf(&s, "%lld", value);
443 } else if (value >= static_cast<int64>(1e15)) {
444 // Number bigger than 1E15; use that notation.
445 Appendf(&s, "%0.3G", static_cast<double>(value));
446 } else {
447 static const char units[] = "kMBT";
448 const char* unit = units;
449 while (value >= static_cast<int64>(1000000)) {
450 value /= static_cast<int64>(1000);
451 ++unit;
452 CHECK(unit < units + TF_ARRAYSIZE(units));
453 }
454 Appendf(&s, "%.2f%c", value / 1000.0, *unit);
455 }
456 return s;
457}
458
459string HumanReadableNumBytes(int64 num_bytes) {
460 if (num_bytes == kint64min) {

Callers 5

MainFunction · 0.85
SummarizeGraphFunction · 0.85
HumanReadableNumOpsFunction · 0.85
HeaderMethod · 0.85
TESTFunction · 0.85

Calls 1

AppendfFunction · 0.85

Tested by 1

TESTFunction · 0.68