MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / ggml_compute_forward_get_rows

Function ggml_compute_forward_get_rows

external/ggml/src/ggml-cpu/ops.cpp:4964–5035  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4962 const int nth = params->nth;
4963
4964 // rows per thread
4965 const int dr = (nr + nth - 1)/nth;
4966
4967 // row range for this thread
4968 const int ir0 = dr*ith;
4969 const int ir1 = MIN(ir0 + dr, nr);
4970
4971 for (int64_t i = ir0; i < ir1; ++i) {
4972 const int64_t i12 = i/(ne11*ne10);
4973 const int64_t i11 = (i - i12*ne11*ne10)/ne10;
4974 const int64_t i10 = (i - i12*ne11*ne10 - i11*ne10);
4975 const int64_t i01 = *(int32_t *) ((char *) src1->data + i10*nb10 + i11*nb11 + i12*nb12);
4976
4977 GGML_ASSERT(i01 >= 0 && i01 < ne01);
4978
4979 ggml_cpu_bf16_to_fp32(
4980 (const ggml_bf16_t *) ((char *) src0->data + i01*nb01 + i11*nb02 + i12*nb03),
4981 (float *) ((char *) dst->data + i10*nb1 + i11*nb2 + i12*nb3), nc);
4982 }
4983}
4984
4985static void ggml_compute_forward_get_rows_f32(
4986 const ggml_compute_params * params,
4987 ggml_tensor * dst) {
4988
4989 const ggml_tensor * src0 = dst->src[0];
4990 const ggml_tensor * src1 = dst->src[1];
4991
4992 GGML_TENSOR_BINARY_OP_LOCALS
4993
4994 const int64_t nc = ne00;
4995 const int64_t nr = ggml_nelements(src1);
4996
4997 assert(ne0 == nc);
4998 assert(ne02 == ne11);
4999 assert(nb00 == sizeof(float));
5000 assert(ggml_nrows(dst) == nr);
5001
5002 const int ith = params->ith;
5003 const int nth = params->nth;
5004
5005 // rows per thread
5006 const int dr = (nr + nth - 1)/nth;
5007
5008 // row range for this thread
5009 const int ir0 = dr*ith;
5010 const int ir1 = MIN(ir0 + dr, nr);
5011
5012 for (int64_t i = ir0; i < ir1; ++i) {
5013 const int64_t i12 = i/(ne11*ne10);
5014 const int64_t i11 = (i - i12*ne11*ne10)/ne10;
5015 const int64_t i10 = (i - i12*ne11*ne10 - i11*ne10);
5016 const int64_t i01 = *(int32_t *) ((char *) src1->data + i10*nb10 + i11*nb11 + i12*nb12);
5017
5018 GGML_ASSERT(i01 >= 0 && i01 < ne01);
5019
5020 ggml_vec_cpy_f32(nc,
5021 (float *) ((char *) dst->data + i10*nb1 + i11*nb2 + i12*nb3),

Callers 2

ggml_compute_forwardFunction · 0.85
compute_forwardMethod · 0.85

Tested by

no test coverage detected