1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef TENSORFLOW_COMPILER_XLA_CLIENT_LIB_MATH_H_ 17 #define TENSORFLOW_COMPILER_XLA_CLIENT_LIB_MATH_H_ 18 19 #include "tensorflow/compiler/xla/client/xla_builder.h" 20 21 namespace xla { 22 23 // Determines whether operand is +/-inf or nan. 24 // 25 // Raises an error if called on integral or complex values. 26 XlaOp IsPosInf(XlaOp operand); 27 XlaOp IsNegInf(XlaOp operand); 28 XlaOp IsInf(XlaOp operand); 29 XlaOp IsNan(XlaOp operand); 30 31 // Determines whether operand is equal to -0. 32 // 33 // Raises an error for integral or complex values. 34 XlaOp IsNegZero(XlaOp operand); 35 36 // Returns the next number after 'from' in the direction of 'to' the same way 37 // std::nextafter(from, to) would. 38 XlaOp NextAfter(XlaOp from, XlaOp to); 39 40 // Computes the square of 'operand'. 41 XlaOp Square(XlaOp operand); 42 43 // Computes the reciprocal of 'operand'. 44 XlaOp Reciprocal(XlaOp operand); 45 46 // Computes an approximation of the error function complement (1 - erf(x)). 47 XlaOp Erfc(XlaOp x); 48 49 // Computes an approximation of the error function. 50 XlaOp Erf(XlaOp x); 51 52 // Computes an approximation of the inverse of the error function. 53 XlaOp ErfInv(XlaOp x); 54 55 // Computes an approximation of the lgamma function. 56 XlaOp Lgamma(XlaOp input); 57 58 // Computes an approximation of the digamma function. 59 XlaOp Digamma(XlaOp input); 60 61 // Computes an approximation of the incomplete gamma function. 62 XlaOp Igamma(XlaOp a, XlaOp x); 63 64 // Computes an approximation of the derivative of the incomplete gamma function 65 // with respect to a. 66 XlaOp IgammaGradA(XlaOp a, XlaOp x); 67 68 // Computes an approximation of the derivative of a sample `x` from a `Gamma(a, 69 // 1)` distribution with respect to a. 70 XlaOp RandomGammaGrad(XlaOp a, XlaOp x); 71 72 // Computes an approximation of the complementary incomplete gamma function. 73 XlaOp Igammac(XlaOp a, XlaOp x); 74 75 // Computes the Polygamma of two arguments. 76 XlaOp Polygamma(XlaOp n, XlaOp x); 77 78 // Computes the Riemann zeta function of two arguments. 79 XlaOp Zeta(XlaOp x, XlaOp q); 80 81 // Rounds the given number to even when the number is equidistant between two 82 // integers. 83 XlaOp RoundToEven(XlaOp x); 84 85 // Trigonometric functions 86 87 // Computes the arc cosine of 'x'. 88 XlaOp Acos(XlaOp x); 89 90 // Computes the arc sine of 'x'. 91 XlaOp Asin(XlaOp x); 92 93 // Computes the arc tangent of 'x'. 94 XlaOp Atan(XlaOp x); 95 96 // Computes the tangent of 'x'. 97 XlaOp Tan(XlaOp x); 98 99 // Hyperbolic trigonometric functions 100 101 // Computes the inverse hyperbolic cosine of 'x'. 102 XlaOp Acosh(XlaOp x); 103 104 // Computes the inverse hyperbolic sine of 'x'. 105 XlaOp Asinh(XlaOp x); 106 107 // Computes the inverse hyperbolic tangent of 'x'. 108 XlaOp Atanh(XlaOp x); 109 110 // Computes the hyperbolic cosine of 'x'. 111 XlaOp Cosh(XlaOp x); 112 113 // Computes the hyperbolic sine of 'x'. 114 XlaOp Sinh(XlaOp x); 115 116 // Applies a complex conjugation operation if 'a' is complex and 'conjugate' 117 // is true, otherwise returns its argument. 118 xla::XlaOp MaybeConjugate(xla::XlaOp x, bool conjugate); 119 120 // Computes the Modified Bessel function of the first kind of the zeroth order 121 // at x. 122 XlaOp BesselI0e(XlaOp x); 123 124 // Computes the Modified Bessel function of the first kind of the first order 125 // at x. 126 XlaOp BesselI1e(XlaOp x); 127 128 // Computes the Regularized Incomplete Beta function. 129 XlaOp RegularizedIncompleteBeta(XlaOp a, XlaOp b, XlaOp x); 130 131 } // namespace xla 132 133 #endif // TENSORFLOW_COMPILER_XLA_CLIENT_LIB_MATH_H_ 134