Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-opencl/kernels/add_id.cl # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-opencl / kernels / add_id.cl` 50 lines ยท 1631 bytes Raw Blame History 1 #pragma OPENCL EXTENSION cl_khr_fp16 : enable 2 3 //------------------------------------------------------------------------------ 4 // add_id 5 //------------------------------------------------------------------------------ 6 kernel void kernel_add_id( 7 global char * src0, 8 ulong offset0, 9 global char * src1, 10 ulong offset1, 11 global char * src2, 12 ulong offset2, 13 global char * dst, 14 ulong offsetd, 15 ulong nb01, 16 ulong nb02, 17 ulong nb11, 18 ulong nb21, 19 int ne0, 20 int ne1 21 ) { 22 src0 = (global char*)((global char*)src0 + offset0); 23 src1 = (global char*)((global char*)src1 + offset1); 24 src2 = (global char*)((global char*)src2 + offset2); 25 dst = (global char*)((global char*)dst + offsetd); 26 27 int i1 = get_group_id(0); 28 int i2 = get_group_id(1); 29 30 const int i11 = *((global const int *) (src2 + i1*sizeof(int) + i2*nb21)); 31 32 const size_t nb1 = ne0 * sizeof(float); 33 const size_t nb2 = ne1 * nb1; 34 35 global float * dst_row = (global float *)((global char *)dst + i1*nb1 + i2*nb2); 36 global float * src0_row = (global float *)((global char *)src0 + i1*nb01 + i2*nb02); 37 38 if (i11 == -1) { // skipped slot, add nothing 39 for (int i0 = get_local_id(0); i0 < ne0; i0 += get_local_size(0)) { 40 dst_row[i0] = src0_row[i0]; 41 } 42 return; 43 } 44 45 global float * src1_row = (global float *)((global char *)src1 + i11*nb11); 46 47 for (int i0 = get_local_id(0); i0 < ne0; i0 += get_local_size(0)) { 48 dst_row[i0] = src0_row[i0] + src1_row[i0]; 49 } 50 }