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

Function SelectGrad

tensorflow/cc/gradients/math_grad.cc:1191–1207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1189REGISTER_GRADIENT_OP("Cast", CastGrad);
1190
1191Status SelectGrad(const Scope& scope, const Operation& op,
1192 const std::vector<Output>& grad_inputs,
1193 std::vector<Output>* grad_outputs) {
1194 if (op.num_inputs() != 3) {
1195 return errors::InvalidArgument("Select requires 3 arguments");
1196 }
1197 if (grad_inputs.size() != 1) {
1198 return errors::InvalidArgument("Select grad requires 1 grad input");
1199 }
1200
1201 auto c = op.input(0);
1202 auto zeros = ZerosLike(scope, grad_inputs[0]);
1203 grad_outputs->push_back(NoGradient()); // Condition
1204 grad_outputs->push_back(Where3(scope, c, grad_inputs[0], zeros));
1205 grad_outputs->push_back(Where3(scope, c, zeros, grad_inputs[0]));
1206 return scope.status();
1207}
1208REGISTER_GRADIENT_OP("Select", SelectGrad);
1209
1210Status SelectV2Grad(const Scope& scope, const Operation& op,

Callers

nothing calls this directly

Calls 8

InvalidArgumentFunction · 0.85
NoGradientFunction · 0.85
ZerosLikeFunction · 0.50
num_inputsMethod · 0.45
sizeMethod · 0.45
inputMethod · 0.45
push_backMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected