Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / cl_kernels / embed_ref.cl
1 // Copyright (c) 2018 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 KERNEL(embed_ref)(const __global UNIT_TYPE* input0,
18     __global UNIT_TYPE* output,
19     const __global UNIT_TYPE* weights
20 #if BIAS_TERM
21     ,const __global UNIT_TYPE* biases
22 #endif
23 )
24 {
25     const uint x = (uint)get_global_id(0);
26         const uint y = (uint)get_global_id(1);
27         const uint b = (uint)get_global_id(2);
28
29         uint output_idx = (b*INPUT0_ELEMENTS_COUNT*NUM_OUTPUT_SIZE)+(uint)(x*NUM_OUTPUT_SIZE+y);
30     output[output_idx] = weights[(uint)(input0[(b*INPUT0_ELEMENTS_COUNT)+x]*NUM_OUTPUT_SIZE+y)];
31 #if BIAS_TERM
32     output[output_idx] += biases[y];
33 #endif
34 }