| 9596 | #endif |
| 9597 | |
| 9598 | static void ggml_compute_forward_mul_mat( |
| 9599 | const struct ggml_compute_params * params, |
| 9600 | const struct ggml_tensor * src0, |
| 9601 | const struct ggml_tensor * src1, |
| 9602 | struct ggml_tensor * dst) { |
| 9603 | int64_t t0 = ggml_perf_time_us(); |
| 9604 | UNUSED(t0); |
| 9605 | |
| 9606 | GGML_TENSOR_BINARY_OP_LOCALS |
| 9607 | |
| 9608 | const int ith = params->ith; |
| 9609 | const int nth = params->nth; |
| 9610 | |
| 9611 | const enum ggml_type type = src0->type; |
| 9612 | |
| 9613 | const bool src1_cont = ggml_is_contiguous(src1); |
| 9614 | |
| 9615 | ggml_vec_dot_t const vec_dot = type_traits[type].vec_dot; |
| 9616 | enum ggml_type const vec_dot_type = type_traits[type].vec_dot_type; |
| 9617 | ggml_from_float_t const from_float_to_vec_dot = type_traits[vec_dot_type].from_float; |
| 9618 | |
| 9619 | GGML_ASSERT(ne0 == ne01); |
| 9620 | GGML_ASSERT(ne1 == ne11); |
| 9621 | GGML_ASSERT(ne2 == ne12); |
| 9622 | GGML_ASSERT(ne3 == ne13); |
| 9623 | |
| 9624 | // we don't support permuted src0 or src1 |
| 9625 | GGML_ASSERT(nb00 == ggml_type_size(type)); |
| 9626 | GGML_ASSERT(nb10 == ggml_type_size(src1->type)); |
| 9627 | |
| 9628 | // dst cannot be transposed or permuted |
| 9629 | GGML_ASSERT(nb0 == sizeof(float)); |
| 9630 | GGML_ASSERT(nb0 <= nb1); |
| 9631 | GGML_ASSERT(nb1 <= nb2); |
| 9632 | GGML_ASSERT(nb2 <= nb3); |
| 9633 | |
| 9634 | // broadcast factors |
| 9635 | const int64_t r2 = ne12/ne02; |
| 9636 | const int64_t r3 = ne13/ne03; |
| 9637 | |
| 9638 | // nb01 >= nb00 - src0 is not transposed |
| 9639 | // compute by src0 rows |
| 9640 | |
| 9641 | #if defined(GGML_USE_CLBLAST) |
| 9642 | if (ggml_cl_can_mul_mat(src0, src1, dst)) { |
| 9643 | if (params->ith == 0 && params->type == GGML_TASK_COMPUTE) { |
| 9644 | ggml_cl_mul_mat(src0, src1, dst, params->wdata, params->wsize); |
| 9645 | } |
| 9646 | return; |
| 9647 | } |
| 9648 | #endif |
| 9649 | |
| 9650 | #if defined(GGML_USE_ACCELERATE) || defined(GGML_USE_OPENBLAS) |
| 9651 | if (ggml_compute_forward_mul_mat_use_blas(src0, src1, dst)) { |
| 9652 | if (params->ith != 0) { |
| 9653 | return; |
| 9654 | } |
| 9655 |
no test coverage detected