6
6
#include <stdbool.h>
7
7
8
8
#ifdef LLAMA_SHARED
9
- # ifdef _WIN32
9
+ # if defined( _WIN32 ) && !defined( __MINGW32__ )
10
10
# ifdef LLAMA_BUILD
11
11
# define LLAMA_API __declspec(dllexport)
12
12
# else
20
20
#endif
21
21
22
22
#define LLAMA_FILE_VERSION 1
23
- #define LLAMA_FILE_MAGIC 0x67676d66 // 'ggmf ' in hex
23
+ #define LLAMA_FILE_MAGIC 0x67676a74 // 'ggjt ' in hex
24
24
#define LLAMA_FILE_MAGIC_UNVERSIONED 0x67676d6c // pre-versioned files
25
25
26
26
#ifdef __cplusplus
@@ -45,7 +45,7 @@ extern "C" {
45
45
46
46
} llama_token_data ;
47
47
48
- typedef void (* llama_progress_callback )(double progress , void * ctx );
48
+ typedef void (* llama_progress_callback )(float progress , void * ctx );
49
49
50
50
struct llama_context_params {
51
51
int n_ctx ; // text context
@@ -55,6 +55,7 @@ extern "C" {
55
55
bool f16_kv ; // use fp16 for KV cache
56
56
bool logits_all ; // the llama_eval() call computes all logits, not just the last one
57
57
bool vocab_only ; // only load the vocabulary, no weights
58
+ bool use_mmap ; // use mmap if possible
58
59
bool use_mlock ; // force system to keep model in RAM
59
60
bool embedding ; // embedding mode only
60
61
@@ -66,6 +67,9 @@ extern "C" {
66
67
67
68
LLAMA_API struct llama_context_params llama_context_default_params ();
68
69
70
+ LLAMA_API bool llama_mmap_supported ();
71
+ LLAMA_API bool llama_mlock_supported ();
72
+
69
73
// Various functions for loading a ggml llama model.
70
74
// Allocate (almost) all memory needed for the model.
71
75
// Return NULL on failure
@@ -81,8 +85,24 @@ extern "C" {
81
85
LLAMA_API int llama_model_quantize (
82
86
const char * fname_inp ,
83
87
const char * fname_out ,
84
- int itype ,
85
- int qk );
88
+ int itype );
89
+
90
+ // Returns the KV cache that will contain the context for the
91
+ // ongoing prediction with the model.
92
+ LLAMA_API const uint8_t * llama_get_kv_cache (struct llama_context * ctx );
93
+
94
+ // Returns the size of the KV cache
95
+ LLAMA_API size_t llama_get_kv_cache_size (struct llama_context * ctx );
96
+
97
+ // Returns the number of tokens in the KV cache
98
+ LLAMA_API int llama_get_kv_cache_token_count (struct llama_context * ctx );
99
+
100
+ // Sets the KV cache containing the current context for the model
101
+ LLAMA_API void llama_set_kv_cache (
102
+ struct llama_context * ctx ,
103
+ const uint8_t * kv_cache ,
104
+ size_t n_size ,
105
+ int n_token_count );
86
106
87
107
// Run the llama inference to obtain the logits and probabilities for the next token.
88
108
// tokens + n_tokens is the provided batch of new tokens to process
@@ -135,9 +155,9 @@ extern "C" {
135
155
const llama_token * last_n_tokens_data ,
136
156
int last_n_tokens_size ,
137
157
int top_k ,
138
- double top_p ,
139
- double temp ,
140
- double repeat_penalty );
158
+ float top_p ,
159
+ float temp ,
160
+ float repeat_penalty );
141
161
142
162
// Performance information
143
163
LLAMA_API void llama_print_timings (struct llama_context * ctx );
@@ -150,4 +170,4 @@ extern "C" {
150
170
}
151
171
#endif
152
172
153
- #endif
173
+ #endif // LLAMA_H
0 commit comments