File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change 1
1
set (TARGET llama-simple )
2
2
add_executable (${TARGET} simple.cpp )
3
3
install (TARGETS ${TARGET} RUNTIME )
4
- target_link_libraries (${TARGET} PRIVATE llama ${CMAKE_THREAD_LIBS_INIT} )
4
+ target_link_libraries (${TARGET} PRIVATE llama llama-common-test ${CMAKE_THREAD_LIBS_INIT} )
5
5
target_compile_features (${TARGET} PRIVATE cxx_std_17 )
Original file line number Diff line number Diff line change
1
+ #include " llama-cpp.h"
1
2
#include " llama.h"
2
3
#include < cstdio>
3
4
#include < cstring>
4
5
#include < string>
5
- #include < vector>
6
6
7
7
static void print_usage (int , char ** argv) {
8
8
printf (" \n example usage:\n " );
9
9
printf (" \n %s -m model.gguf [-n n_predict] [-ngl n_gpu_layers] [prompt]\n " , argv[0 ]);
10
+ printf (" \n Optional environment variables: LLAMA_EXAMPLE_MEMORY_BUFFER LLAMA_EXAMPLE_MEMORY_BUFFER_SPLIT" );
10
11
printf (" \n " );
11
12
}
12
13
14
+ #ifdef LLAMA_COMMON_TEST_HEADERS
15
+ #include " load_into_memory.h"
16
+ #endif
17
+
13
18
int main (int argc, char ** argv) {
14
19
// path to the model gguf file
15
20
std::string model_path;
@@ -83,12 +88,13 @@ int main(int argc, char ** argv) {
83
88
llama_model_params model_params = llama_model_default_params ();
84
89
model_params.n_gpu_layers = ngl;
85
90
91
+ #ifdef LLAMA_COMMON_TEST_HEADERS
92
+ llama_model * model = memory_configuration_env_is_set () ?
93
+ load_model_from_memory_configuration (model_path.c_str (), model_params) :
94
+ llama_model_load_from_file (model_path.c_str (), model_params);
95
+ #else
86
96
llama_model * model = llama_model_load_from_file (model_path.c_str (), model_params);
87
-
88
- if (model == NULL ) {
89
- fprintf (stderr , " %s: error: unable to load model\n " , __func__);
90
- return 1 ;
91
- }
97
+ #endif
92
98
93
99
const llama_vocab * vocab = llama_model_get_vocab (model);
94
100
// tokenize the prompt
You can’t perform that action at this time.
0 commit comments