BinaryGradCommon handles the setup for binary ops that broadcast their inputs.
| 377 | // BinaryGradCommon handles the setup for binary ops that broadcast |
| 378 | // their inputs. |
| 379 | Status BinaryGradCommon(const Scope& scope, const Operation& op, |
| 380 | std::vector<Output>* grad_outputs, const Output& gx_1, |
| 381 | const Output& gx_2) { |
| 382 | auto sx_1 = Shape(scope, op.input(0)); |
| 383 | auto sx_2 = Shape(scope, op.input(1)); |
| 384 | auto rx = internal::BroadcastGradientArgs(scope, sx_1, sx_2); |
| 385 | auto dx_1 = Reshape(scope, Sum(scope, gx_1, rx.r0), sx_1); |
| 386 | auto dx_2 = Reshape(scope, Sum(scope, gx_2, rx.r1), sx_2); |
| 387 | grad_outputs->push_back(dx_1); |
| 388 | grad_outputs->push_back(dx_2); |
| 389 | return scope.status(); |
| 390 | } |
| 391 | |
| 392 | Status AddGrad(const Scope& scope, const Operation& op, |
| 393 | const std::vector<Output>& grad_inputs, |
no test coverage detected