Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / actual_kernels / concatenation / concatenation_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 "common_kernel_base.h"
20 #include "kernel_selector_params.h"
21
22 namespace kernel_selector 
23 {
24     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25     // concatenation_params
26     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27     struct concatenation_params : public base_params
28     {
29         concatenation_params() : base_params(KernelType::CONCATENATION) {}
30
31         ConcatAxis axis = ConcatAxis::FEATURE;
32
33         virtual ParamsKey GetParamsKey() const
34         {
35             auto k = base_params::GetParamsKey();
36             k.EnableConcatAxis(axis);
37             return k;
38         }
39     };
40
41     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
42     // concatenation_optional_params
43     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
44     struct concatenation_optional_params : optional_params
45     {
46         concatenation_optional_params() : optional_params(KernelType::CONCATENATION) {}
47         bool kernelPerInput = true;
48
49
50     protected:
51         virtual ParamsKey GetSupportedKey() const
52         {
53             ParamsKey k = optional_params::GetSupportedKey();
54
55             if (kernelPerInput)
56             {
57                 k.EnableConcatKernelPerInput();
58             }
59             else
60             {
61                 k.EnableConcatOneKernel();
62             }
63
64             return k;
65         }
66     };
67
68     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
69     // ConcatenationKernelBase
70     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
71     class ConcatenationKernelBase : public common_kernel_base
72     {
73     public:
74         using common_kernel_base::common_kernel_base;
75         virtual ~ConcatenationKernelBase() {}
76
77         using DispatchData = CommonDispatchData;
78     
79     protected:
80         virtual bool Validate(const Params&, const optional_params&) const override;
81         virtual JitConstants GetJitConstants(const concatenation_params& params) const;
82         virtual DispatchData SetDefault(const concatenation_params& params) const;
83         KernelsData GetCommonKernelsData(const Params& params, const optional_params&) const;
84     };
85 }