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 "depth_to_space_kernel_ref.h"
18 #include "kernel_selector_utils.h"
20 namespace kernel_selector
22 ParamsKey DepthToSpaceKernelRef::GetSupportedKey() const
25 k.EnableInputDataType(Datatype::F16);
26 k.EnableInputDataType(Datatype::F32);
27 k.EnableOutputDataType(Datatype::F16);
28 k.EnableOutputDataType(Datatype::F32);
29 k.EnableAllInputLayout();
30 k.EnableAllOutputLayout();
31 k.EnableTensorOffset();
32 k.EnableTensorPitches();
37 CommonDispatchData DepthToSpaceKernelRef::SetDefault(const depth_to_space_params& params, const optional_params&) const
39 CommonDispatchData runInfo;
41 std::vector<size_t> global = { params.output.Batch().v, params.output.Feature().v, params.output.Y().v * params.output.X().v };
43 auto local = GetOptimalLocalWorkGroupSizes(global);
45 runInfo.gws0 = global[0];
46 runInfo.gws1 = global[1];
47 runInfo.gws2 = global[2];
49 runInfo.lws0 = local[0];
50 runInfo.lws1 = local[1];
51 runInfo.lws2 = local[2];
56 JitConstants DepthToSpaceKernelRef::GetJitConstants(const depth_to_space_params& params) const
58 JitConstants jit = MakeBaseParamsJitConstants(params);
60 jit.AddConstant(MakeJitConstant("BLOCK_SIZE", params.block_size));
65 KernelsData DepthToSpaceKernelRef::GetKernelsData(const Params& params, const optional_params& options) const
67 KernelData kd = KernelData::Default<depth_to_space_params>(params);
68 depth_to_space_params& newParams = *static_cast<depth_to_space_params*>(kd.params.get());
70 assert(params.GetType() == KernelType::DEPTH_TO_SPACE);
72 auto runInfo = SetDefault(newParams, options);
73 auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options);
74 auto cldnn_jit = GetJitConstants(newParams);
75 std::string jit = CreateJit(kernelName, cldnn_jit, entry_point);
77 auto& kernel = kd.kernels[0];
79 FillCLKernelData(kernel, runInfo, params.engineInfo, kernelName, jit, entry_point);
81 kd.estimatedTime = DONT_USE_IF_HAVE_SOMETHING_ELSE;