| 465 | } |
| 466 | |
| 467 | static 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 | |
| 505 | static void helper_after_test_idata_split( |
| 506 | enum ggml_opt_optimizer_type optim, |
no test coverage detected