#include "opencl_source_map.hpp" namespace MNN { #ifndef MNN_OPENCL_BUFFER_CLOSED const char* rope_buf = "#ifdef MNN_SUPPORT_FP16\n" "#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n" "#endif\n" "#define GLOBAL_SIZE_3_DIMS "" __private const int global_size_dim0,__private const int global_size_dim1,__private const int global_size_dim2,\n" "#define DEAL_NON_UNIFORM_DIM3(input1, input2, input3) "" if (input1 >= global_size_dim0 || input2 >= global_size_dim1 || input3 >= global_size_dim2) { "" return; "" }\n" "#define C4_OFFSET(token,channel,seqLen) (((channel)/4)*(seqLen)*4+(token)*4+((channel) % 4))\n" "__kernel void rope_buf(GLOBAL_SIZE_3_DIMS __global const FLOAT* q,__global const FLOAT* k,__global const FLOAT* cos,\n" " __global const FLOAT* sin,__global FLOAT* q_out,__global FLOAT* k_out,\n" " __private const int outerSize,__private const int halfD,__private const int ropeHalfD,\n" " __private const int headDim,__private const int numHead,__private const int kvNumHead\n" "#ifdef Q_NORM\n" " ,\n" " __global const float* qGamma,__private const float qEps\n" "#endif\n" "#ifdef K_NORM\n" " ,\n" " __global const float* kGamma,__private const float kEps\n" "#endif\n" ") {\n" " const int x=get_global_id(0);\n" " const int y=get_global_id(1);\n" " const int z=get_global_id(2);\n" " DEAL_NON_UNIFORM_DIM3(x,y,z);\n" " const int fullHead=numHead+kvNumHead;\n" "#if defined(Q_NORM) || defined(K_NORM)\n" " if (x >= 1 || y >= outerSize || z >= fullHead) {\n" " return;\n" " }\n" "#else\n" " if (x >= halfD || y >= outerSize || z >= fullHead) {\n" " return;\n" " }\n" "#endif\n" " const int D=headDim;\n" " bool isQ=(z