Skip to content

Need help to understand the (backward) computational graph #663

Answered by ggerganov
bssrdf asked this question in Q&A
Discussion options

You must be logged in to vote

node_5 and node_4 correspond to the 2 ggml_mul ops in the backward pass for b:

struct ggml_tensor * b = ggml_mul(ctx0, x, x);

ggml/src/ggml.c

Lines 14929 to 14945 in 6474641

case GGML_OP_MUL:
{
if (src0->grad) {
src0->grad =
ggml_add_or_set(ctx,
src0->grad,
ggml_mul(ctx, src1, tensor->grad),
zero_table);
}
if (src1->grad) {
src1->grad =
ggml_add_or_set(ctx,
src1->grad,
ggml_mul(ctx, src0, tensor->grad),
zero_table);
}
} break;

To try to make it more clear, you can apply this patch and rerun the test:

diff --git a/src/ggml.c b/src/ggml.c

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bssrdf
Comment options

Answer selected by bssrdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants