2 // Copyright (c) 2019 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "roi_pooling_kernel_base.h"
19 namespace kernel_selector {
21 static ROIPoolingKernelBase::DispatchData SetDefault(const roi_pooling_params& params)
23 ROIPoolingKernelBase::DispatchData kd;
25 kd.fp16UnitUsed = (params.inputs[0].GetDType() == Datatype::F16);
27 // Determine global work sizes.
28 kd.gws0 = params.output.LogicalSize();
32 // Find largest positive local work size that is divider for global work size.
33 kd.lws0 = std::min(std::max(kd.gws0, static_cast<size_t>(1)), static_cast<size_t>(32));
34 while (kd.gws0 % kd.lws0 != 0)
44 JitConstants ROIPoolingKernelBase::GetJitConstants(const roi_pooling_params& rp) const
46 JitConstants jit = MakeBaseParamsJitConstants(rp);
49 MakeJitConstant("POOLED_HEIGHT", rp.pooledHeight),
50 MakeJitConstant("POOLED_WIDTH", rp.pooledWidth),
51 MakeJitConstant("SPATIAL_SCALE", rp.spatialScale),
52 MakeJitConstant(toString(rp.mode) + "_POOLING", 1),
58 KernelsData ROIPoolingKernelBase::GetCommonKernelsData(const Params& params, const optional_params& options, float estimatedTime) const
60 assert(params.GetType() == KernelType::ROI_POOLING);
61 const roi_pooling_params& orgParams = static_cast<const roi_pooling_params&>(params);
63 if (orgParams.activation.function != ActivationFunction::NONE)
68 DispatchData runInfo = SetDefault(orgParams);
69 KernelData kd = KernelData::Default<roi_pooling_params>(params);
71 auto cldnn_jit = GetJitConstants(orgParams);
72 auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options);
73 auto jit = CreateJit(kernelName, cldnn_jit, entry_point);
75 auto& kernel = kd.kernels[0];
76 FillCLKernelData(kernel, runInfo, params.engineInfo, kernelName, jit, entry_point);
77 kernel.arguments.push_back({ ArgumentDescriptor::Types::INPUT, 1 });
79 kd.estimatedTime = estimatedTime;