interplane.Get Omega
Read in your language

ggml

[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)

Brought by drakestapleton

branch master Branches Tags History

ggml / src / ggml-rpc / log.h

49 lines · 1685 bytes Raw Blame History
1#pragma once
2
3// Log infrastructure for the RPC backend: LOG_* are unconditional, LOG_DBG* are gated by GGML_RPC_DEBUG
4
5#include "ggml-impl.h"
6
7#include <cstddef>
8#include <cstdlib>
9#include <string>
10
11// GGML_RPC_DEBUG verbosity: unset / 0 disabled, 1 connections and allocations, 2 per-command trace,
12// 3 per-message detail. Non-numeric values fall back to 1
13static inline int rpc_log_debug_level() {
14 static const int level = [] {
15 const char * env = std::getenv("GGML_RPC_DEBUG");
16 if (env == nullptr) {
17 return 0;
18 }
19 if (env[0] == '\0') {
20 return 1;
21 }
22 int value = 0;
23 for (const char * p = env; *p != '\0'; p++) {
24 if (*p < '0' || *p > '9') {
25 return 1;
26 }
27 value = value * 10 + (*p - '0');
28 if (value > 3) {
29 value = 3;
30 }
31 }
32 return value;
33 }();
34 return level;
35}
36
37// Byte counts in binary units, e.g. 8208 -> "8.02 KiB". Sizes below 1 KiB stay in plain bytes
38std::string rpc_log_format_size(size_t size);
39
40// Tensor identity: "blk.0.attn_q.weight [NONE, f16, [4096, 4096, 1, 1]]"
41std::string rpc_log_format_tensor(const ggml_tensor * tensor);
42
43#define LOG_INFO(...) GGML_LOG_INFO(__VA_ARGS__)
44#define LOG_WARN(...) GGML_LOG_WARN(__VA_ARGS__)
45#define LOG_ERROR(...) GGML_LOG_ERROR(__VA_ARGS__)
46
47#define LOG_DBG(...) do { if (rpc_log_debug_level() >= 1) GGML_LOG_DEBUG(__VA_ARGS__); } while (0)
48#define LOG_DBG2(...) do { if (rpc_log_debug_level() >= 2) GGML_LOG_DEBUG(__VA_ARGS__); } while (0)
49#define LOG_DBG3(...) do { if (rpc_log_debug_level() >= 3) GGML_LOG_DEBUG(__VA_ARGS__); } while (0)