1 // Copyright (C) 2019 Intel Corporation
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
17 __kernel void grn_NCHW(__global const half* restrict src_data,
18 __global half* restrict dst_data,
22 int x = get_global_id(0);
23 int W = get_global_size(0);
25 int y = get_global_id(1);
26 int H = get_global_size(1);
28 float variance = bias + 1e-9f;
31 for (int c = 0; c < C; c++)
33 float val = (float)src_data[c*H*W + y*W + x];
34 variance += val * val;
37 variance = 1.f / native_sqrt(variance);
40 for (int c = 0; c < C; c++)
42 float val = (float)src_data[c*H*W + y*W + x];
43 dst_data[c*H*W + y*W + x] = (half)(val * variance);