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

Function AngleGrad

tensorflow/cc/gradients/math_grad.cc:608–621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606REGISTER_GRADIENT_OP("Complex", ComplexGrad);
607
608Status 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}
622REGISTER_GRADIENT_OP("Angle", AngleGrad);
623
624Status ConjGrad(const Scope& scope, const Operation& op,

Callers

nothing calls this directly

Calls 12

typeMethod · 0.65
RealFunction · 0.50
ImagFunction · 0.50
ReciprocalFunction · 0.50
ComplexFunction · 0.50
CastFunction · 0.50
ConstFunction · 0.50
NegFunction · 0.50
MulFunction · 0.50
inputMethod · 0.45
push_backMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected