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

Function ggml_compute_forward_silu_f32

ggml.c:9004–9043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9002// ggml_compute_forward_silu
9003
9004static void ggml_compute_forward_silu_f32(
9005 const struct ggml_compute_params * params,
9006 const struct ggml_tensor * src0,
9007 struct ggml_tensor * dst) {
9008 GGML_ASSERT(ggml_is_contiguous_except_dim_1(src0));
9009 GGML_ASSERT(ggml_is_contiguous_except_dim_1(dst));
9010 GGML_ASSERT(ggml_are_same_shape(src0, dst));
9011
9012 if (params->type == GGML_TASK_INIT || params->type == GGML_TASK_FINALIZE) {
9013 return;
9014 }
9015
9016 const int ith = params->ith;
9017 const int nth = params->nth;
9018
9019 const int nc = src0->ne[0];
9020 const int nr = ggml_nrows(src0);
9021
9022 // rows per thread
9023 const int dr = (nr + nth - 1)/nth;
9024
9025 // row range for this thread
9026 const int ir0 = dr*ith;
9027 const int ir1 = MIN(ir0 + dr, nr);
9028
9029 for (int i1 = ir0; i1 < ir1; i1++) {
9030 ggml_vec_silu_f32(nc,
9031 (float *) ((char *) dst->data + i1*( dst->nb[1])),
9032 (float *) ((char *) src0->data + i1*(src0->nb[1])));
9033
9034#ifndef NDEBUG
9035 for (int k = 0; k < nc; k++) {
9036 const float x = ((float *) ((char *) dst->data + i1*(dst->nb[1])))[k];
9037 UNUSED(x);
9038 assert(!isnan(x));
9039 assert(!isinf(x));
9040 }
9041#endif
9042 }
9043}
9044
9045static void ggml_compute_forward_silu(
9046 const struct ggml_compute_params * params,

Callers 1

Calls 4

ggml_are_same_shapeFunction · 0.70
ggml_nrowsFunction · 0.70
ggml_vec_silu_f32Function · 0.70

Tested by

no test coverage detected