#ifdef MNN_SUPPORT_FP16 #pragma OPENCL EXTENSION cl_khr_fp16 : enable #endif /* \ #define OPWM 64 // The outputsize-per-workgroup in dimension M #define OPWN 128 // The outputsize-per-workgroup in dimension N #define CPWK 8 // The cachesize-per-workgroup in dimension K #define OPTM 4 // The outputsize-per-thread in dimension M #define OPTN 8 // The outputsize-per-thread in dimension N */ #define TPWM (OPWM/OPTM) // The threadsize-per-workgroup in dimension M #define TPWN (OPWN/OPTN) // The threadsize-per-workgroup in dimension N #define LPTA ((CPWK*OPWM)/(TPWM*TPWN)) // Loads-num-per-thread for A #define LPTB ((CPWK*OPWN)/(TPWM*TPWN)) // Loads-num-per-thread for B // vetorize + pragma unroll __kernel void matmul_local_buf(const int M, const int N, const int K, __global const FLOAT* A, #if (defined USE_LOW_BIT_WEIGHT_INT8) __global const char* B, __global const float* dequantScale, __global const float* dequantOffset, #elif (defined USE_LOW_BIT_WEIGHT_INT4) __global const uchar* B, __global const float* dequantScale, __global const float* dequantOffset, #else __global const FLOAT* B, #endif #ifdef BIAS __global const FLOAT* bias, #endif __global FLOAT* C) { // Local thread id const int lidm = get_local_id(0); // Local row ID const int lidn = get_local_id(1); // Local col ID // group id const int offsetM = get_group_id(0) * OPWM; // Work-group offset M const int offsetN = get_group_id(1) * OPWN; // Work-group offset N // Local memory for work-group cache of A and B __local FLOAT Alocal[CPWK][OPWM]; __local FLOAT Blocal[OPWN][CPWK+2]; // Allocate register space COMPUTE_FLOAT sum[OPTM][OPTN]; // Initialise the accumulation registers for (int wm=0; wm