Skip to content

Commit

Permalink
llama : introduce anonymous namespace in llama.cpp
Browse files Browse the repository at this point in the history
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: ggerganov#9557
  • Loading branch information
danbev committed Sep 23, 2024
1 parent e62e978 commit bfb1058
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2247,6 +2247,8 @@ static ggml_backend_buffer_type_t llama_default_buffer_type_cpu(bool host_buffer
GGML_UNUSED(host_buffer);
}

namespace {

//
// globals
//
Expand All @@ -2267,7 +2269,7 @@ struct llama_state {
void * log_callback_user_data = nullptr;
};

static llama_state g_state;
llama_state g_state;

// available llama models
enum e_model {
Expand Down Expand Up @@ -2333,9 +2335,9 @@ enum e_model {
MODEL_27B,
};

static const size_t kiB = 1024;
static const size_t MiB = 1024*kiB;
static const size_t GiB = 1024*MiB;
const size_t kiB = 1024;
const size_t MiB = 1024*kiB;
const size_t GiB = 1024*MiB;

struct llama_hparams {
bool vocab_only;
Expand Down Expand Up @@ -2839,6 +2841,8 @@ struct llama_control_vector {
}
};

}

struct llama_model {
e_model type = MODEL_UNKNOWN;
llm_arch arch = LLM_ARCH_UNKNOWN;
Expand Down

0 comments on commit bfb1058

Please sign in to comment.