| 85 | REGISTER_GRADIENT_OP("Reciprocal", InvGrad); |
| 86 | |
| 87 | Status SquareGrad(const Scope& scope, const Operation& op, |
| 88 | const std::vector<Output>& grad_inputs, |
| 89 | std::vector<Output>* grad_outputs) { |
| 90 | // dy/dx = (2 * x) |
| 91 | auto two = Cast(scope, Const(scope, 2), op.input(0).type()); |
| 92 | auto dydx = Mul(scope, two, op.input(0)); |
| 93 | // grad(x) = grad(y) * conj(dy/dx) |
| 94 | grad_outputs->push_back( |
| 95 | Mul(scope, grad_inputs[0], ConjugateHelper(scope, dydx))); |
| 96 | return scope.status(); |
| 97 | } |
| 98 | REGISTER_GRADIENT_OP("Square", SquareGrad); |
| 99 | |
| 100 | Status SqrtGrad(const Scope& scope, const Operation& op, |