MCPcopy Create free account
hub / github.com/ml-explore/mlx / parse_size

Function parse_size

mlx/distributed/jaccl/lib/examples/allreduce_bench.cpp:58–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58static size_t parse_size(const char* s) {
59 char* end = nullptr;
60 double val = std::strtod(s, &end);
61 if (end && (*end == 'K' || *end == 'k'))
62 val *= 1024;
63 else if (end && (*end == 'M' || *end == 'm'))
64 val *= 1024 * 1024;
65 else if (end && (*end == 'G' || *end == 'g'))
66 val *= 1024 * 1024 * 1024;
67 return static_cast<size_t>(val);
68}
69
70static std::string fmt_bytes(size_t bytes) {
71 const char* units[] = {"B", "KB", "MB", "GB", "TB"};

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected