| 488 | REGISTER_GRADIENT_OP("SquaredDifference", SquaredDifferenceGrad); |
| 489 | |
| 490 | Status 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 | } |
| 506 | REGISTER_GRADIENT_OP("AddN", AddNGrad); |
| 507 | |
| 508 | Status PowGrad(const Scope& scope, const Operation& op, |
nothing calls this directly
no test coverage detected