| 7754 | // ggml_compute_forward_mul |
| 7755 | |
| 7756 | static void ggml_compute_forward_mul_f32( |
| 7757 | const struct ggml_compute_params * params, |
| 7758 | const struct ggml_tensor * src0, |
| 7759 | const struct ggml_tensor * src1, |
| 7760 | struct ggml_tensor * dst) { |
| 7761 | GGML_ASSERT(ggml_can_repeat_rows(src1, src0) && ggml_are_same_shape(src0, dst)); |
| 7762 | |
| 7763 | if (params->type == GGML_TASK_INIT || params->type == GGML_TASK_FINALIZE) { |
| 7764 | return; |
| 7765 | } |
| 7766 | const int ith = params->ith; |
| 7767 | const int nth = params->nth; |
| 7768 | |
| 7769 | #ifdef GGML_USE_CLBLAST |
| 7770 | if (src1->backend == GGML_BACKEND_GPU) { |
| 7771 | if (ith == 0) { |
| 7772 | ggml_cl_mul(src0, src1, dst); |
| 7773 | } |
| 7774 | return; |
| 7775 | } |
| 7776 | #endif |
| 7777 | |
| 7778 | const int64_t nr = ggml_nrows(src0); |
| 7779 | |
| 7780 | GGML_TENSOR_BINARY_OP_LOCALS |
| 7781 | |
| 7782 | GGML_ASSERT( nb0 == sizeof(float)); |
| 7783 | GGML_ASSERT(nb00 == sizeof(float)); |
| 7784 | GGML_ASSERT(ne00 == ne10); |
| 7785 | |
| 7786 | if (nb10 == sizeof(float)) { |
| 7787 | for (int64_t ir = ith; ir < nr; ir += nth) { |
| 7788 | // src0 and dst are same shape => same indices |
| 7789 | const int64_t i03 = ir/(ne02*ne01); |
| 7790 | const int64_t i02 = (ir - i03*ne02*ne01)/ne01; |
| 7791 | const int64_t i01 = (ir - i03*ne02*ne01 - i02*ne01); |
| 7792 | |
| 7793 | const int64_t i13 = i03 % ne13; |
| 7794 | const int64_t i12 = i02 % ne12; |
| 7795 | const int64_t i11 = i01 % ne11; |
| 7796 | |
| 7797 | float * dst_ptr = (float *) ((char *) dst->data + i03*nb3 + i02*nb2 + i01*nb1 ); |
| 7798 | float * src0_ptr = (float *) ((char *) src0->data + i03*nb03 + i02*nb02 + i01*nb01); |
| 7799 | float * src1_ptr = (float *) ((char *) src1->data + i13*nb13 + i12*nb12 + i11*nb11); |
| 7800 | |
| 7801 | #ifdef GGML_USE_ACCELERATE |
| 7802 | UNUSED(ggml_vec_mul_f32); |
| 7803 | |
| 7804 | vDSP_vmul( src0_ptr, 1, src1_ptr, 1, dst_ptr, 1, ne00); |
| 7805 | #else |
| 7806 | ggml_vec_mul_f32(ne00, dst_ptr, src0_ptr, src1_ptr); |
| 7807 | #endif |
| 7808 | // } |
| 7809 | // } |
| 7810 | } |
| 7811 | } else { |
| 7812 | // src1 is not contiguous |
| 7813 | for (int64_t ir = ith; ir < nr; ir += nth) { |
no test coverage detected