| 473 | REGISTER_GRADIENT_OP("DivNoNan", DivNoNanGrad); |
| 474 | |
| 475 | Status SquaredDifferenceGrad(const Scope& scope, const Operation& op, |
| 476 | const std::vector<Output>& grad_inputs, |
| 477 | std::vector<Output>* grad_outputs) { |
| 478 | auto x_1 = ConjugateHelper(scope, op.input(0)); |
| 479 | auto x_2 = ConjugateHelper(scope, op.input(1)); |
| 480 | // y = (x_1 - x_2)^2 |
| 481 | // dy/dx_1 = 2 * (x_1 - x_2) |
| 482 | // dy/dx_2 = -2 * (x_1 - x_2) |
| 483 | auto two = Cast(scope, Const(scope, 2), grad_inputs[0].type()); |
| 484 | auto gx_1 = Mul(scope, grad_inputs[0], Mul(scope, two, Sub(scope, x_1, x_2))); |
| 485 | auto gx_2 = Neg(scope, gx_1); |
| 486 | return BinaryGradCommon(scope, op, grad_outputs, gx_1, gx_2); |
| 487 | } |
| 488 | REGISTER_GRADIENT_OP("SquaredDifference", SquaredDifferenceGrad); |
| 489 | |
| 490 | Status AddNGrad(const Scope& scope, const Operation& op, |
nothing calls this directly
no test coverage detected