Rate This Document
Findability
Accuracy
Completeness
Readability

v?fmax

Return the larger one of two input vectors.

Interface Definition

C interface:

void vsfmax(const int len, const float* src1, const float* src2, float* dst);

void vdfmax(const int len, const double* src1, const double* src2, double* dst);

void vhfmax(const int len, const __fp16 *src1, const __fp16 *src2, __fp16 *dst);

Parameters

Parameter

Type

Description

Input/Output

len

Integer

Number of elements in the input vector.

If len ≤ 0, an invalid parameter error is reported and the function returns.

Input

src1

  • Single-precision floating-point type for vsfmax
  • Double-precision floating-point type for vdfmax
  • Half-precision floating-point type for vhfmax

Input vector src1 with length len.

If the pointer is null, a null pointer error is reported and the function returns.

Input

src2

  • Single-precision floating-point type for vsfmax
  • Double-precision floating-point type for vdfmax
  • Half-precision floating-point type for vhfmax

Input vector src2 with length len.

If the pointer is null, a null pointer error is reported and the function returns.

Input

dst

  • Single-precision floating-point type for vsfmax
  • Double-precision floating-point type for vdfmax
  • Half-precision floating-point type for vhfmax

Output vector dst with length len.

If the pointer is null, a null pointer error is reported and the function returns.

Output

Return Value

  • If x > y, x is returned. Otherwise, y is returned.
  • For special values, see the following table.

    Input Value 1 (src1)

    Input Value 2 (src2)

    Output Value (dst)

    any

    qnan

    x

    qnan

    any

    y

    any

    snan

    nan

    snan

    any

    nan

Dependencies

C: "kvml.h"

Examples

C interface:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
    int i, len = 8; 
    float src1[8] = {-1.5f, -0.0f, 0.0f, 1.0f, 1.5f, -INFINITY, INFINITY, NAN};
    float src2[8] = {-1.1f, 0.0f, +0.0f, -1.0f, -1.5f, +INFINITY, -INFINITY, -NAN}; 
    float* dst = (float*)malloc(sizeof(float) * len); 
    if (dst == NULL) { 
        printf("Malloc Failed!\n"); 
        return 0;
    }
    vsfmax(len, src1, src2, dst);

    /** 
     *  Output dst: 
     *     -1.100000 0.000000 0.000000 1.000000 1.500000 inf inf nan
     */