| 432 | } |
| 433 | |
| 434 | static std::pair<int, int> test_epoch_vs_fit(ggml_backend_sched_t backend_sched, ggml_backend_t backend) { |
| 435 | int ntest = 0; |
| 436 | int npass = 0; |
| 437 | |
| 438 | float weights_epoch; |
| 439 | float weights_fit; |
| 440 | |
| 441 | { |
| 442 | struct helper_ctx_data cd = helper_get_ctx_data(backend_sched, backend, /*init_opt_ctx =*/ true); |
| 443 | ggml_opt_dataset_t dataset = cd.dataset_unsupervised; |
| 444 | |
| 445 | ggml_opt_dataset_shuffle(cd.opt_ctx, dataset, -1); |
| 446 | ggml_opt_epoch(cd.opt_ctx, dataset, cd.result, nullptr, ndata, nullptr, nullptr); |
| 447 | |
| 448 | ggml_backend_tensor_get(cd.weights, &weights_epoch, 0, ggml_nbytes(cd.weights)); |
| 449 | helper_free_ctx_data(cd); |
| 450 | } |
| 451 | { |
| 452 | struct helper_ctx_data cd = helper_get_ctx_data(backend_sched, backend, /*init_opt_ctx =*/ false); |
| 453 | ggml_opt_dataset_t dataset = cd.dataset_unsupervised; |
| 454 | |
| 455 | ggml_opt_fit(backend_sched, cd.ctx_compute, cd.inputs, cd.outputs, dataset, |
| 456 | GGML_OPT_LOSS_TYPE_SUM, ggml_opt_get_default_optimizer_params, 1, 1, 0.0f, true); |
| 457 | |
| 458 | ggml_backend_tensor_get(cd.weights, &weights_fit, 0, ggml_nbytes(cd.weights)); |
| 459 | helper_free_ctx_data(cd); |
| 460 | } |
| 461 | |
| 462 | const bool subtest_ok = weights_epoch == weights_fit; |
| 463 | |
| 464 | printf(" %s(): ", __func__); |
| 465 | if (subtest_ok) { |
| 466 | printf("\033[1;32mOK\033[0m\n"); |
| 467 | npass++; |
| 468 | } else { |
| 469 | printf("\033[1;31mFAIL\033[0m\n"); |
| 470 | } |
| 471 | ntest++; |
| 472 | |
| 473 | return std::make_pair(npass, ntest); |
| 474 | } |
| 475 | |
| 476 | static void helper_after_test_idata_split( |
| 477 | const char * func, const bool high_level, const int epoch, |
no test coverage detected