| 14028 | } |
| 14029 | |
| 14030 | static void ggml_compute_forward_mul_mat_sparse( |
| 14031 | const struct ggml_compute_params * params, |
| 14032 | const struct ggml_tensor * src0, |
| 14033 | const struct ggml_tensor * src1, |
| 14034 | struct ggml_tensor * dst) { |
| 14035 | int64_t t0 = ggml_perf_time_us(); |
| 14036 | UNUSED(t0); |
| 14037 | |
| 14038 | GGML_TENSOR_BINARY_OP_LOCALS; |
| 14039 | |
| 14040 | const int ith = params->ith; |
| 14041 | const int nth = params->nth; |
| 14042 | |
| 14043 | const enum ggml_type type = src0->type; |
| 14044 | |
| 14045 | const bool src1_cont = ggml_is_contiguous(src1); |
| 14046 | |
| 14047 | ggml_vec_dot_t const vec_dot = type_traits[type].vec_dot; |
| 14048 | enum ggml_type const vec_dot_type = type_traits[type].vec_dot_type; |
| 14049 | ggml_from_float_t const from_float_to_vec_dot = type_traits[vec_dot_type].from_float; |
| 14050 | |
| 14051 | const float threshold = sparse_pred_threshold; |
| 14052 | |
| 14053 | GGML_ASSERT(ne0 == ne01); |
| 14054 | GGML_ASSERT(ne1 == ne11); |
| 14055 | GGML_ASSERT(ne2 == ne12); |
| 14056 | GGML_ASSERT(ne3 == ne13); |
| 14057 | |
| 14058 | // we don't support permuted src0 or src1 |
| 14059 | GGML_ASSERT(nb00 == ggml_type_size(type)); |
| 14060 | GGML_ASSERT(nb10 == sizeof(float)); |
| 14061 | |
| 14062 | // dst cannot be transposed or permuted |
| 14063 | GGML_ASSERT(nb0 == sizeof(float)); |
| 14064 | GGML_ASSERT(nb0 <= nb1); |
| 14065 | GGML_ASSERT(nb1 <= nb2); |
| 14066 | GGML_ASSERT(nb2 <= nb3); |
| 14067 | |
| 14068 | // broadcast factors |
| 14069 | const int64_t r2 = ne12/ne02; |
| 14070 | const int64_t r3 = ne13/ne03; |
| 14071 | |
| 14072 | // nb01 >= nb00 - src0 is not transposed |
| 14073 | // compute by src0 rows |
| 14074 | |
| 14075 | #if defined(GGML_USE_CLBLAST) |
| 14076 | if (ggml_cl_can_mul_mat(src0, src1, dst)) { |
| 14077 | // TODO: handle case when src0 is broadcast-able into src1 across 2nd,3rd dimension |
| 14078 | // ref: https://github.com/ggerganov/ggml/pull/224 |
| 14079 | GGML_ASSERT(ne02 == ne12); |
| 14080 | GGML_ASSERT(ne03 == ne13); |
| 14081 | |
| 14082 | if (params->ith == 0 && params->type == GGML_TASK_COMPUTE) { |
| 14083 | ggml_cl_mul_mat(src0, src1, dst, params->wdata, params->wsize); |
| 14084 | } |
| 14085 | return; |
| 14086 | } |
| 14087 | #endif |
no test coverage detected