Rate This Document
Findability
Accuracy
Completeness
Readability

vfloatcvtf16

Convert the float data type to FP16.

Interface Definition

C interface:

void vfloatcvtf16(const int len, const float *src, __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

src

Single-precision floating-point

Input vector src with length len.

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

Input

dst

FP16

Output vector dst with length len.

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

Output

Dependencies

C: "kvml.h"

Examples

C interface:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
    const int len = 8;
    float src[8] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f};
    __fp16 dst[8];

    vfloatcvtf16(len, src, dst);


    /** 
     *  Output dst: 
     *    1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000
     */