Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / cl_kernels / permute_ref.cl
1 // Copyright (c) 2017 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 (permute_ref)(const __global UNIT_TYPE* input, __global UNIT_TYPE* output)
19 {
20     uint4 input_indices, output_indices;
21     
22     //gws(y, x, b*f)
23     //input_indices[b, f, x, y]
24     input_indices[3] = get_global_id(0); 
25     input_indices[2] = get_global_id(1);
26     input_indices[1] = get_global_id(2) % INPUT0_FEATURE_NUM;
27     input_indices[0] = get_global_id(2) / INPUT0_FEATURE_NUM;
28     
29     //PERMUTE_ORDER[b, f, x, y]
30     //output_indices[b, f, x, y]
31     output_indices[0] = input_indices[PERMUTE_ORDER[0]];
32     output_indices[1] = input_indices[PERMUTE_ORDER[1]];
33     output_indices[2] = input_indices[PERMUTE_ORDER[2]];
34     output_indices[3] = input_indices[PERMUTE_ORDER[3]];
35     
36     uint input_offset =  GET_DATA_INDEX(INPUT0, input_indices[0], input_indices[1], input_indices[3], input_indices[2]);
37     uint output_offset = GET_DATA_INDEX(OUTPUT, output_indices[0], output_indices[1], output_indices[3], output_indices[2]);
38
39     output[output_offset] = ACTIVATION(input[input_offset], NL_M, NL_N);
40 }