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