Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / kernel_selector / core / actual_kernels / pyramid_roi_align / pyramid_roi_align_kernel_base.cpp
1 // Copyright (c) 2018 Intel Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "pyramid_roi_align_kernel_base.h"
16 #include "kernel_selector_utils.h"
17
18 namespace kernel_selector {
19
20     JitConstants PyramidROIAlignKernelBase::GetJitConstants(const PyramidROIAlign_params& params)
21     {
22         JitConstants jit = MakeBaseParamsJitConstants(params);
23         return jit;
24     }
25
26     PyramidROIAlignKernelBase::DispatchData PyramidROIAlignKernelBase::SetDefault(const PyramidROIAlign_params& params)
27     {
28         const auto& boxes = params.inputs.at(0);
29         DispatchData kd;
30
31         kd.fp16UnitUsed = params.inputs[0].GetDType() == Datatype::F16;
32
33         std::vector<size_t> global;
34         global = { boxes.Y().v, 1, 1 };
35
36         const auto& local = GetOptimalLocalWorkGroupSizes(global);
37
38         kd.gws0 = global[0];
39         kd.gws1 = global[1];
40         kd.gws2 = global[2];
41
42         kd.lws0 = local[0];
43         kd.lws1 = local[1];
44         kd.lws2 = local[2];
45
46         return kd;
47     }
48
49     KernelsData PyramidROIAlignKernelBase::GetCommonKernelsData(const Params& params, const optional_params& options, float estimated_time) const
50     {
51         assert(params.GetType() == KernelType::PYRAMID_ROI_ALIGN);
52
53         const auto& prim_params = static_cast<const PyramidROIAlign_params&>(params); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
54         auto run_info = SetDefault(prim_params);
55         KernelData k_data = KernelData::Default<PyramidROIAlign_params>(params);
56         auto cldnn_jit = GetJitConstants(prim_params);
57         auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, options);
58         auto jit = CreateJit(kernelName, cldnn_jit, entry_point);
59
60         auto& kernel = k_data.kernels[0];
61         FillCLKernelData(kernel, run_info, params.engineInfo, kernelName, jit, entry_point, "", false, false, (uint32_t)prim_params.inputs.size());
62
63         k_data.estimatedTime = estimated_time;
64
65         return { k_data };
66     }
67 }