The following functions are available globally.

  • Declaration

    @_semantics("typechecker.gradient(of:﹚")
    public func gradient<T, Result>(of function: (T) -> Result) -> (T) -> T
      where T : VectorNumeric, Result : VectorNumeric
  • Declaration

    @_semantics("typechecker.gradient(of:﹚")
    public func gradient<T, U, Result>(
      of function: (T, U) -> Result
    ) -> (T, U) -> (T, U)
      where T : VectorNumeric, U : VectorNumeric, Result : VectorNumeric,
            T.ScalarElement : FloatingPoint, U.ScalarElement : FloatingPoint
  • Declaration

    @_semantics("typechecker.gradient(of:﹚")
    public func gradient<T, U, V, Result>(
      of function: (T, U, V) -> Result
    ) -> (T, U, V) -> (T, U, V)
      where T : VectorNumeric, U : VectorNumeric, V : VectorNumeric,
            Result : VectorNumeric, T.ScalarElement : FloatingPoint,
            U.ScalarElement : FloatingPoint, V.ScalarElement : FloatingPoint
  • Declaration

    @_semantics("typechecker.gradient(of:﹚")
    public func gradient<T, U, V, W, Result>(
      of function: (T, U, V, W) -> Result
    ) -> (T, U, V, W) -> (T, U, V, W)
      where T : VectorNumeric, U : VectorNumeric, V : VectorNumeric,
            W : VectorNumeric, Result : VectorNumeric, T.ScalarElement : FloatingPoint,
            U.ScalarElement : FloatingPoint, V.ScalarElement : FloatingPoint,
            W.ScalarElement : FloatingPoint
  • Declaration

    @_semantics("typechecker.valueAndGradient(of:﹚")
    public func valueAndGradient<T, Result>(
      of function: (T) -> Result
    ) -> (T) -> (value: Result, gradient: T)
      where T : VectorNumeric, Result : VectorNumeric, T.ScalarElement : FloatingPoint
  • Declaration

    @_semantics("typechecker.valueAndGradient(of:﹚")
    public func valueAndGradient<T, U, Result>(
      of function: (T, U) -> Result
    ) -> (T, U) -> (value: Result, gradient: (T, U))
      where T : VectorNumeric, U : VectorNumeric, Result : VectorNumeric,
            T.ScalarElement : FloatingPoint, U.ScalarElement : FloatingPoint
  • Declaration

    @_semantics("typechecker.valueAndGradient(of:﹚")
    public func valueAndGradient<T, U, V, Result>(
      of function: (T, U, V) -> Result
    ) -> (T, U, V) -> (value: Result, gradient: (T, U, V))
      where T : VectorNumeric, U : VectorNumeric, V : VectorNumeric,
            Result : VectorNumeric, T.ScalarElement : FloatingPoint,
            U.ScalarElement : FloatingPoint, V.ScalarElement : FloatingPoint
  • Declaration

    @_semantics("typechecker.valueAndGradient(of:﹚")
    public func valueAndGradient<T, U, V, W, Result>(
      of function: (T, U, V, W) -> Result
    ) -> (T, U, V, W) -> (value: Result, gradient: (T, U, V, W))
      where T : VectorNumeric, U : VectorNumeric, V : VectorNumeric,
            W : VectorNumeric, Result : VectorNumeric, T.ScalarElement : FloatingPoint,
            U.ScalarElement : FloatingPoint, V.ScalarElement : FloatingPoint,
            W.ScalarElement : FloatingPoint
  • Computes sigmoid of the specified tensor element-wise. Specifically, computes 1 / (1 + exp(-x)).

    Declaration

    public func sigmoid<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes relu of the specified tensor element-wise. Specifically, computes max(0, x).

    Declaration

    public func relu<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes the softmax of the specified tensor element-wise. Specifically, computes exp(x) / exp(x).sum().

    Declaration

    public func softmax<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes the softmax of the specified tensor along the specified axis. Specifically, computes exp(x) / exp(x).sum(alongAxes: axis).

    Declaration

    public func softmax<T : BinaryFloatingPoint>(
      _ x: Tensor<T>, alongAxis axis: Int32
    ) -> Tensor<T>
  • Performs matrix multiplication with another tensor and produces the result.

    Declaration

    public func matmul<Scalar : Numeric>(
      _ left: Tensor<Scalar>, _ right: Tensor<Scalar>
    ) -> Tensor<Scalar>
  • Computes the absolute value of the specified tensor element-wise.

    Declaration

    public func abs<T>(_ x: Tensor<T>) -> Tensor<T> where T : SignedNumeric, T : AccelerableByTensorFlow
  • Computes the natural logarithm of the specified tensor element-wise.

    Declaration

    public func log<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes sin of the specified tensor element-wise.

    Declaration

    public func sin<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes cos of the specified tensor element-wise.

    Declaration

    public func cos<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes tan of the specified tensor element-wise.

    Declaration

    public func tan<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes sinh of the specified tensor element-wise.

    Declaration

    public func sinh<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes cosh of the specified tensor element-wise.

    Declaration

    public func cosh<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes tanh of the specified tensor element-wise.

    Declaration

    public func tanh<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes the square root of the specified tensor element-wise.

    Declaration

    public func sqrt<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes the inverse square root of the specified tensor element-wise.

    Declaration

    public func rsqrt<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes exp of the specified tensor element-wise.

    Declaration

    public func exp<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow
  • Computes the power of the first tensor to the second tensor.

    Declaration

    public func pow<T>(_ lhs: Tensor<T>, _ rhs: Tensor<T>) -> Tensor<T>
      where T : BinaryFloatingPoint
  • Computes the power of the scalar to the tensor, broadcasting the scalar.

    Declaration

    public func pow<T>(_ lhs: T, _ rhs: Tensor<T>) -> Tensor<T>
      where T : BinaryFloatingPoint
  • Computes the power of the tensor to the scalar, broadcasting the scalar.

    Declaration

    public func pow<T>(_ lhs: Tensor<T>, _ rhs: T) -> Tensor<T>
      where T : BinaryFloatingPoint
  • Computes the element-wise maximum of two tensors.

    Note

    max supports broadcasting.

    Declaration

    public func max<T>(_ lhs: Tensor<T>, _ rhs: Tensor<T>) -> Tensor<T>
      where T : Numeric & Comparable
  • Computes the element-wise maximum of the scalar and the tensor, broadcasting the scalar.

    Declaration

    public func max<T>(_ lhs: T, _ rhs: Tensor<T>) -> Tensor<T>
      where T : Numeric & Comparable
  • Computes the element-wise maximum of the scalar and the tensor, broadcasting the scalar.

    Declaration

    public func max<T>(_ lhs: Tensor<T>, _ rhs: T) -> Tensor<T>
      where T : Numeric & Comparable
  • Computes the element-wise minimum of two tensors.

    Note

    min supports broadcasting.

    Declaration

    public func min<T>(_ lhs: Tensor<T>, _ rhs: Tensor<T>) -> Tensor<T>
      where T : Numeric & Comparable
  • Computes the element-wise minimum of the scalar and the tensor, broadcasting the scalar.

    Declaration

    public func min<T>(_ lhs: T, _ rhs: Tensor<T>) -> Tensor<T>
      where T : Numeric & Comparable
  • Computes the element-wise minimum of the scalar and the tensor, broadcasting the scalar.

    Declaration

    public func min<T>(_ lhs: Tensor<T>, _ rhs: T) -> Tensor<T>
      where T : Numeric & Comparable
  • Computes the log-softmax of the specified tensor element-wise.

    Declaration

    public func logSoftmax<T>(_ x: Tensor<T>) -> Tensor<T> where T : BinaryFloatingPoint, T : AccelerableByTensorFlow