MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_compute_forward_flash_ff_f16

Function ggml_compute_forward_flash_ff_f16

ggml.c:12585–12716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12583// ggml_compute_forward_flash_ff
12584
12585static void ggml_compute_forward_flash_ff_f16(
12586 const struct ggml_compute_params * params,
12587 const struct ggml_tensor * a, // F16
12588 const struct ggml_tensor * b0, // F16 fc_w
12589 const struct ggml_tensor * b1, // F32 fc_b
12590 const struct ggml_tensor * c0, // F16 proj_w
12591 const struct ggml_tensor * c1, // F32 proj_b
12592 struct ggml_tensor * dst) {
12593 int64_t t0 = ggml_perf_time_us();
12594 UNUSED(t0);
12595
12596 GGML_TENSOR_LOCALS(int64_t, nea, a, ne)
12597 GGML_TENSOR_LOCALS(size_t, nba, a, nb)
12598 GGML_TENSOR_LOCALS(int64_t, neb0, b0, ne)
12599 GGML_TENSOR_LOCALS(size_t, nbb0, b0, nb)
12600 GGML_TENSOR_LOCALS(int64_t, neb1, b1, ne)
12601 GGML_TENSOR_LOCALS(size_t, nbb1, b1, nb)
12602 GGML_TENSOR_LOCALS(int64_t, nec0, c0, ne)
12603 GGML_TENSOR_LOCALS(size_t, nbc0, c0, nb)
12604 GGML_TENSOR_LOCALS(int64_t, nec1, c1, ne)
12605 GGML_TENSOR_LOCALS(size_t, nbc1, c1, nb)
12606 GGML_TENSOR_LOCALS(int64_t, ne, dst, ne)
12607 GGML_TENSOR_LOCALS(size_t, nb, dst, nb)
12608
12609 const int ith = params->ith;
12610 const int nth = params->nth;
12611
12612 const int64_t D = nea0;
12613 //const int64_t N = nea1;
12614 const int64_t M = neb01;
12615
12616 GGML_ASSERT(ne0 == nea0);
12617 GGML_ASSERT(ne1 == nea1);
12618 GGML_ASSERT(ne2 == nea2);
12619
12620 GGML_ASSERT(nba0 == sizeof(ggml_fp16_t));
12621 GGML_ASSERT(nbb00 == sizeof(ggml_fp16_t));
12622 GGML_ASSERT(nbb10 == sizeof(float));
12623 GGML_ASSERT(nbc00 == sizeof(ggml_fp16_t));
12624 GGML_ASSERT(nbc10 == sizeof(float));
12625
12626 GGML_ASSERT(neb00 == D);
12627 GGML_ASSERT(neb01 == M);
12628 GGML_ASSERT(neb10 == M);
12629 GGML_ASSERT(neb11 == 1);
12630
12631 GGML_ASSERT(nec00 == M);
12632 GGML_ASSERT(nec01 == D);
12633 GGML_ASSERT(nec10 == D);
12634 GGML_ASSERT(nec11 == 1);
12635
12636 // dst cannot be transposed or permuted
12637 GGML_ASSERT(nb0 == sizeof(float));
12638 GGML_ASSERT(nb0 <= nb1);
12639 GGML_ASSERT(nb1 <= nb2);
12640 GGML_ASSERT(nb2 <= nb3);
12641
12642 if (params->type == GGML_TASK_INIT) {

Callers 1

Calls 3

ggml_vec_dot_f16Function · 0.70
ggml_vec_add_f32Function · 0.70
ggml_vec_gelu_f16Function · 0.70

Tested by

no test coverage detected