1 // Copyright (c) 2017 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 #include "include/include_all.cl"
18 KERNEL (permute_ref)(const __global UNIT_TYPE* input, __global UNIT_TYPE* output)
20 uint4 input_indices, output_indices;
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;
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]];
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]);
39 output[output_offset] = ACTIVATION(input[input_offset], NL_M, NL_N);