#include <math.h>#include <stddef.h>#include <stdint.h>#include <string.h>#include "bf16_utils.h"#include "ckernel_engine.h"Go to the source code of this file.
Functions | |
| static int | binary_bf16 (const uint16_t *left, const uint16_t *right, size_t rhs_count, uint16_t *out, uint16_t *stage, size_t n, int multiply) |
| int | ck_add_bf16_checked (const uint16_t *left, const uint16_t *right, uint16_t *out, uint16_t *stage, size_t elements) |
| int | ck_argmax_values_bf16_checked (const uint16_t *values, int32_t *index, size_t elements, size_t index_elements) |
| int | ck_bias_rows_bf16_checked (const uint16_t *input, const uint16_t *bias, uint16_t *out, uint16_t *stage, size_t elements, size_t bias_elements) |
| int | ck_geglu_tanh_bf16_checked (const uint16_t *gate, const uint16_t *up, uint16_t *out, float *stage, size_t elements) |
| int | ck_indexed_affine_bf16_checked (const uint16_t *input, const int32_t *indices, const uint16_t *scale, const uint16_t *shift, uint16_t *out, uint16_t *stage, size_t rows, size_t width, size_t banks, size_t elements, size_t bank_elements) |
| int | ck_indexed_residual_bf16_checked (const uint16_t *input, const int32_t *indices, const uint16_t *scale, const uint16_t *update, uint16_t *out, uint16_t *stage, size_t rows, size_t width, size_t banks, size_t elements, size_t bank_elements) |
| int | ck_mul_bf16_checked (const uint16_t *left, const uint16_t *right, uint16_t *out, uint16_t *stage, size_t elements) |
| int | ck_narrow_f32_bf16_checked (const float *input, uint16_t *out, size_t elements) |
| int | ck_prepend_weight_row_bf16_checked (const uint16_t *input, const uint16_t *row, uint16_t *out, size_t input_elements, size_t row_elements, size_t output_elements) |
| int | ck_relu2_bf16_checked (const uint16_t *input, uint16_t *out, float *stage, size_t elements) |
| int | ck_rope_interleaved_partial_bf16_checked (const uint16_t *input, const int32_t *positions, const float *inv_freq, uint16_t *out, uint16_t *stage, size_t tokens, size_t heads, size_t dim, size_t elements, size_t frequencies) |
| int | ck_rope_split_interleaved_3d_bf16_checked (const uint16_t *input, const int32_t *positions, const float *inv_freq, uint16_t *out, uint16_t *stage, size_t tokens, size_t heads, size_t dim, size_t elements, size_t frequencies, size_t position_elements, size_t axis1_pairs, size_t axis2_pairs) |
| int | ck_rope_split_interleaved_3d_fp32_pos_bf16_checked (const uint16_t *input, const float *positions, const float *inv_freq, uint16_t *out, uint16_t *stage, size_t tokens, size_t heads, size_t dim, size_t elements, size_t frequencies, size_t position_elements, size_t axis1_pairs, size_t axis2_pairs) |
| int | ck_rope_split_positions_bf16_checked (const uint16_t *input, const int32_t *positions, const float *inv_freq, uint16_t *out, uint16_t *stage, size_t tokens, size_t heads, size_t dim, size_t elements, size_t frequencies) |
| int | ck_rope_split_tables_bf16_checked (const uint16_t *input, const uint16_t *cosine, const uint16_t *sine, uint16_t *out, uint16_t *stage, size_t tokens, size_t heads, size_t dim, size_t rotary_dim, size_t elements, size_t table_elements) |
| int | ck_scale_bf16_checked (const uint16_t *input, const uint16_t *weight, uint16_t *out, uint16_t *stage, size_t elements, size_t gain_elements) |
| int | ck_scale_rows_bf16_checked (const uint16_t *input, const uint16_t *weight, uint16_t *out, uint16_t *stage, size_t elements, size_t gain_elements) |
| int | ck_scale_scalar_f32_bf16_checked (const uint16_t *input, uint16_t *out, uint16_t *stage, size_t elements, float scale) |
| int | ck_sigmoid_mul_bf16_checked (const uint16_t *gate, const uint16_t *up, uint16_t *out, float *stage, size_t elements) |
| int | ck_silu_bf16_checked (const uint16_t *input, uint16_t *out, uint16_t *stage, size_t elements) |
| int | ck_slice_bf16_checked (const uint16_t *input, uint16_t *out, size_t input_elements, size_t offset, size_t elements) |
| int | ck_swiglu_bf16_checked (const uint16_t *gate, const uint16_t *up, uint16_t *out, float *stage, size_t elements) |
| int | ck_widen_bf16_checked (const uint16_t *input, float *out, size_t elements) |
| static int | gated_bf16 (const uint16_t *gate, const uint16_t *up, uint16_t *out, float *stage, size_t n, void(*activate)(float *, size_t)) |
| static int | indexed_transform_valid (const uint16_t *input, const int32_t *indices, const uint16_t *scale, const uint16_t *other, size_t other_count, uint16_t *out, uint16_t *stage, size_t rows, size_t width, size_t banks, size_t elements, size_t bank_elements) |
| static int | overlaps (const void *a, size_t abytes, const void *b, size_t bbytes) |
| static int | rope_split_positions_bf16_checked (const uint16_t *input, const void *positions, const float *inv_freq, uint16_t *out, uint16_t *stage, size_t tokens, size_t heads, size_t dim, size_t elements, size_t frequencies, size_t axes, size_t position_elements, size_t axis1_pairs, size_t axis2_pairs, int fp32_positions) |
| static void | sigmoid_bf16_storage (float *values, size_t count) |
| static void | silu_bf16_storage (float *values, size_t count) |
| static int | valid_span (const void *ptr, size_t count, size_t element) |
|
static |
Definition at line 38 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), float_to_bf16(), left, overlaps(), right, and valid_span().
Referenced by ck_add_bf16_checked(), ck_bias_rows_bf16_checked(), ck_mul_bf16_checked(), ck_scale_bf16_checked(), and ck_scale_rows_bf16_checked().
| int ck_add_bf16_checked | ( | const uint16_t * | left, |
| const uint16_t * | right, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | elements ) |
Definition at line 65 of file bf16_checked_tensor_ops.c.
References binary_bf16(), left, and right.
| int ck_argmax_values_bf16_checked | ( | const uint16_t * | values, |
| int32_t * | index, | ||
| size_t | elements, | ||
| size_t | index_elements ) |
Definition at line 365 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), overlaps(), and valid_span().
| int ck_bias_rows_bf16_checked | ( | const uint16_t * | input, |
| const uint16_t * | bias, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | elements, | ||
| size_t | bias_elements ) |
Definition at line 77 of file bf16_checked_tensor_ops.c.
References binary_bf16().
| int ck_geglu_tanh_bf16_checked | ( | const uint16_t * | gate, |
| const uint16_t * | up, | ||
| uint16_t * | out, | ||
| float * | stage, | ||
| size_t | elements ) |
Definition at line 161 of file bf16_checked_tensor_ops.c.
References gated_bf16(), and gelu_pytorch_tanh_bf16_storage().
Referenced by routed_experts_bf16_checked().
| int ck_indexed_affine_bf16_checked | ( | const uint16_t * | input, |
| const int32_t * | indices, | ||
| const uint16_t * | scale, | ||
| const uint16_t * | shift, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | rows, | ||
| size_t | width, | ||
| size_t | banks, | ||
| size_t | elements, | ||
| size_t | bank_elements ) |
Definition at line 496 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), float_to_bf16(), indexed_transform_valid(), and product().
| int ck_indexed_residual_bf16_checked | ( | const uint16_t * | input, |
| const int32_t * | indices, | ||
| const uint16_t * | scale, | ||
| const uint16_t * | update, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | rows, | ||
| size_t | width, | ||
| size_t | banks, | ||
| size_t | elements, | ||
| size_t | bank_elements ) |
Definition at line 521 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), float_to_bf16(), indexed_transform_valid(), and product().
| int ck_mul_bf16_checked | ( | const uint16_t * | left, |
| const uint16_t * | right, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | elements ) |
Definition at line 71 of file bf16_checked_tensor_ops.c.
References binary_bf16(), left, and right.
| int ck_narrow_f32_bf16_checked | ( | const float * | input, |
| uint16_t * | out, | ||
| size_t | elements ) |
Definition at line 386 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), float_to_bf16(), overlaps(), and valid_span().
| int ck_prepend_weight_row_bf16_checked | ( | const uint16_t * | input, |
| const uint16_t * | row, | ||
| uint16_t * | out, | ||
| size_t | input_elements, | ||
| size_t | row_elements, | ||
| size_t | output_elements ) |
Definition at line 21 of file bf16_checked_tensor_ops.c.
References overlaps(), and valid_span().
| int ck_relu2_bf16_checked | ( | const uint16_t * | input, |
| uint16_t * | out, | ||
| float * | stage, | ||
| size_t | elements ) |
Definition at line 112 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), float_to_bf16(), overlaps(), and valid_span().
| int ck_rope_interleaved_partial_bf16_checked | ( | const uint16_t * | input, |
| const int32_t * | positions, | ||
| const float * | inv_freq, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | tokens, | ||
| size_t | heads, | ||
| size_t | dim, | ||
| size_t | elements, | ||
| size_t | frequencies ) |
Definition at line 293 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), float_to_bf16(), overlaps(), token, and valid_span().
| int ck_rope_split_interleaved_3d_bf16_checked | ( | const uint16_t * | input, |
| const int32_t * | positions, | ||
| const float * | inv_freq, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | tokens, | ||
| size_t | heads, | ||
| size_t | dim, | ||
| size_t | elements, | ||
| size_t | frequencies, | ||
| size_t | position_elements, | ||
| size_t | axis1_pairs, | ||
| size_t | axis2_pairs ) |
Definition at line 273 of file bf16_checked_tensor_ops.c.
References rope_split_positions_bf16_checked().
| int ck_rope_split_interleaved_3d_fp32_pos_bf16_checked | ( | const uint16_t * | input, |
| const float * | positions, | ||
| const float * | inv_freq, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | tokens, | ||
| size_t | heads, | ||
| size_t | dim, | ||
| size_t | elements, | ||
| size_t | frequencies, | ||
| size_t | position_elements, | ||
| size_t | axis1_pairs, | ||
| size_t | axis2_pairs ) |
Definition at line 283 of file bf16_checked_tensor_ops.c.
References rope_split_positions_bf16_checked().
| int ck_rope_split_positions_bf16_checked | ( | const uint16_t * | input, |
| const int32_t * | positions, | ||
| const float * | inv_freq, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | tokens, | ||
| size_t | heads, | ||
| size_t | dim, | ||
| size_t | elements, | ||
| size_t | frequencies ) |
Definition at line 264 of file bf16_checked_tensor_ops.c.
References rope_split_positions_bf16_checked().
| int ck_rope_split_tables_bf16_checked | ( | const uint16_t * | input, |
| const uint16_t * | cosine, | ||
| const uint16_t * | sine, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | tokens, | ||
| size_t | heads, | ||
| size_t | dim, | ||
| size_t | rotary_dim, | ||
| size_t | elements, | ||
| size_t | table_elements ) |
Definition at line 401 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), float_to_bf16(), overlaps(), and valid_span().
| int ck_scale_bf16_checked | ( | const uint16_t * | input, |
| const uint16_t * | weight, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | elements, | ||
| size_t | gain_elements ) |
Definition at line 84 of file bf16_checked_tensor_ops.c.
References binary_bf16().
| int ck_scale_rows_bf16_checked | ( | const uint16_t * | input, |
| const uint16_t * | weight, | ||
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | elements, | ||
| size_t | gain_elements ) |
Definition at line 92 of file bf16_checked_tensor_ops.c.
References binary_bf16().
| int ck_scale_scalar_f32_bf16_checked | ( | const uint16_t * | input, |
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | elements, | ||
| float | scale ) |
Definition at line 345 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), float_to_bf16(), overlaps(), and valid_span().
| int ck_sigmoid_mul_bf16_checked | ( | const uint16_t * | gate, |
| const uint16_t * | up, | ||
| uint16_t * | out, | ||
| float * | stage, | ||
| size_t | elements ) |
Definition at line 187 of file bf16_checked_tensor_ops.c.
References gated_bf16(), and sigmoid_bf16_storage().
| int ck_silu_bf16_checked | ( | const uint16_t * | input, |
| uint16_t * | out, | ||
| uint16_t * | stage, | ||
| size_t | elements ) |
Definition at line 546 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), float_to_bf16(), overlaps(), and valid_span().
| int ck_slice_bf16_checked | ( | const uint16_t * | input, |
| uint16_t * | out, | ||
| size_t | input_elements, | ||
| size_t | offset, | ||
| size_t | elements ) |
Definition at line 453 of file bf16_checked_tensor_ops.c.
References overlaps(), and valid_span().
| int ck_swiglu_bf16_checked | ( | const uint16_t * | gate, |
| const uint16_t * | up, | ||
| uint16_t * | out, | ||
| float * | stage, | ||
| size_t | elements ) |
Definition at line 175 of file bf16_checked_tensor_ops.c.
References gated_bf16(), and silu_bf16_storage().
Referenced by routed_experts_bf16_checked().
| int ck_widen_bf16_checked | ( | const uint16_t * | input, |
| float * | out, | ||
| size_t | elements ) |
Definition at line 98 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), overlaps(), and valid_span().
|
static |
Definition at line 135 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), float_to_bf16(), overlaps(), and valid_span().
Referenced by ck_geglu_tanh_bf16_checked(), ck_sigmoid_mul_bf16_checked(), and ck_swiglu_bf16_checked().
|
static |
Definition at line 466 of file bf16_checked_tensor_ops.c.
References overlaps(), and valid_span().
Referenced by ck_indexed_affine_bf16_checked(), and ck_indexed_residual_bf16_checked().
|
static |
Definition at line 15 of file bf16_checked_tensor_ops.c.
Referenced by binary_bf16(), ck_argmax_values_bf16_checked(), ck_narrow_f32_bf16_checked(), ck_prepend_weight_row_bf16_checked(), ck_relu2_bf16_checked(), ck_rope_interleaved_partial_bf16_checked(), ck_rope_split_tables_bf16_checked(), ck_scale_scalar_f32_bf16_checked(), ck_silu_bf16_checked(), ck_slice_bf16_checked(), ck_widen_bf16_checked(), gated_bf16(), indexed_transform_valid(), and rope_split_positions_bf16_checked().
|
static |
Definition at line 193 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), count, float_to_bf16(), overlaps(), and valid_span().
Referenced by ck_rope_split_interleaved_3d_bf16_checked(), ck_rope_split_interleaved_3d_fp32_pos_bf16_checked(), and ck_rope_split_positions_bf16_checked().
|
static |
Definition at line 181 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), count, and float_to_bf16().
Referenced by ck_sigmoid_mul_bf16_checked().
|
static |
Definition at line 167 of file bf16_checked_tensor_ops.c.
References bf16_to_float(), count, and float_to_bf16().
Referenced by ck_swiglu_bf16_checked().
|
static |
Definition at line 9 of file bf16_checked_tensor_ops.c.
References count.
Referenced by binary_bf16(), ck_argmax_values_bf16_checked(), ck_narrow_f32_bf16_checked(), ck_prepend_weight_row_bf16_checked(), ck_relu2_bf16_checked(), ck_rope_interleaved_partial_bf16_checked(), ck_rope_split_tables_bf16_checked(), ck_scale_scalar_f32_bf16_checked(), ck_silu_bf16_checked(), ck_slice_bf16_checked(), ck_widen_bf16_checked(), gated_bf16(), indexed_transform_valid(), and rope_split_positions_bf16_checked().