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

Function CastGrad

tensorflow/cc/gradients/math_grad.cc:1170–1188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1168}
1169
1170Status CastGrad(const Scope& scope, const Operation& op,
1171 const std::vector<Output>& grad_inputs,
1172 std::vector<Output>* grad_outputs) {
1173 if (op.num_inputs() != 1) {
1174 return errors::InvalidArgument("Cast requires 2 arguments");
1175 }
1176 if (grad_inputs.size() != 1) {
1177 return errors::InvalidArgument("Cast grad requires 1 grad input");
1178 }
1179
1180 auto src_type = op.input_type(0);
1181 auto dst_type = grad_inputs[0].type();
1182 if (IsFloatingPointDtype(src_type) && IsFloatingPointDtype(dst_type)) {
1183 grad_outputs->push_back(Cast(scope, grad_inputs[0], src_type));
1184 } else {
1185 grad_outputs->push_back(NoGradient());
1186 }
1187 return scope.status();
1188}
1189REGISTER_GRADIENT_OP("Cast", CastGrad);
1190
1191Status SelectGrad(const Scope& scope, const Operation& op,

Callers

nothing calls this directly

Calls 10

InvalidArgumentFunction · 0.85
IsFloatingPointDtypeFunction · 0.85
NoGradientFunction · 0.85
typeMethod · 0.65
CastFunction · 0.50
num_inputsMethod · 0.45
sizeMethod · 0.45
input_typeMethod · 0.45
push_backMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected