Download modules/core/src/opencl/gemm.cl from tgollogly/test: direct link, hf CLI and curl.
- Browser
- Download file 3.02 kB
-
https://huggingface.co/tgollogly/test/resolve/main/modules/core/src/opencl/gemm.cl
- Command line
-
hf download hf://tgollogly/test/modules/core/src/opencl/gemm.cl
-
curl -L -o gemm.cl https://huggingface.co/tgollogly/test/resolve/main/modules/core/src/opencl/gemm.cl
3.02 kB
| // This file is part of OpenCV project. | |
| // It is subject to the license terms in the LICENSE file found in the top-level directory | |
| // of this distribution and at http://opencv.org/license.html. | |
| // Copyright (C) 2014, Itseez, Inc., all rights reserved. | |
| // Third party copyrights are property of their respective owners. | |
| __kernel void gemm(__global const uchar * A_ptr, int A_step, int A_offset, | |
| __global const uchar * B_ptr, int B_step, int B_offset, | |
| __global uchar * D_ptr, int D_step, int D_offset, int D_rows, int D_cols, | |
| int n, T1 alpha, T1 beta) | |
| { | |
| int x = get_global_id(0); | |
| int y = get_global_id(1); | |
| int lidx = get_local_id(0); | |
| int lidy = get_local_id(1); | |
| __global const T* A = (__global const T*)(A_ptr + IND_A); | |
| __global const WT* B = (__global const WT*)(B_ptr + IND_B); | |
| WT sum = (WT)(0); | |
| if (x < D_cols && y < D_rows) | |
| { | |
| for (int i = 0; i < n; ++i) | |
| MUL(A[i], B[i*STEP_B]); | |
| __local T a_local[LOCAL_SIZE_ODD*LOCAL_SIZE]; | |
| __local WT b_local[LOCAL_SIZE_ODD*LOCAL_SIZE]; | |
| int reps; | |
| reps = (n + LOCAL_SIZE-1)/LOCAL_SIZE; | |
| reps = n/LOCAL_SIZE; | |
| for (int p = 0; p < reps; ++p) | |
| { | |
| if (p * LOCAL_SIZE + lidx < n && y < D_rows) | |
| a_local[mad24(lidy, LOCAL_SIZE_ODD, lidx)] = A[mad24(p, LOCAL_SIZE, lidx)]; | |
| if (p * LOCAL_SIZE + lidy < n && x < D_cols) | |
| b_local[mad24(lidy, LOCAL_SIZE_ODD, lidx)] = B[mad24(p, LOCAL_SIZE, lidy)*STEP_B]; | |
| barrier(CLK_LOCAL_MEM_FENCE); | |
| if (x < D_cols && y < D_rows) | |
| { | |
| int ie = min(LOCAL_SIZE, n - p * LOCAL_SIZE); | |
| for (int i = 0; i < ie; ++i) | |
| for (int i = 0; i < LOCAL_SIZE; ++i) | |
| MUL(a_local[mad24(lidy, LOCAL_SIZE_ODD, i)], b_local[mad24(i, LOCAL_SIZE_ODD, lidx)]); | |
| } | |
| barrier(CLK_LOCAL_MEM_FENCE); | |
| } | |
| if (x < D_cols && y < D_rows) | |
| { | |
| __global WT* D = (__global WT*)(D_ptr + mad24(y, D_step, mad24(x, WTSIZE, D_offset))); | |
| D[0] = mad(alpha, sum, D[0]*beta); | |
| D[0] = alpha * sum; | |
| } | |
| } |