| 361 | REGISTER_GRADIENT_OP("Tan", TanGrad); |
| 362 | |
| 363 | Status AtanGrad(const Scope& scope, const Operation& op, |
| 364 | const std::vector<Output>& grad_inputs, |
| 365 | std::vector<Output>* grad_outputs) { |
| 366 | // y = arctan(x) |
| 367 | // dy/dx = 1 / (1 + x^2) |
| 368 | // dx = dy * (1 / (1 + x^2) |
| 369 | auto one = Cast(scope, Const(scope, 1.0), op.input(0).type()); |
| 370 | auto dydx = Reciprocal(scope, Add(scope, one, Square(scope, op.input(0)))); |
| 371 | auto dx = Mul(scope, grad_inputs[0], dydx); |
| 372 | grad_outputs->push_back(dx); |
| 373 | return scope.status(); |
| 374 | } |
| 375 | REGISTER_GRADIENT_OP("Atan", AtanGrad); |
| 376 | |
| 377 | // BinaryGradCommon handles the setup for binary ops that broadcast |