Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / actual_kernels / deconvolution / deconvolution_kernel_base.h
1 /*
2 // Copyright (c) 2016 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 #pragma once
18
19 #include "weight_bias_kernel_base.h"
20 #include "kernel_selector_params.h"
21
22 namespace kernel_selector 
23 {
24     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25     // deconvolution_params
26     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27     struct deconvolution_params : public weight_bias_params
28     {
29         deconvolution_params() : weight_bias_params(KernelType::DECONVOLUTION) {}
30
31         uSize    filterSize;
32         uSize    stride;
33         uSize    dilation;
34         uSize    padding;
35         uint32_t split = 1;
36         uint32_t groups = 1;
37         bool     depthwise_separable_opt = false;
38         bool     fused_eltwise = false;
39
40         virtual std::string to_string() const override;
41
42         virtual ParamsKey GetParamsKey() const override
43         {
44             ParamsKey k = weight_bias_params::GetParamsKey();
45
46             if (split > 1)
47             {
48                 k.EnableSplitSupport();
49             }
50
51             if (dilation.x != 1 ||
52                 dilation.y != 1)
53             {
54                 k.EnableDilation();
55             }
56
57             if (depthwise_separable_opt)
58             {
59                 k.EnableDepthwiseSeparableOpt();
60             }
61
62             if (groups > 1 && !depthwise_separable_opt)
63             {
64                 k.EnableGroupedConvolution();
65             }
66
67             return k;
68         }
69     };
70
71     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
72     // deconvolution_optional_params
73     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
74     struct deconvolution_optional_params : weight_bias_optional_params
75     {
76         deconvolution_optional_params() : weight_bias_optional_params(KernelType::DECONVOLUTION) {}
77     };
78
79     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
80     // DeconvolutionKernelBase
81     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
82     class DeconvolutionKernelBase : public WeightBiasKernelBase
83     {
84     public:
85         using WeightBiasKernelBase::WeightBiasKernelBase;
86         virtual ~DeconvolutionKernelBase() {}
87
88         using DispatchData = CommonDispatchData;
89     
90     protected:
91         virtual KernelsData GetKernelsData(const Params& params, const optional_params& options) const;
92         virtual JitConstants GetJitConstants(const deconvolution_params& params) const;
93         virtual DispatchData SetDefault(const deconvolution_params& params) const;
94     };
95 }