Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llama : add benchmark example #2626

Merged
merged 19 commits into from
Aug 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
better checks for non-optimized builds
  • Loading branch information
slaren committed Aug 16, 2023
commit 5765f90f5873647e56cd6c30dd79c0f9b96af4de
18 changes: 13 additions & 5 deletions examples/llama-bench/llama-bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct cmd_params {
output_formats output_format;
};

static cmd_params cmd_params_defaults = {
static const cmd_params cmd_params_defaults = {
/* model */ {"models/7B/ggml-model-q4_0.bin"},
/* n_prompt */ {512},
/* n_gen */ {128},
Expand Down Expand Up @@ -688,9 +688,9 @@ struct markdown_printer : public printer {
value = backend_params::get_backend();
} else if (field == "test") {
char buf[128];
if (t.bparams.n_prompt > 0) {
if (t.bparams.n_prompt > 0 && t.bparams.n_gen == 0) {
snprintf(buf, sizeof(buf), "pp %d", t.bparams.n_prompt);
} else if (t.bparams.n_gen > 0) {
} else if (t.bparams.n_gen > 0 && t.bparams.n_prompt == 0) {
snprintf(buf, sizeof(buf), "tg %d", t.bparams.n_gen);
} else {
assert(false);
Expand Down Expand Up @@ -743,8 +743,16 @@ void llama_null_log_callback(enum llama_log_level level, const char * text, void
}

int main(int argc, char ** argv) {
#ifndef NDEBUG
fprintf(stderr, "warning: NDEBUG is not defined, performance may be affected\n");
#if !defined(NDEBUG)
fprintf(stderr, "warning: asserts enabled, performance may be affected\n");
#endif

#if (defined(_MSC_VER) && defined(_DEBUG)) || (!defined(_MSC_VER) && !defined(__OPTIMIZE__))
fprintf(stderr, "warning: debug build, performance may be affected\n");
#endif

#if defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_THREAD__)
fprintf(stderr, "warning: sanitizer enabled, performance may be affected\n");
#endif

cmd_params params = parse_cmd_params(argc, argv);
Expand Down