Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / cl_kernels / contract_ref.cl
1 // Copyright (c) 2019 Intel Corporation
2 //
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
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
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.
14
15 #include "include/include_all.cl"
16
17
18 KERNEL(contract_ref)(
19     const __global INPUT0_TYPE* input,
20     __global INPUT0_TYPE* output)
21 {
22     INPUT0_TYPE out_val = REDUCE_SEED;
23
24 #if REDUCE_B
25     for (uint in_b = 0; in_b < INPUT0_BATCH_NUM; ++in_b) {
26 #else
27     const uint in_b = (uint) get_global_id(DIM_B);
28 #endif
29
30 #if REDUCE_F
31     for (uint in_f = 0; in_f < INPUT0_FEATURE_NUM; ++in_f) {
32 #else
33     const uint in_f = (uint) get_global_id(DIM_F);
34 #endif
35
36 #if REDUCE_Y
37     for (uint in_y = 0; in_y < INPUT0_SIZE_Y; ++in_y) {
38 #else
39     const uint in_y = (uint) get_global_id(DIM_Y);
40 #endif
41
42 #if REDUCE_X
43     for (uint in_x = 0; in_x < INPUT0_SIZE_X; ++in_x) {
44 #else
45     const uint in_x = (uint) get_global_id(DIM_X);
46 #endif
47
48     out_val = REDUCE_OPERATION(out_val, input[GET_DATA_INDEX(INPUT0, in_b, in_f, in_y, in_x)]);
49
50 #if REDUCE_X
51     }
52 #endif
53 #if REDUCE_Y
54     }
55 #endif
56 #if REDUCE_F
57     }
58 #endif
59 #if REDUCE_B
60     }
61 #endif
62
63     output[GET_DATA_INDEX(OUTPUT, 0, get_global_id(0), get_global_id(1), get_global_id(2))] = out_val;
64 }