| 606 | REGISTER_GRADIENT_OP("Complex", ComplexGrad); |
| 607 | |
| 608 | Status AngleGrad(const Scope& scope, const Operation& op, |
| 609 | const std::vector<Output>& grad_inputs, |
| 610 | std::vector<Output>* grad_outputs) { |
| 611 | // y = Angle(x) |
| 612 | // dx = -dy / (Im(x) + iRe(x)) = -dy * z |
| 613 | auto re = Real(scope, op.input(0)); |
| 614 | auto im = Imag(scope, op.input(0)); |
| 615 | auto z_inv = Reciprocal(scope, Complex(scope, im, re)); |
| 616 | auto zero = Cast(scope, Const(scope, 0), grad_inputs[0].type()); |
| 617 | auto grad = Complex(scope, grad_inputs[0], zero); |
| 618 | auto dx = Neg(scope, Mul(scope, grad, z_inv)); |
| 619 | grad_outputs->push_back(dx); |
| 620 | return scope.status(); |
| 621 | } |
| 622 | REGISTER_GRADIENT_OP("Angle", AngleGrad); |
| 623 | |
| 624 | Status ConjGrad(const Scope& scope, const Operation& op, |
nothing calls this directly
no test coverage detected