Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-rpc/log.cpp # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-rpc / log.cpp` 34 lines ยท 1039 bytes Raw Blame History 1 #include "log.h" 2 3 #include 4 #include 5 6 std::string rpc_log_format_size(size_t size) { 7 static const char * units[] = { "B", "KiB", "MiB", "GiB", "TiB", "PiB" }; 8 9 double value = (double) size; 10 size_t unit = 0; 11 while (value >= 1024.0 && unit + 1 < sizeof(units) / sizeof(units[0])) { 12 value /= 1024.0; 13 unit++; 14 } 15 16 char buf[32]; 17 if (unit == 0) { 18 snprintf(buf, sizeof(buf), "%zu B", size); 19 } else { 20 snprintf(buf, sizeof(buf), "%.2f %s", value, units[unit]); 21 } 22 return std::string(buf); 23 } 24 25 std::string rpc_log_format_tensor(const ggml_tensor * tensor) { 26 char shape[64]; 27 snprintf(shape, sizeof(shape), "[%" PRId64 ", %" PRId64 ", %" PRId64 ", %" PRId64 "]", tensor->ne[0], tensor->ne[1], 28 tensor->ne[2], tensor->ne[3]); 29 30 char buf[GGML_MAX_NAME + 192]; 31 snprintf(buf, sizeof(buf), "%s [%s, %s, %s]", ggml_get_name(tensor), ggml_op_name(tensor->op), 32 ggml_type_name(tensor->type), shape); 33 return std::string(buf); 34 }