MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / AddNGrad

Function AddNGrad

tensorflow/cc/gradients/math_grad.cc:490–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

488REGISTER_GRADIENT_OP("SquaredDifference", SquaredDifferenceGrad);
489
490Status AddNGrad(const Scope& scope, const Operation& op,
491 const std::vector<Output>& grad_inputs,
492 std::vector<Output>* grad_outputs) {
493 // AddN doesn't support broadcasting, so all the inputs must be the
494 // same shape.
495 // Note:
496 // dy/dx_k = d(x_1 + x_2 + ... + x_n)/dx_k = 1 for all x_k
497 // hence dx_k = dy for all x_k
498 // So the gradient for AddN just transfers the incoming gradient to
499 // all outgoing gradients.
500 auto incoming = Identity(scope, grad_inputs[0]);
501 for (int32 i = 0; i < op.num_inputs(); ++i) {
502 grad_outputs->push_back(incoming);
503 }
504 return scope.status();
505}
506REGISTER_GRADIENT_OP("AddN", AddNGrad);
507
508Status PowGrad(const Scope& scope, const Operation& op,

Callers

nothing calls this directly

Calls 4

IdentityFunction · 0.50
num_inputsMethod · 0.45
push_backMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected