Download modules/core/src/opencl/meanstddev.cl from tgollogly/test: direct link, hf CLI and curl.
- Browser
- Download file 3.79 kB
-
https://huggingface.co/tgollogly/test/resolve/main/modules/core/src/opencl/meanstddev.cl
- Command line
-
hf download hf://tgollogly/test/modules/core/src/opencl/meanstddev.cl
-
curl -L -o meanstddev.cl https://huggingface.co/tgollogly/test/resolve/main/modules/core/src/opencl/meanstddev.cl
3.79 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 meanStdDev(__global const uchar * srcptr, int src_step, int src_offset, int cols, | |
| int total, int groups, __global uchar * dstptr | |
| , __global const uchar * mask, int mask_step, int mask_offset | |
| ) | |
| { | |
| int lid = get_local_id(0); | |
| int gid = get_group_id(0); | |
| int id = get_global_id(0); | |
| __local dstT localMemSum[WGS2_ALIGNED]; | |
| __local sqdstT localMemSqSum[WGS2_ALIGNED]; | |
| __local int localMemNonZero[WGS2_ALIGNED]; | |
| dstT accSum = (dstT)(0); | |
| sqdstT accSqSum = (sqdstT)(0); | |
| int accNonZero = 0; | |
| mask += mask_offset; | |
| srcptr += src_offset; | |
| for (int grain = groups * WGS; id < total; id += grain) | |
| { | |
| int mask_index = id; | |
| int mask_index = mad24(id / cols, mask_step, id % cols); | |
| if (mask[mask_index]) | |
| { | |
| int src_index = id * srcTSIZE; | |
| int src_index = mad24(id / cols, src_step, mul24(id % cols, srcTSIZE)); | |
| srcT value = loadpix(srcptr + src_index); | |
| accSum += convertToDT(value); | |
| sqdstT dvalue = convertToSDT(value); | |
| accSqSum = fma(dvalue, dvalue, accSqSum); | |
| ++accNonZero; | |
| } | |
| } | |
| if (lid < WGS2_ALIGNED) | |
| { | |
| localMemSum[lid] = accSum; | |
| localMemSqSum[lid] = accSqSum; | |
| localMemNonZero[lid] = accNonZero; | |
| } | |
| barrier(CLK_LOCAL_MEM_FENCE); | |
| if (lid >= WGS2_ALIGNED && total >= WGS2_ALIGNED) | |
| { | |
| localMemSum[lid - WGS2_ALIGNED] += accSum; | |
| localMemSqSum[lid - WGS2_ALIGNED] += accSqSum; | |
| localMemNonZero[lid - WGS2_ALIGNED] += accNonZero; | |
| } | |
| barrier(CLK_LOCAL_MEM_FENCE); | |
| for (int lsize = WGS2_ALIGNED >> 1; lsize > 0; lsize >>= 1) | |
| { | |
| if (lid < lsize) | |
| { | |
| int lid2 = lsize + lid; | |
| localMemSum[lid] += localMemSum[lid2]; | |
| localMemSqSum[lid] += localMemSqSum[lid2]; | |
| localMemNonZero[lid] += localMemNonZero[lid2]; | |
| } | |
| barrier(CLK_LOCAL_MEM_FENCE); | |
| } | |
| if (lid == 0) | |
| { | |
| storepix(localMemSum[0], dstptr + dstTSIZE * gid); | |
| storesqpix(localMemSqSum[0], dstptr + mad24(dstTSIZE, groups, sqdstTSIZE * gid)); | |
| *(__global int *)(dstptr + mad24(dstTSIZE + sqdstTSIZE, groups, (int)sizeof(int) * gid)) = localMemNonZero[0]; | |
| } | |
| } | |