powf

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

x

Atlas A2 training product/Atlas A2 inference product

x

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Obtains the input data x raised to the power of y.

Prototype

1
inline float powf(float x, float y)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

x

Input

Source operand, which is the base of the exponentiation computation.

y

Input

Source operand, which is the exponent of the exponentiation computation.

Returns

Result of x raised to the power of y.

  • If x^y exceeds the maximum range of float, the return value is inf.
  • If x is ±0 and y is an odd number less than 0, the return value is ±inf.
  • If x is ±0 and y is less than 0 and is not an odd number, the return value is inf.
  • If x is ±0 and y is an odd number greater than 0, the return value is ±0.
  • If x is ±0 and y is greater than 0 and is not an odd number, the return value is 0.
  • If x is –1 and y is ±inf, the return value is 1.
  • If x is 1 and y is any value (including nan), the return value is 1.
  • If y is ±0 and x is any value (including nan), the return value is 1.
  • If x is less than 0 and y is not an integer, the return value is nan.
  • If |x| < 1 and y is -inf, the return value is inf.
  • If |x| > 1 and y is -inf, the return value is 0.
  • If |x| < 1 and y is inf, the return value is 0.
  • If |x| > 1 and y is inf, the return value is inf.
  • If x is -inf and y is an odd number less than 0, the return value is -0.
  • If x is -inf and y is less than 0 and is not an odd number, the return value is 0.
  • If x is -inf and y is an odd number greater than 0, the return value is -inf.
  • If x is -inf and y is greater than 0 and is not an odd number, the return value is inf.
  • If x is inf and y is less than 0, the return value is 0.
  • If x is inf and y is greater than 0, the return value is inf.
  • In the following boundary scenarios, the return value is nan.
    • x is nan, and y is not 0.
    • y is nan, and x is not 1.
    • Both x and y are nan.

Restrictions

For SIMT programming, this API is not supported.

Header File to Be Included

To use this API, the simt_api/math_functions.h header file must be included.

1
#include "simt_api/math_functions.h"

Examples

For SIMD and SIMT programming:
1
2
3
4
5
__simt_vf__ __launch_bounds__(1024) inline void KernelPow(__gm__ float* dst, __gm__ float* x, __gm__ float* y)
{
    int idx = threadIdx.x + blockIdx.x * blockDim.x;
    dst[idx] = powf(x[idx], y[idx]);
}