Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / cl_kernels / gather_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
16 #include "include/include_all.cl"
17
18 KERNEL(gather_ref)(const __global UNIT_TYPE* dictionary, const __global float* indices, __global UNIT_TYPE* output)
19 {
20     const uint workItemId = get_global_id(0);
21
22     if (workItemId >= COMPUTATIONAL_OPERATIONS_NUMBER)
23         return;
24
25     uint partNumber = workItemId / INPUT1_LENGTH;
26     uint outputIndex = workItemId * SLICE_SIZE;
27     uint index = workItemId - (partNumber * INPUT1_LENGTH);
28
29     for (int k = 0; k < SLICE_SIZE; ++k)
30     {
31         output[outputIndex++] = dictionary[(partNumber * PART_SIZE) + ((uint) indices[index] * SLICE_SIZE) + k];
32     }
33 }