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

Function BroadcastToGrad

tensorflow/cc/gradients/array_grad.cc:562–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560REGISTER_GRADIENT_OP("ConcatV2", ConcatV2Grad);
561
562Status BroadcastToGrad(const Scope& scope, const Operation& op,
563 const std::vector<Output>& grad_inputs,
564 std::vector<Output>* grad_outputs) {
565 if (grad_inputs.size() != 1) {
566 return errors::InvalidArgument("BroadcastTo grad should have 1 grad input");
567 }
568 if (op.num_inputs() != 2) {
569 return errors::InvalidArgument("BroadcastTo requires 2 inputs");
570 }
571
572 auto x_shape = Shape(scope, op.input(0));
573 auto args = internal::BroadcastGradientArgs(scope, x_shape, op.input(1));
574 auto sum_gx = Sum(scope, grad_inputs[0], args.r0);
575 grad_outputs->push_back(Reshape(scope, sum_gx, x_shape));
576 grad_outputs->push_back(NoGradient());
577 return scope.status();
578}
579
580REGISTER_GRADIENT_OP("BroadcastTo", BroadcastToGrad);
581

Callers

nothing calls this directly

Calls 11

InvalidArgumentFunction · 0.85
BroadcastGradientArgsFunction · 0.85
NoGradientFunction · 0.85
ShapeClass · 0.50
SumClass · 0.50
ReshapeFunction · 0.50
sizeMethod · 0.45
num_inputsMethod · 0.45
inputMethod · 0.45
push_backMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected