| 9103 | // ggml_compute_forward_silu_back |
| 9104 | |
| 9105 | static void ggml_compute_forward_silu_back_f32( |
| 9106 | const struct ggml_compute_params * params, |
| 9107 | const struct ggml_tensor * src0, |
| 9108 | const struct ggml_tensor * grad, |
| 9109 | struct ggml_tensor * dst) { |
| 9110 | GGML_ASSERT(ggml_is_contiguous_except_dim_1(grad)); |
| 9111 | GGML_ASSERT(ggml_is_contiguous_except_dim_1(src0)); |
| 9112 | GGML_ASSERT(ggml_is_contiguous_except_dim_1(dst)); |
| 9113 | GGML_ASSERT(ggml_are_same_shape(src0, dst)); |
| 9114 | GGML_ASSERT(ggml_are_same_shape(src0, grad)); |
| 9115 | |
| 9116 | if (params->type == GGML_TASK_INIT || params->type == GGML_TASK_FINALIZE) { |
| 9117 | return; |
| 9118 | } |
| 9119 | |
| 9120 | const int ith = params->ith; |
| 9121 | const int nth = params->nth; |
| 9122 | |
| 9123 | const int nc = src0->ne[0]; |
| 9124 | const int nr = ggml_nrows(src0); |
| 9125 | |
| 9126 | // rows per thread |
| 9127 | const int dr = (nr + nth - 1)/nth; |
| 9128 | |
| 9129 | // row range for this thread |
| 9130 | const int ir0 = dr*ith; |
| 9131 | const int ir1 = MIN(ir0 + dr, nr); |
| 9132 | |
| 9133 | for (int i1 = ir0; i1 < ir1; i1++) { |
| 9134 | ggml_vec_silu_backward_f32(nc, |
| 9135 | (float *) ((char *) dst->data + i1*( dst->nb[1])), |
| 9136 | (float *) ((char *) src0->data + i1*(src0->nb[1])), |
| 9137 | (float *) ((char *) grad->data + i1*(grad->nb[1]))); |
| 9138 | |
| 9139 | #ifndef NDEBUG |
| 9140 | for (int k = 0; k < nc; k++) { |
| 9141 | const float x = ((float *) ((char *) dst->data + i1*( dst->nb[1])))[k]; |
| 9142 | UNUSED(x); |
| 9143 | assert(!isnan(x)); |
| 9144 | assert(!isinf(x)); |
| 9145 | } |
| 9146 | #endif |
| 9147 | } |
| 9148 | } |
| 9149 | |
| 9150 | static void ggml_compute_forward_silu_back( |
| 9151 | const struct ggml_compute_params * params, |
no test coverage detected