#include "bf16_utils.h"#include "ckernel_engine.h"#include <dlfcn.h>#include <math.h>#include <pthread.h>#include <stdio.h>#include <stdlib.h>Go to the source code of this file.
Macros | |
| #define | _GNU_SOURCE |
Typedefs | |
| typedef float(* | ck_recurrent_libm_f32_fn) (float) |
Functions | |
| static void | ck_bind_recurrent_llama_libm (void) |
| void | recurrent_dt_gate_backward (const float *d_gate, const float *alpha, const float *dt_bias, const float *a, float *d_alpha, float *d_dt_bias, float *d_a, int rows, int dim) |
| void | recurrent_dt_gate_expanded_forward (const float *alpha, const float *dt_bias, const float *a, float *gate, int rows, int num_heads, int state_dim) |
| void | recurrent_dt_gate_forward (const float *alpha, const float *dt_bias, const float *a, float *gate, int rows, int num_heads, int state_dim) |
| void | recurrent_dt_gate_forward_pytorch_fp32 (const float *alpha, const float *dt_bias, const float *a, float *gate, int rows, int num_heads, int state_dim) |
| static float | recurrent_sigmoid (float x) |
| void | recurrent_sigmoid_forward_ggml (const float *x, float *out, int rows, int dim) |
| void | recurrent_sigmoid_forward_pytorch_bf16_input_fp32_output (const float *x, float *out, int rows, int dim) |
| void | recurrent_silu_backward (const float *d_out, const float *x, float *d_x, int rows, int dim) |
| void | recurrent_silu_forward (const float *x, float *out, int rows, int dim) |
| void | recurrent_silu_forward_ggml (const float *x, float *out, int rows, int dim) |
| void | recurrent_silu_forward_pytorch_bf16_input_fp32_output (const float *x, float *out, int rows, int dim) |
| void | recurrent_silu_forward_pytorch_bf16_storage (const float *x, float *out, int rows, int dim) |
| static float | recurrent_softplus (float x) |
Variables | |
| static void * | ck_recurrent_libm_handle = NULL |
| static pthread_once_t | ck_recurrent_libm_once = PTHREAD_ONCE_INIT |
| static ck_recurrent_libm_f32_fn | ck_recurrent_llama_expf = NULL |
| static ck_recurrent_libm_f32_fn | ck_recurrent_llama_logf = NULL |
| static ck_recurrent_libm_f32_fn | ck_recurrent_pytorch_log1pf = NULL |
| #define _GNU_SOURCE |
Definition at line 2 of file recurrent_gate_kernels.c.
| typedef float(* ck_recurrent_libm_f32_fn) (float) |
Definition at line 17 of file recurrent_gate_kernels.c.
|
static |
Definition at line 24 of file recurrent_gate_kernels.c.
References ck_recurrent_libm_handle, ck_recurrent_llama_expf, ck_recurrent_llama_logf, and ck_recurrent_pytorch_log1pf.
Referenced by recurrent_dt_gate_forward_pytorch_fp32(), and recurrent_softplus().
| void recurrent_dt_gate_backward | ( | const float * | d_gate, |
| const float * | alpha, | ||
| const float * | dt_bias, | ||
| const float * | a, | ||
| float * | d_alpha, | ||
| float * | d_dt_bias, | ||
| float * | d_a, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 104 of file recurrent_gate_kernels.c.
References recurrent_sigmoid(), and recurrent_softplus().
| void recurrent_dt_gate_expanded_forward | ( | const float * | alpha, |
| const float * | dt_bias, | ||
| const float * | a, | ||
| float * | gate, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | state_dim | ||
| ) |
Definition at line 83 of file recurrent_gate_kernels.c.
References recurrent_softplus().
| void recurrent_dt_gate_forward | ( | const float * | alpha, |
| const float * | dt_bias, | ||
| const float * | a, | ||
| float * | gate, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | state_dim | ||
| ) |
Definition at line 65 of file recurrent_gate_kernels.c.
References recurrent_softplus().
Referenced by ck_test_recurrent_dt_gate().
| void recurrent_dt_gate_forward_pytorch_fp32 | ( | const float * | alpha, |
| const float * | dt_bias, | ||
| const float * | a, | ||
| float * | gate, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | state_dim | ||
| ) |
Definition at line 179 of file recurrent_gate_kernels.c.
References __attribute__(), ck_bind_recurrent_llama_libm(), ck_recurrent_libm_once, ck_recurrent_llama_expf, and ck_recurrent_pytorch_log1pf.
|
inlinestatic |
Definition at line 54 of file recurrent_gate_kernels.c.
Referenced by recurrent_dt_gate_backward(), recurrent_silu_backward(), and recurrent_silu_forward().
| void recurrent_sigmoid_forward_ggml | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 501 of file recurrent_gate_kernels.c.
Referenced by hyper_connection_mix_quantized(), and recurrent_norm_sigmoid_gate_llama_avx2_forward().
| void recurrent_sigmoid_forward_pytorch_bf16_input_fp32_output | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 339 of file recurrent_gate_kernels.c.
References __attribute__(), bf16_to_float(), and float_to_bf16().
Referenced by attn_gate_sigmoid_mul_pytorch_bf16_storage(), and recurrent_norm_sigmoid_gate_pytorch_bf16_storage().
| void recurrent_silu_backward | ( | const float * | d_out, |
| const float * | x, | ||
| float * | d_x, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 515 of file recurrent_gate_kernels.c.
References recurrent_sigmoid().
| void recurrent_silu_forward | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 137 of file recurrent_gate_kernels.c.
References recurrent_sigmoid().
Referenced by ck_test_recurrent_silu().
| void recurrent_silu_forward_ggml | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 468 of file recurrent_gate_kernels.c.
Referenced by hyper_connection_mix_quantized(), qwen4_ple_gate_conv_inject_impl(), and recurrent_norm_gate_llama_avx2_forward().
| void recurrent_silu_forward_pytorch_bf16_input_fp32_output | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 299 of file recurrent_gate_kernels.c.
References __attribute__(), bf16_to_float(), and float_to_bf16().
Referenced by recurrent_norm_gate_pytorch_bf16_storage().
| void recurrent_silu_forward_pytorch_bf16_storage | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 252 of file recurrent_gate_kernels.c.
References __attribute__(), bf16_to_float(), float_to_bf16(), and silu().
|
inlinestatic |
Definition at line 43 of file recurrent_gate_kernels.c.
References ck_bind_recurrent_llama_libm(), ck_recurrent_libm_once, ck_recurrent_llama_expf, and ck_recurrent_llama_logf.
Referenced by recurrent_dt_gate_backward(), recurrent_dt_gate_expanded_forward(), and recurrent_dt_gate_forward().
|
static |
Definition at line 21 of file recurrent_gate_kernels.c.
Referenced by ck_bind_recurrent_llama_libm().
|
static |
Definition at line 22 of file recurrent_gate_kernels.c.
Referenced by recurrent_dt_gate_forward_pytorch_fp32(), and recurrent_softplus().
|
static |
Definition at line 18 of file recurrent_gate_kernels.c.
Referenced by ck_bind_recurrent_llama_libm(), recurrent_dt_gate_forward_pytorch_fp32(), and recurrent_softplus().
|
static |
Definition at line 19 of file recurrent_gate_kernels.c.
Referenced by ck_bind_recurrent_llama_libm(), and recurrent_softplus().
|
static |
Definition at line 20 of file recurrent_gate_kernels.c.
Referenced by ck_bind_recurrent_llama_libm(), and recurrent_dt_gate_forward_pytorch_fp32().