rnormf

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 reciprocal of the square root of the sum of squares of the first n elements in the input data a (a[0]2 + a[1]2 + ... + a[n-1]2).

Prototype

1
inline float rnormf(int n, float* a)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

n

Input

Source operand. Number of consecutive elements for computation in the input data a.

a

Input

Source operand. Unified Buffer, Global Memory, or stack address.

Returns

Reciprocal of the square root of a[0]2 + a[1]2 + ... + a[n-1]2.

  • If the square root of a[0]2 + a[1]2 + ... + a[n-1]2 exceeds the maximum range of float, the return value is 0.
  • If the reciprocal of the square root of a[0]2 + a[1]2 + ... + a[n-1]2 exceeds the maximum range of float, the return value is inf.
  • If a[0], a[1], ..., and a[n-1] are all 0, the return value is inf.
  • If any or more of a[0], a[1], ..., and a[n-1] are ±inf, the return value is 0.
  • If any or more of a[0], a[1], ..., and a[n-1] are nan and not ±inf, the return value is nan.
  • If n is less than 1, the reciprocal of the absolute value of a[0] is returned. If a[0] is 0, the return value is inf.

Restrictions

  • The length of the input data a must be greater than or equal to that of the parameter n.
  • If n is too large, the API performance cannot be guaranteed.
  • 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:

In SIMD and SIMT programming, the address space qualifier must be explicitly used to indicate the address space. __gm__ indicates the Global Memory memory space, and __ubuf__ indicates the Unified Buffer memory space. No address space qualifier is required for the stack space.
1
2
3
4
5
__simt_vf__ __launch_bounds__(1024) inline void KernelRnorm(__gm__ float* dst, __gm__ int* n, __gm__ float* a)
{
    int idx = threadIdx.x + blockIdx.x * blockDim.x;
    dst[idx] = rnormf(n[idx], a);
}