fp16.h file
IEEE binary16 storage and vm_.
Not a vm_ width.
Compiled into the library only when VECMAT_ENABLE_FP16=ON. Not part of vecmat.h. Symbols are not in abi.h.
Classes
- struct vm_vec4_fp16
- struct vm_mat4_fp16
Typedefs
- using vm_fp16_t = uint16_t
- IEEE binary16 bits.
- using vm_vec4_fp16 = struct vm_vec4_fp16
- using vm_mat4_fp16 = struct vm_mat4_fp16
- using vm_fp16_gemm_fn = void(*)(float*c, int ldc, const vm_fp16_t*a, int lda, const vm_fp16_t*b, int ldb, int m, int n, int k, float alpha, float beta)
- Row-major
C = alpha * A * B + beta * Cwith fp16 inputs and an f32 accumulator.
Functions
-
auto vm_fp16_from_f32(float x) -> vm_
fp16_ t - Round a binary32 value to binary16, ties to even.
-
auto vm_f32_from_fp16(vm_
fp16_ t h) -> float - Expand binary16 bits to binary32.
- void vm_fp16_init(void)
- Install the scalar GEMM, then run
vm_.fp16_ modules_ register() -
void vm_fp16_set_gemm(vm_
fp16_ gemm_ fn fn, const char* note) - Replace the GEMM slot.
- auto vm_fp16_note(void) -> const char*
fp16=scalaruntil a module overrides the slot.-
void vm_gemm_fp16f32(float* c,
int ldc,
const vm_
fp16_ t* a, int lda, const vm_ fp16_ t* b, int ldb, int m, int n, int k, float alpha, float beta) - See
vm_.fp16_ gemm_ fn
Typedef documentation
typedef void(*vm_fp16_gemm_fn)(float*c, int ldc, const vm_fp16_t*a, int lda, const vm_fp16_t*b, int ldb, int m, int n, int k, float alpha, float beta)
Row-major C = alpha * A * B + beta * C with fp16 inputs and an f32 accumulator.
No transpose and no layout flag. This is not vm_ (that default is column-major and takes transpose flags). lda / ldb are in vm_ elements; ldc is in float elements.
Function documentation
vm_ fp16_ t vm_fp16_from_f32(float x)
Round a binary32 value to binary16, ties to even.
Inf maps to inf. Every NaN maps to the canonical quiet NaN 0x7e00. Subnormals are kept.
void vm_fp16_init(void)
Install the scalar GEMM, then run vm_.
Call before the first vm_ if a module must override the slot. A second call does not replace an already installed slot.
void vm_fp16_set_gemm(vm_ fp16_ gemm_ fn fn,
const char* note)
Replace the GEMM slot.
fn == NULL is ignored.
note is printed by the caller via vm_. It is not vm_.
void vm_gemm_fp16f32(float* c,
int ldc,
const vm_ fp16_ t* a,
int lda,
const vm_ fp16_ t* b,
int ldb,
int m,
int n,
int k,
float alpha,
float beta)
See vm_.
Dispatches the installed slot.