Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / actual_kernels / batch_norm / batch_norm_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 "common_kernel_base.h"
20 #include "kernel_selector_params.h"
21
22 namespace kernel_selector
23 {
24     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25     // batch_norm_params
26     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27     struct batch_norm_params : public base_params
28     {
29         batch_norm_params() : base_params(KernelType::BATCH_NORM_GRAD) {}
30
31         struct DedicatedParams
32         {
33             float epsilon;
34             bool with_inv_var;
35                         bool with_scale_shift;
36                         bool with_mean_var_out = false;
37         };
38
39         DedicatedParams batchNormParams;
40
41         virtual ParamsKey GetParamsKey() const
42         {
43             return base_params::GetParamsKey();
44         }
45     };
46
47     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
48     // batch_norm_optional_params
49     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
50     struct batch_norm_optional_params : optional_params
51     {
52         batch_norm_optional_params() : optional_params(KernelType::BATCH_NORM_GRAD) {}
53     };
54
55     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
56     // BatchNormKernelBase
57     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
58     class BatchNormKernelBase : public common_kernel_base
59     {
60     public:
61         using common_kernel_base::common_kernel_base;
62         virtual ~BatchNormKernelBase() {}
63
64         using DispatchData = CommonDispatchData;
65
66     protected:
67         virtual bool Validate(const Params& params, const optional_params& options) const override;
68         KernelsData GetCommonKernelsData(const Params& params, const optional_params&, float estimatedTime) const;
69         virtual JitConstants GetJitConstants(const batch_norm_params& params) const;
70         virtual DispatchData SetDefault(const batch_norm_params& params) const;
71     };
72 }