2 // Copyright (c) 2018 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 "lookup_table_kernel_base.h"
19 namespace kernel_selector
21 bool LookUpTableKernelBase::Validate(const Params& p, const optional_params& o) const
23 if (p.GetType() != KernelType::LOOKUP_TABLE ||
24 o.GetType() != KernelType::LOOKUP_TABLE)
32 JitConstants LookUpTableKernelBase::GetJitConstants(const lookup_table_params& params) const
34 JitConstants jit = MakeBaseParamsJitConstants(params);
37 MakeJitConstant("VAL_NUM", params.numberOfValues),
38 MakeJitConstant(toString(params.lookUpTableAxis) + "_AXIS", 1),
44 LookUpTableKernelBase::DispatchData LookUpTableKernelBase::SetDefault(const lookup_table_params& params) const
48 kd.fp16UnitUsed = params.inputs[0].GetDType() == Datatype::F16;
50 // Determine global work sizes.
51 kd.gws0 = params.inputIndices.X().v;
52 kd.gws1 = params.inputIndices.Batch().v; // B
55 kd.lws0 = std::min(std::max(kd.gws0, static_cast<size_t>(1)), static_cast<size_t>(32));
56 while (kd.gws0 % kd.lws0 != 0)
66 KernelsData LookUpTableKernelBase::GetCommonKernelsData(const Params& params, const optional_params& options, float estimatedTime) const
68 if (!Validate(params, options))
73 const lookup_table_params& orgParams = static_cast<const lookup_table_params&>(params);
75 DispatchData runInfo = SetDefault(orgParams);
77 KernelData kd = KernelData::Default<lookup_table_params>(params);
79 auto cldnn_jit = GetJitConstants(orgParams);
80 auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options);
81 auto jit = CreateJit(kernelName, cldnn_jit, entry_point);
83 auto& kernel = kd.kernels[0];
84 FillCLKernelData(kernel, runInfo, kernelName, jit, entry_point, "", false, false, 2);
86 kd.estimatedTime = estimatedTime;