diff --git a/ggml/include/ggml.h b/ggml/include/ggml.h index 35f0c44ec..5cb49d0ee 100644 --- a/ggml/include/ggml.h +++ b/ggml/include/ggml.h @@ -2788,6 +2788,12 @@ extern "C" { struct ggml_cgraph * cgraph, struct ggml_tensor * tensor); + // add the tensor and its parents to the graph without marking them for compute + // the flag is set later, when the tensor is reached from a node that computes + GGML_API void ggml_build_forward_order( + struct ggml_cgraph * cgraph, + struct ggml_tensor * tensor); + GGML_API void ggml_build_backward_expand( struct ggml_context * ctx, // context for gradient computation struct ggml_cgraph * cgraph, diff --git a/ggml/src/ggml.c b/ggml/src/ggml.c index 59191c663..da7f3a5f2 100644 --- a/ggml/src/ggml.c +++ b/ggml/src/ggml.c @@ -7200,6 +7200,10 @@ void ggml_build_forward_expand(struct ggml_cgraph * cgraph, struct ggml_tensor * ggml_build_forward_impl(cgraph, tensor, true, true); } +void ggml_build_forward_order(struct ggml_cgraph * cgraph, struct ggml_tensor * tensor) { + ggml_build_forward_impl(cgraph, tensor, true, false); +} + void ggml_build_backward_expand( struct ggml_context * ctx, struct ggml_cgraph * cgraph,