From 0e269665cd87fa803202fe18941a7478b41e7b92 Mon Sep 17 00:00:00 2001 From: xaedes Date: Thu, 1 Jun 2023 19:41:28 +0200 Subject: [PATCH] add ggml_opt_resume_g which accepts forward and backward cgraphs --- ggml.c | 11 +++++++++++ ggml.h | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/ggml.c b/ggml.c index bde5f9698..b16cd07a9 100644 --- a/ggml.c +++ b/ggml.c @@ -17457,6 +17457,17 @@ enum ggml_opt_result ggml_opt_resume( *gf = ggml_build_forward (f); *gb = ggml_build_backward(ctx, gf, true); + return ggml_opt_resume_g(ctx, opt, f, gf, gb); +} + +enum ggml_opt_result ggml_opt_resume_g( + struct ggml_context * ctx, + struct ggml_opt_context * opt, + struct ggml_tensor * f, + struct ggml_cgraph * gf, + struct ggml_cgraph * gb) { + + // build forward + backward compute graphs enum ggml_opt_result result = GGML_OPT_OK; switch (opt->params.type) { diff --git a/ggml.h b/ggml.h index a9750d89d..1e85b2fb1 100644 --- a/ggml.h +++ b/ggml.h @@ -1208,6 +1208,14 @@ extern "C" { struct ggml_opt_context * opt, struct ggml_tensor * f); + // continue optimizing the function defined by the tensor f + GGML_API enum ggml_opt_result ggml_opt_resume_g( + struct ggml_context * ctx, + struct ggml_opt_context * opt, + struct ggml_tensor * f, + struct ggml_cgraph * gf, + struct ggml_cgraph * gb); + // // quantization //