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

Function ggml_opt_init

subprojects/llama.cpp/ggml/src/ggml-opt.cpp:549–582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

547}
548
549ggml_opt_context_t ggml_opt_init(struct ggml_opt_params params) {
550 ggml_opt_context_t result = new struct ggml_opt_context;
551 result->backend_sched = params.backend_sched;
552 result->ctx_compute = params.ctx_compute;
553 result->loss_type = params.loss_type;
554 result->build_type = params.build_type;
555 result->build_type_alloc = params.build_type;
556 result->inputs = params.inputs;
557 result->outputs = params.outputs;
558 result->opt_period = params.opt_period;
559 result->get_opt_pars = params.get_opt_pars;
560 result->get_opt_pars_ud = params.get_opt_pars_ud;
561 result->optimizer = params.optimizer;
562
563 GGML_ASSERT(result->opt_period >= 1);
564
565 result->static_graphs = result->ctx_compute;
566
567 if (!result->static_graphs) {
568 GGML_ASSERT(!result->inputs);
569 GGML_ASSERT(!result->outputs);
570 return result;
571 }
572
573 GGML_ASSERT(result->inputs);
574 GGML_ASSERT(result->outputs);
575
576 result->gf = ggml_new_graph_custom(result->ctx_compute, GGML_DEFAULT_GRAPH_SIZE, /*grads =*/ true); // Forward pass.
577 ggml_build_forward_expand(result->gf, result->outputs);
578
579 ggml_opt_build(result);
580
581 return result;
582}
583
584void ggml_opt_free(ggml_opt_context_t opt_ctx) {
585 if (opt_ctx == nullptr) {

Callers 3

opt_initMethod · 0.85
helper_get_ctx_dataFunction · 0.85
ggml_opt_fitFunction · 0.85

Calls 3

ggml_new_graph_customFunction · 0.85
ggml_opt_buildFunction · 0.85

Tested by 1

helper_get_ctx_dataFunction · 0.68