test : simplify
ggml-ci
This commit is contained in:
parent
58356e6bba
commit
06b4979149
1 changed files with 10 additions and 20 deletions
|
@ -2,25 +2,10 @@
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <pthread.h>
|
#include <thread>
|
||||||
|
|
||||||
#include "llama.h"
|
#include "llama.h"
|
||||||
|
|
||||||
static std::string g_fname;
|
|
||||||
|
|
||||||
static void * llamacpp_pthread(void * arg) {
|
|
||||||
(void)arg;
|
|
||||||
|
|
||||||
llama_backend_init(false);
|
|
||||||
auto * model = llama_load_model_from_file(g_fname.c_str(), llama_model_default_params());
|
|
||||||
auto * ctx = llama_new_context_with_model(model, llama_context_default_params());
|
|
||||||
llama_free(ctx);
|
|
||||||
llama_free_model(model);
|
|
||||||
llama_backend_free();
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This creates a new context inside a pthread and then tries to exit cleanly.
|
// This creates a new context inside a pthread and then tries to exit cleanly.
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
|
@ -28,11 +13,16 @@ int main(int argc, char ** argv) {
|
||||||
return 0; // intentionally return success
|
return 0; // intentionally return success
|
||||||
}
|
}
|
||||||
|
|
||||||
g_fname = argv[1];
|
const std::string fname = argv[1];
|
||||||
|
|
||||||
pthread_t tid;
|
std::thread([&fname]() {
|
||||||
pthread_create(&tid, NULL, llamacpp_pthread, NULL);
|
llama_backend_init(false);
|
||||||
pthread_join(tid, NULL);
|
auto * model = llama_load_model_from_file(fname.c_str(), llama_model_default_params());
|
||||||
|
auto * ctx = llama_new_context_with_model(model, llama_context_default_params());
|
||||||
|
llama_free(ctx);
|
||||||
|
llama_free_model(model);
|
||||||
|
llama_backend_free();
|
||||||
|
}).join();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue