Skip to content

Commit bfb1058

Browse files
committed
llama : introduce anonymous namespace in llama.cpp
This commit introduces an anonymous namespace in llama.cpp to encapsulate the following structs and types: * llama_state * llama_hparams * llama_cparams * llama_layer * llama_ubatch * llama_kv_cell * llama_kv_cache * llama_control_vector * e_model There are potentially more structs, and also functions that are currently declared as static, which could be included in this anonymous namespace in the future. The motivation for this change is to avoid polluting the global namespace with these types. Refs: ggml-org#9557
1 parent e62e978 commit bfb1058

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/llama.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,6 +2247,8 @@ static ggml_backend_buffer_type_t llama_default_buffer_type_cpu(bool host_buffer
22472247
GGML_UNUSED(host_buffer);
22482248
}
22492249

2250+
namespace {
2251+
22502252
//
22512253
// globals
22522254
//
@@ -2267,7 +2269,7 @@ struct llama_state {
22672269
void * log_callback_user_data = nullptr;
22682270
};
22692271

2270-
static llama_state g_state;
2272+
llama_state g_state;
22712273

22722274
// available llama models
22732275
enum e_model {
@@ -2333,9 +2335,9 @@ enum e_model {
23332335
MODEL_27B,
23342336
};
23352337

2336-
static const size_t kiB = 1024;
2337-
static const size_t MiB = 1024*kiB;
2338-
static const size_t GiB = 1024*MiB;
2338+
const size_t kiB = 1024;
2339+
const size_t MiB = 1024*kiB;
2340+
const size_t GiB = 1024*MiB;
23392341

23402342
struct llama_hparams {
23412343
bool vocab_only;
@@ -2839,6 +2841,8 @@ struct llama_control_vector {
28392841
}
28402842
};
28412843

2844+
}
2845+
28422846
struct llama_model {
28432847
e_model type = MODEL_UNKNOWN;
28442848
llm_arch arch = LLM_ARCH_UNKNOWN;

0 commit comments

Comments
 (0)