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

Function BinaryGradCommon

tensorflow/cc/gradients/math_grad.cc:379–390  ·  view source on GitHub ↗

BinaryGradCommon handles the setup for binary ops that broadcast their inputs.

Source from the content-addressed store, hash-verified

377// BinaryGradCommon handles the setup for binary ops that broadcast
378// their inputs.
379Status 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
392Status AddGrad(const Scope& scope, const Operation& op,
393 const std::vector<Output>& grad_inputs,

Callers 10

AddGradFunction · 0.85
SubGradFunction · 0.85
MulGradFunction · 0.85
DivGradFunction · 0.85
RealDivGradFunction · 0.85
DivNoNanGradFunction · 0.85
SquaredDifferenceGradFunction · 0.85
PowGradFunction · 0.85
MaximumMinimumGradCommonFunction · 0.85
ComplexGradFunction · 0.85

Calls 7

BroadcastGradientArgsFunction · 0.85
ShapeClass · 0.50
ReshapeFunction · 0.50
SumClass · 0.50
inputMethod · 0.45
push_backMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected