Skip to content

Commit 7eee341

Browse files
slarenggerganov
andauthored
common : use common_ prefix for common library functions (ggml-org#9805)
* common : use common_ prefix for common library functions --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
1 parent 0e9f760 commit 7eee341

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1284
-1284
lines changed

common/arg.cpp

+434-434
Large diffs are not rendered by default.

common/arg.h

+22-22
Original file line numberDiff line numberDiff line change
@@ -10,68 +10,68 @@
1010
// CLI argument parsing
1111
//
1212

13-
struct llama_arg {
13+
struct common_arg {
1414
std::set<enum llama_example> examples = {LLAMA_EXAMPLE_COMMON};
1515
std::vector<const char *> args;
1616
const char * value_hint = nullptr; // help text or example for arg value
1717
const char * value_hint_2 = nullptr; // for second arg value
1818
const char * env = nullptr;
1919
std::string help;
2020
bool is_sparam = false; // is current arg a sampling param?
21-
void (*handler_void) (gpt_params & params) = nullptr;
22-
void (*handler_string) (gpt_params & params, const std::string &) = nullptr;
23-
void (*handler_str_str)(gpt_params & params, const std::string &, const std::string &) = nullptr;
24-
void (*handler_int) (gpt_params & params, int) = nullptr;
21+
void (*handler_void) (common_params & params) = nullptr;
22+
void (*handler_string) (common_params & params, const std::string &) = nullptr;
23+
void (*handler_str_str)(common_params & params, const std::string &, const std::string &) = nullptr;
24+
void (*handler_int) (common_params & params, int) = nullptr;
2525

26-
llama_arg(
26+
common_arg(
2727
const std::initializer_list<const char *> & args,
2828
const char * value_hint,
2929
const std::string & help,
30-
void (*handler)(gpt_params & params, const std::string &)
30+
void (*handler)(common_params & params, const std::string &)
3131
) : args(args), value_hint(value_hint), help(help), handler_string(handler) {}
3232

33-
llama_arg(
33+
common_arg(
3434
const std::initializer_list<const char *> & args,
3535
const char * value_hint,
3636
const std::string & help,
37-
void (*handler)(gpt_params & params, int)
37+
void (*handler)(common_params & params, int)
3838
) : args(args), value_hint(value_hint), help(help), handler_int(handler) {}
3939

40-
llama_arg(
40+
common_arg(
4141
const std::initializer_list<const char *> & args,
4242
const std::string & help,
43-
void (*handler)(gpt_params & params)
43+
void (*handler)(common_params & params)
4444
) : args(args), help(help), handler_void(handler) {}
4545

4646
// support 2 values for arg
47-
llama_arg(
47+
common_arg(
4848
const std::initializer_list<const char *> & args,
4949
const char * value_hint,
5050
const char * value_hint_2,
5151
const std::string & help,
52-
void (*handler)(gpt_params & params, const std::string &, const std::string &)
52+
void (*handler)(common_params & params, const std::string &, const std::string &)
5353
) : args(args), value_hint(value_hint), value_hint_2(value_hint_2), help(help), handler_str_str(handler) {}
5454

55-
llama_arg & set_examples(std::initializer_list<enum llama_example> examples);
56-
llama_arg & set_env(const char * env);
57-
llama_arg & set_sparam();
55+
common_arg & set_examples(std::initializer_list<enum llama_example> examples);
56+
common_arg & set_env(const char * env);
57+
common_arg & set_sparam();
5858
bool in_example(enum llama_example ex);
5959
bool get_value_from_env(std::string & output);
6060
bool has_value_from_env();
6161
std::string to_string();
6262
};
6363

64-
struct gpt_params_context {
64+
struct common_params_context {
6565
enum llama_example ex = LLAMA_EXAMPLE_COMMON;
66-
gpt_params & params;
67-
std::vector<llama_arg> options;
66+
common_params & params;
67+
std::vector<common_arg> options;
6868
void(*print_usage)(int, char **) = nullptr;
69-
gpt_params_context(gpt_params & params) : params(params) {}
69+
common_params_context(common_params & params) : params(params) {}
7070
};
7171

7272
// parse input arguments from CLI
7373
// if one argument has invalid value, it will automatically display usage of the specific argument (and not the full usage message)
74-
bool gpt_params_parse(int argc, char ** argv, gpt_params & params, llama_example ex, void(*print_usage)(int, char **) = nullptr);
74+
bool common_params_parse(int argc, char ** argv, common_params & params, llama_example ex, void(*print_usage)(int, char **) = nullptr);
7575

7676
// function to be used by test-arg-parser
77-
gpt_params_context gpt_params_parser_init(gpt_params & params, llama_example ex, void(*print_usage)(int, char **) = nullptr);
77+
common_params_context common_params_parser_init(common_params & params, llama_example ex, void(*print_usage)(int, char **) = nullptr);

0 commit comments

Comments
 (0)