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

Function test_epoch_vs_fit

subprojects/llama.cpp/tests/test-opt.cpp:467–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467static std::pair<int, int> test_epoch_vs_fit(
468 enum ggml_opt_optimizer_type optim,
469 ggml_backend_sched_t backend_sched, ggml_backend_t backend) {
470 int ntest = 0;
471 int npass = 0;
472
473 float weights_epoch;
474 float weights_fit;
475
476 {
477 struct helper_ctx_data cd = helper_get_ctx_data(optim, backend_sched, backend, /*init_opt_ctx =*/ true);
478 ggml_opt_dataset_t dataset = cd.dataset_unsupervised;
479
480 ggml_opt_dataset_shuffle(cd.opt_ctx, dataset, -1);
481 ggml_opt_epoch(cd.opt_ctx, dataset, cd.result, nullptr, ndata, nullptr, nullptr);
482 // leaked.
483
484 ggml_backend_tensor_get(cd.weights, &weights_epoch, 0, ggml_nbytes(cd.weights));
485 helper_free_ctx_data(cd);
486 }
487 {
488 struct helper_ctx_data cd = helper_get_ctx_data(optim, backend_sched, backend, /*init_opt_ctx =*/ false);
489 ggml_opt_dataset_t dataset = cd.dataset_unsupervised;
490
491 ggml_opt_fit(backend_sched, cd.ctx_compute, cd.inputs, cd.outputs, dataset, GGML_OPT_LOSS_TYPE_SUM,
492 optim, ggml_opt_get_default_optimizer_params, 1, 1, 0.0f, true);
493
494 ggml_backend_tensor_get(cd.weights, &weights_fit, 0, ggml_nbytes(cd.weights));
495 helper_free_ctx_data(cd);
496 }
497
498 const bool subtest_ok = weights_epoch == weights_fit;
499
500 print_ok(__func__, subtest_ok, npass, ntest);
501
502 return std::make_pair(npass, ntest);
503}
504
505static void helper_after_test_idata_split(
506 enum ggml_opt_optimizer_type optim,

Callers 1

test_backendFunction · 0.85

Calls 8

helper_get_ctx_dataFunction · 0.85
ggml_opt_dataset_shuffleFunction · 0.85
ggml_opt_epochFunction · 0.85
ggml_backend_tensor_getFunction · 0.85
ggml_nbytesFunction · 0.85
helper_free_ctx_dataFunction · 0.85
ggml_opt_fitFunction · 0.85
print_okFunction · 0.85

Tested by

no test coverage detected