#include "bf16_utils.h"#include "ckernel_engine.h"#include <dlfcn.h>#include <math.h>#include <pthread.h>#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <string.h>Go to the source code of this file.
Macros | |
| #define | _GNU_SOURCE |
Typedefs | |
| typedef void(* | sgemm_fn) (const char *, const char *, const int *, const int *, const int *, const float *, const float *, const int *, const float *, const int *, const float *, float *, const int *) |
| typedef void(* | strsm_fn) (const char *, const char *, const char *, const char *, const int *, const int *, const float *, const float *, const int *, float *, const int *) |
| typedef void(* | vsexp_fn) (int, const float *, float *) |
Enumerations | |
| enum | { TEMPORAL = CHUNK * CHUNK , STATE = HEAD_WIDTH * HEAD_WIDTH } |
| enum | { CHUNK = 64 , HEAD_WIDTH = 128 , MATRIX = CHUNK * HEAD_WIDTH } |
| enum | chunk_profile { BF16_QK_BETA_INVERSE , FP32_QK_BETA_INVERSE , FP32_QK_BF16_BETA_SOLVE } |
Functions | |
| static void | apply_chunk (chunk_workspace *w, float *state, bool solve) |
| static float | bf16_round (float x) |
| static void | bind_math (void) |
| void | gated_deltanet_chunked_bf16_prefill_forward (const float *q, const float *k, const float *v, const float *packed_qkv, const float *g, const float *beta, const float *state_in, float *state_out, float *out, void *workspace, int rows, int heads, int groups, int width, float eps) |
| void | gated_deltanet_chunked_fp32_qk_beta_prefill_forward (const float *q, const float *k, const float *v, const float *g, const float *beta, const float *state_in, float *state_out, float *out, void *workspace, int rows, int heads, int groups, int width) |
| void | gated_deltanet_chunked_fp32_qk_triangular_prefill_forward (const float *q, const float *k, const float *v, const float *g, const float *beta, const float *state_in, float *state_out, float *out, void *workspace, int rows, int heads, int groups, int width) |
| static void | gated_deltanet_chunked_prefill (const float *q, const float *k, const float *v, const float *packed_qkv, const float *g, const float *beta, const float *state_in, float *state_out, float *out, void *workspace, int rows, int heads, int groups, int width, float eps, chunk_profile profile) |
| static void | matmul (int rows, int columns, int depth, const float *a, const float *b, int transpose_a, int transpose_b, float *c) |
| static float | reduce_previous_rows (const float *matrix, int row, int column) |
| static void | solve_lower_unit (const float *matrix, const float *rhs, float *result) |
| static void | temporal_transform (chunk_workspace *w, bool inverse) |
Variables | |
| static pthread_once_t | bind_once = PTHREAD_ONCE_INIT |
| static sgemm_fn | sgemm |
| static strsm_fn | strsm |
| static vsexp_fn | vsexp |
| #define _GNU_SOURCE |
Definition at line 6 of file deltanet_chunked_bf16.c.
| typedef void(* sgemm_fn) (const char *, const char *, const int *, const int *, const int *, const float *, const float *, const int *, const float *, const int *, const float *, float *, const int *) |
Definition at line 41 of file deltanet_chunked_bf16.c.
| typedef void(* strsm_fn) (const char *, const char *, const char *, const char *, const int *, const int *, const float *, const float *, const int *, float *, const int *) |
Definition at line 45 of file deltanet_chunked_bf16.c.
| typedef void(* vsexp_fn) (int, const float *, float *) |
Definition at line 48 of file deltanet_chunked_bf16.c.
| anonymous enum |
| anonymous enum |
| enum chunk_profile |
| Enumerator | |
|---|---|
| BF16_QK_BETA_INVERSE | |
| FP32_QK_BETA_INVERSE | |
| FP32_QK_BF16_BETA_SOLVE | |
Definition at line 55 of file deltanet_chunked_bf16.c.
|
static |
Definition at line 160 of file deltanet_chunked_bf16.c.
References CHUNK, HEAD_WIDTH, matmul(), MATRIX, solve_lower_unit(), STATE, TEMPORAL, and temporal_transform().
Referenced by gated_deltanet_chunked_prefill().
|
static |
Definition at line 85 of file deltanet_chunked_bf16.c.
References bf16_to_float(), and float_to_bf16().
Referenced by gated_deltanet_chunked_prefill().
|
static |
Definition at line 61 of file deltanet_chunked_bf16.c.
References RTLD_DEFAULT, sgemm, strsm, and vsexp.
Referenced by gated_deltanet_chunked_prefill().
| void gated_deltanet_chunked_bf16_prefill_forward | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | packed_qkv, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| float * | state_out, | ||
| float * | out, | ||
| void * | workspace, | ||
| int | rows, | ||
| int | heads, | ||
| int | groups, | ||
| int | width, | ||
| float | eps ) |
Definition at line 278 of file deltanet_chunked_bf16.c.
References BF16_QK_BETA_INVERSE, and gated_deltanet_chunked_prefill().
| void gated_deltanet_chunked_fp32_qk_beta_prefill_forward | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| float * | state_out, | ||
| float * | out, | ||
| void * | workspace, | ||
| int | rows, | ||
| int | heads, | ||
| int | groups, | ||
| int | width ) |
Definition at line 287 of file deltanet_chunked_bf16.c.
References FP32_QK_BETA_INVERSE, and gated_deltanet_chunked_prefill().
| void gated_deltanet_chunked_fp32_qk_triangular_prefill_forward | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| float * | state_out, | ||
| float * | out, | ||
| void * | workspace, | ||
| int | rows, | ||
| int | heads, | ||
| int | groups, | ||
| int | width ) |
Definition at line 296 of file deltanet_chunked_bf16.c.
References FP32_QK_BF16_BETA_SOLVE, and gated_deltanet_chunked_prefill().
|
static |
Definition at line 193 of file deltanet_chunked_bf16.c.
References apply_chunk(), BF16_QK_BETA_INVERSE, bf16_round(), bind_math(), bind_once, CHUNK, FP32_QK_BETA_INVERSE, FP32_QK_BF16_BETA_SOLVE, HEAD_WIDTH, recurrent_qk_l2_norm_pytorch_bf16_storage(), sgemm, start, STATE, strsm, token, valid(), and vsexp.
Referenced by gated_deltanet_chunked_bf16_prefill_forward(), gated_deltanet_chunked_fp32_qk_beta_prefill_forward(), and gated_deltanet_chunked_fp32_qk_triangular_prefill_forward().
|
static |
Definition at line 72 of file deltanet_chunked_bf16.c.
References sgemm.
Referenced by apply_chunk(), and temporal_transform().
|
static |
Definition at line 90 of file deltanet_chunked_bf16.c.
References CHUNK.
Referenced by temporal_transform().
|
static |
Definition at line 149 of file deltanet_chunked_bf16.c.
References CHUNK, HEAD_WIDTH, MATRIX, and strsm.
Referenced by apply_chunk().
|
static |
Definition at line 116 of file deltanet_chunked_bf16.c.
References CHUNK, HEAD_WIDTH, matmul(), reduce_previous_rows(), TEMPORAL, and vsexp.
Referenced by apply_chunk().
|
static |
Definition at line 50 of file deltanet_chunked_bf16.c.
Referenced by gated_deltanet_chunked_prefill().
|
static |
Definition at line 51 of file deltanet_chunked_bf16.c.
Referenced by attention_impl(), bind_math(), bind_sgemm(), ck_linear_rows_sgemm_checked(), gated_deltanet_chunked_prefill(), and matmul().
|
static |
Definition at line 52 of file deltanet_chunked_bf16.c.
Referenced by bind_math(), gated_deltanet_chunked_prefill(), and solve_lower_unit().
|
static |
Definition at line 53 of file deltanet_chunked_bf16.c.
Referenced by bind_math(), gated_deltanet_chunked_prefill(), and temporal_transform().