ggml_graph_reset: Reset Graph (for backpropagation)

View source: R/graph.R

ggml_graph_resetR Documentation

Reset Graph (for backpropagation)

Description

Zeroes every gradient in the graph and seeds the loss node's own gradient with 1 – the value the chain rule starts from. Call this after ggml_build_backward_expand and before ggml_graph_compute: without it every gradient computes as zero, since the backward pass multiplies through a seed that was never set.

Usage

ggml_graph_reset(graph)

Arguments

graph

Graph object with gradients allocated

Details

Requires a graph built by ggml_build_forward_expand_grads; an inference-only graph has no gradients to reset and is rejected.

Value

No return value, called for side effects

See Also

ggml_build_backward_expand, ggml_build_forward_expand_grads


ggmlR documentation built on Oct. 23, 2026, 1:07 a.m.