Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / actual_kernels / convolution / convolution_kernel_bfyx_depthwise_weights_lwg.cpp
1 /*
2 // Copyright (c) 2018 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 "convolution_kernel_bfyx_depthwise_weights_lwg.h"
18
19 namespace kernel_selector 
20 {
21     ParamsKey ConvolutionKernel_bfyx_depthwise_weights_lwg::GetSupportedKey() const
22     {
23         ParamsKey k;
24         k.EnableInputDataType(Datatype::F32);
25         k.EnableInputDataType(Datatype::F16);
26         k.EnableInputWeightsType(WeightsType::F16);
27         k.EnableInputWeightsType(WeightsType::F32);
28         k.EnableOutputDataType(Datatype::F32);
29         k.EnableOutputDataType(Datatype::F16);
30         k.EnableInputLayout(DataLayout::bfyx);
31         k.EnableOutputLayout(DataLayout::bfyx);
32         k.EnableTensorOffset();
33         k.EnableTensorPitches();
34         k.EnableBiasPerFeature();
35         k.EnableNonBiasTerm();
36         k.EnableBatching();
37         k.EnableSplitSupport();
38         k.EnableSubGroup();
39         k.EnableSubGroupShort();
40         k.EnableDepthwiseSeparableOpt();
41         k.EnableDilation();
42         return k;
43     }
44
45     bool ConvolutionKernel_bfyx_depthwise_weights_lwg::Validate(const Params& p, const optional_params& o) const
46     {
47         if (!ConvolutionKernelBase::Validate(p, o) ||
48             !CovolutionCheckInput(p, o))
49         {
50             return false;
51         }
52
53        const convolution_params& cp = static_cast<const convolution_params&>(p);
54        if (!cp.depthwise_separable_opt)
55            return false;
56        if ((cp.filterSize.x > 4) ||
57            (cp.filterSize.y > 4) ||
58            ((cp.inputs[0].Feature().v != cp.split) && (cp.inputs[0].Feature().v != cp.groups)))
59        {
60            return false;
61        }
62
63         return true;
64     }
65
66     ConvolutionKernelBase::DispatchData ConvolutionKernel_bfyx_depthwise_weights_lwg::SetDefault(const convolution_params& params, int) const
67     {
68         DispatchData runInfo = Parent::SetDefault(params);
69         const auto& out = params.output;
70
71         std::vector<size_t> global = { out.X().v * out.Y().v, out.Feature().v, out.Batch().v };
72
73         runInfo.gws0 = Align(global[0], 16);
74         runInfo.gws1 = global[1];
75         runInfo.gws2 = global[2];
76         runInfo.lws0 = 16;
77         runInfo.lws1 = 1;
78         runInfo.lws2 = 1;
79
80         runInfo.effiency = FORCE_PRIORITY_6;
81
82         return runInfo;
83     }
84
85     JitConstants ConvolutionKernel_bfyx_depthwise_weights_lwg::GetJitConstants(const convolution_params& params, const DispatchData& kd) const
86     {
87         auto mem_consts = ConvolutionKernelBase::GetJitConstants(params, kd);
88
89         if(params.padding.x != 0 || params.padding.y != 0)
90             mem_consts.AddConstant(MakeJitConstant("BOUNDARY_CHECK", 1));
91
92         return mem_consts;
93     }
94
95     KernelsData ConvolutionKernel_bfyx_depthwise_weights_lwg::GetKernelsData(const Params& params, const optional_params& options) const
96     {
97         return GetTunedKernelsDataByIndex(params, options);
98     }
99 }