Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / actual_kernels / roi_pooling / roi_pooling_kernel_base.h
1 /*
2 // Copyright (c) 2019 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 <iostream>
20 #include "common_kernel_base.h"
21
22 namespace kernel_selector
23 {
24     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25     // roi_pooling_params
26     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27     struct roi_pooling_params : public base_params
28     {
29         roi_pooling_params() : base_params(KernelType::ROI_POOLING) {}
30
31         PoolType    mode = PoolType::MAX;
32         bool        position_sensitive = false;
33         int         pooledWidth = 0;
34         int         pooledHeight = 0;
35         int         spatial_bins_x = 1;
36         int         spatial_bins_y = 1;
37         float       spatialScale = 1.f;
38
39         virtual ParamsKey GetParamsKey() const
40         {
41             auto k = base_params::GetParamsKey();
42             if (position_sensitive)
43             {
44                 k.EnablePositionSensitivePooling();
45             }
46             k.EnablePoolType(mode);
47
48             return k;
49         }
50     };
51
52     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
53     // roi_pooling_optional_params
54     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
55     struct roi_pooling_optional_params : optional_params
56     {
57         roi_pooling_optional_params() : optional_params(KernelType::ROI_POOLING) {}
58     };
59
60     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
61     // ROIPoolingKernelBase
62     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
63     class ROIPoolingKernelBase : public common_kernel_base
64     {
65     public:
66         using common_kernel_base::common_kernel_base;
67         virtual ~ROIPoolingKernelBase() {};
68
69         using DispatchData = CommonDispatchData;
70
71         KernelsData GetCommonKernelsData(const Params& params, const optional_params& options, float estimatedTime) const;
72     protected:
73         virtual JitConstants GetJitConstants(const roi_pooling_params& params) const;
74     };
75 }