Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / actual_kernels / pooling / pooling_kernel_gpu_b_fs_yx_fsv4.cpp
1 /*
2 // Copyright (c) 2019 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #include "pooling_kernel_gpu_b_fs_yx_fsv4.h"
18
19 namespace kernel_selector
20 {
21     ParamsKey PoolingKerneGPU_b_fs_yx_fsv4::GetSupportedKey() const
22     {
23         ParamsKey k;
24         k.EnableInputDataType(Datatype::INT8);
25         k.EnableInputDataType(Datatype::UINT8);
26         k.EnableOutputDataType(Datatype::INT8);
27         k.EnableOutputDataType(Datatype::UINT8);
28         k.EnableInputLayout(DataLayout::b_fs_yx_fsv4);
29         k.EnableOutputLayout(DataLayout::b_fs_yx_fsv4);
30         k.EnableOutputLayout(DataLayout::bfyx);
31         k.EnableTensorOffset();
32         k.EnableTensorPitches();
33         k.EnableBatching();
34         k.EnablePoolType(PoolType::MAX);
35         k.EnablePoolType(PoolType::AVG);
36         k.EnablePoolRemainder(PoolRemainder::FLOOR);
37         k.EnablePoolRemainder(PoolRemainder::CEIL);
38         k.EnablePoolKernelDividerMode(KernelDividerMode::FIXED);
39         k.EnablePoolKernelDividerMode(KernelDividerMode::DYNAMIC);
40         k.EnablePoolKernelDividerMode(KernelDividerMode::DYNAMIC_WITH_PADDING);
41         k.EnableDifferentTypes();
42         return k;
43     }
44
45     PoolingKernelBase::DispatchData PoolingKerneGPU_b_fs_yx_fsv4::SetDefault(const pooling_params& params) const
46     {
47         DispatchData runInfo = PoolingKernelBase::SetDefault(params);
48
49         runInfo.gws0 = params.output.X().v;   // X
50         runInfo.gws1 = params.output.Y().v;   // Y
51         // we got b_fs_yx_fsv4 format, we process 4 features per workitem
52         runInfo.gws2 = (params.output.Feature().v * params.output.Batch().v) / 4;
53
54         runInfo.lws0 = 1;
55         runInfo.lws1 = 1;
56         runInfo.lws2 = 1;
57
58         return runInfo;
59     }
60
61     JitConstants PoolingKerneGPU_b_fs_yx_fsv4::GetJitConstants(const pooling_params& params, DispatchData kd) const
62     {
63         auto jit = PoolingKernelBase::GetJitConstants(params, kd);
64
65         const size_t in_x_pitch = 4;
66         const size_t in_y_pitch = 4 * params.inputs[0].X().LogicalDimPadded();
67         jit.AddConstant(MakeJitConstant("IN_X_PITCH", in_x_pitch));
68         jit.AddConstant(MakeJitConstant("IN_Y_PITCH", in_y_pitch));
69
70         return jit;
71     }
72
73     KernelsData PoolingKerneGPU_b_fs_yx_fsv4::GetKernelsData(const Params& params, const optional_params& options) const
74     {
75         return GetCommonKernelsData(params, options, FORCE_PRIORITY_1);
76     }
77 }