MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / test_gguf_set_kv

Function test_gguf_set_kv

subprojects/llama.cpp/tests/test-gguf.cpp:1214–1304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1212}
1213
1214static std::pair<int, int> test_gguf_set_kv(ggml_backend_dev_t dev, const unsigned int seed) {
1215 ggml_backend_t backend = ggml_backend_dev_init(dev, nullptr);
1216 printf("%s: device=%s, backend=%s\n", __func__, ggml_backend_dev_description(dev), ggml_backend_name(backend));
1217
1218 int npass = 0;
1219 int ntest = 0;
1220
1221 struct gguf_context * gguf_ctx_0;
1222 struct ggml_context * ctx_0;
1223 ggml_backend_buffer_t bbuf_0;
1224 {
1225 struct random_gguf_context_result result = get_random_gguf_context(backend, seed);
1226 gguf_ctx_0 = result.gguf_ctx;
1227 ctx_0 = result.ctx;
1228 bbuf_0 = result.buffer;
1229 }
1230
1231 struct gguf_context * gguf_ctx_1;
1232 struct ggml_context * ctx_1;
1233 ggml_backend_buffer_t bbuf_1;
1234 {
1235 struct random_gguf_context_result result = get_random_gguf_context(backend, seed + 1);
1236 gguf_ctx_1 = result.gguf_ctx;
1237 ctx_1 = result.ctx;
1238 bbuf_1 = result.buffer;
1239 }
1240
1241 struct gguf_context * gguf_ctx_2 = gguf_init_empty();
1242
1243 gguf_set_kv(gguf_ctx_1, gguf_ctx_0);
1244 gguf_set_kv(gguf_ctx_2, gguf_ctx_0);
1245
1246 printf("%s: same_n_kv: ", __func__);
1247 if (gguf_get_n_kv(gguf_ctx_0) == gguf_get_n_kv(gguf_ctx_2)) {
1248 printf("\033[1;32mOK\033[0m\n");
1249 npass++;
1250 } else {
1251 printf("\033[1;31mFAIL\033[0m\n");
1252 }
1253 ntest++;
1254
1255 printf("%s: all_kv_0_in_1: ", __func__);
1256 if (all_kv_in_other(gguf_ctx_0, gguf_ctx_1)) {
1257 printf("\033[1;32mOK\033[0m\n");
1258 npass++;
1259 } else {
1260 printf("\033[1;31mFAIL\033[0m\n");
1261 }
1262 ntest++;
1263
1264 printf("%s: all_kv_0_in_2: ", __func__);
1265 if (all_kv_in_other(gguf_ctx_0, gguf_ctx_2)) {
1266 printf("\033[1;32mOK\033[0m\n");
1267 npass++;
1268 } else {
1269 printf("\033[1;31mFAIL\033[0m\n");
1270 }
1271 ntest++;

Callers 1

mainFunction · 0.85

Calls 12

ggml_backend_dev_initFunction · 0.85
ggml_backend_nameFunction · 0.85
get_random_gguf_contextFunction · 0.85
gguf_init_emptyFunction · 0.85
gguf_set_kvFunction · 0.85
gguf_get_n_kvFunction · 0.85
all_kv_in_otherFunction · 0.85
ggml_backend_buffer_freeFunction · 0.85
ggml_freeFunction · 0.85
gguf_freeFunction · 0.85
ggml_backend_freeFunction · 0.85

Tested by

no test coverage detected