7 int tokens,
int heads,
int head_dim)
9 if (!src || !dst || tokens <= 0 || heads <= 0 || head_dim <= 0)
return;
10 for (
int t = 0; t < tokens; ++t) {
11 for (
int h = 0; h < heads; ++h) {
12 memcpy(dst + ((
size_t)h * (
size_t)tokens + (
size_t)t) * (
size_t)head_dim,
13 src + ((
size_t)t * (
size_t)heads + (
size_t)h) * (
size_t)head_dim,
14 (
size_t)head_dim *
sizeof(
float));
20 int heads,
int tokens,
int head_dim)
22 if (!src || !dst || heads <= 0 || tokens <= 0 || head_dim <= 0)
return;
23 for (
int h = 0; h < heads; ++h) {
24 for (
int t = 0; t < tokens; ++t) {
25 memcpy(dst + ((
size_t)t * (
size_t)heads + (
size_t)h) * (
size_t)head_dim,
26 src + ((
size_t)h * (
size_t)tokens + (
size_t)t) * (
size_t)head_dim,
27 (
size_t)head_dim *
sizeof(
float));
void ck_layout_token_to_head_f32(const float *src, float *dst, int tokens, int heads, int head_dim)
void ck_layout_head_to_token_f32(const float *src, float *dst, int heads, int tokens, int head_dim)