File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
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.h"
1
+ #include " llama-cpp .h"
2
2
#include < cstdio>
3
3
#include < cstring>
4
4
#include < string>
5
- #include < vector>
6
5
7
6
static void print_usage (int , char ** argv) {
8
7
printf (" \n example usage:\n " );
9
8
printf (" \n %s -m model.gguf [-n n_predict] [-ngl n_gpu_layers] [prompt]\n " , argv[0 ]);
9
+ printf (" \n Optional environment variables: LLAMA_EXAMPLE_MEMORY_BUFFER LLAMA_EXAMPLE_MEMORY_BUFFER_SPLIT" );
10
10
printf (" \n " );
11
11
}
12
12
13
+ #include " load_into_memory.h"
14
+
13
15
int main (int argc, char ** argv) {
14
16
// path to the model gguf file
15
17
std::string model_path;
@@ -83,12 +85,9 @@ int main(int argc, char ** argv) {
83
85
llama_model_params model_params = llama_model_default_params ();
84
86
model_params.n_gpu_layers = ngl;
85
87
86
- 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
- }
88
+ llama_model * model = memory_configuration_env_is_set () ?
89
+ load_model_from_memory_configuration (model_path.c_str (), model_params) :
90
+ llama_model_load_from_file (model_path.c_str (), model_params);
92
91
93
92
const llama_vocab * vocab = llama_model_get_vocab (model);
94
93
// tokenize the prompt
You can’t perform that action at this time.
0 commit comments