Read the equation
The output is the sum of two inputs. Each input has local derivative one, so the backward pass adds the incoming output gradient to both input gradients. Accumulation is necessary when a variable contributes along multiple graph paths.
Terms & definitions
| Term | Meaning in this source |
|---|---|
| x | First input |
| y | Second input |
| z | Sum |
How it works
Read the definition from its right-hand expression to the quantity on the left. Its surrounding source records the intended input, state, or parameter context. Where the source leaves an operation unspecified, this page preserves that gap.
Assumptions & limits
Source recovery establishes that the expression appears in this record. Its mathematical validity, implementation behavior, and interpretation must be assessed separately. See the linked source and research notes for the checks available for this version.
Original context
Read the surrounding source passage
namespace ops {
// Create leaf node (input variable)
inline GradNodePtr variable(double value, bool requires_grad = true) {
return std::make_shared<GradNode>(value, requires_grad);
}
// Addition: z = x + y, dz/dx = 1, dz/dy = 1
inline GradNodePtr add(GradNodePtr x, GradNodePtr y, TapeRecorder& tape) {
auto z = std::make_shared<GradNode>(x->value + y->value);
z->inputs = {x, y};
z->backward_fn = [x, y, z]() {
x->grad += z->grad;
y->grad += z->grad;
};
return tape.record(z);
}
Exact original notation
Addition: z = x + y, dz/dx = 1, dz/dy = 1