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 "select_inst.h"
18 #include "primitive_gpu_base.h"
19 #include "implementation_map.h"
20 #include "error_handler.h"
21 #include "kernel_selector_helper.h"
22 #include "select/select_kernel_selector.h"
23 #include "select/select_kernel_base.h"
28 struct select_gpu : typed_primitive_gpu_impl<select> {
29 using parent = typed_primitive_gpu_impl<select>;
33 static primitive_impl* create(const select_node& arg) {
34 auto select_params = get_default_params<kernel_selector::select_params>(arg);
35 auto select_optional_params =
36 get_default_optional_params<kernel_selector::select_optional_params>(arg.get_program());
38 for (size_t i = 1; i < arg.inputs_count(); i++) {
39 select_params.inputs.push_back(convert_data_tensor(arg.input(i).get_output_layout()));
42 auto& kernel_selector = kernel_selector::select_kernel_selector::Instance();
43 auto best_kernels = kernel_selector.GetBestKernels(select_params, select_optional_params);
45 CLDNN_ERROR_BOOL(arg.id(),
46 "Best_kernel.empty()",
48 "Cannot find a proper kernel with this arguments");
50 auto select = new select_gpu(arg, best_kernels[0]);
59 implementation_map<select>::add(
60 {{std::make_tuple(engine_types::ocl, data_types::f32, format::yxfb), select_gpu::create},
61 {std::make_tuple(engine_types::ocl, data_types::f16, format::yxfb), select_gpu::create},
62 {std::make_tuple(engine_types::ocl, data_types::i8, format::yxfb), select_gpu::create},
63 {std::make_tuple(engine_types::ocl, data_types::u8, format::yxfb), select_gpu::create},
65 {std::make_tuple(engine_types::ocl, data_types::f32, format::bfyx), select_gpu::create},
66 {std::make_tuple(engine_types::ocl, data_types::f16, format::bfyx), select_gpu::create},
67 {std::make_tuple(engine_types::ocl, data_types::i8, format::bfyx), select_gpu::create},
68 {std::make_tuple(engine_types::ocl, data_types::u8, format::bfyx), select_gpu::create},
70 {std::make_tuple(engine_types::ocl, data_types::f32, format::byxf), select_gpu::create},
71 {std::make_tuple(engine_types::ocl, data_types::f16, format::byxf), select_gpu::create},
72 {std::make_tuple(engine_types::ocl, data_types::i8, format::byxf), select_gpu::create},
73 {std::make_tuple(engine_types::ocl, data_types::u8, format::byxf), select_gpu::create}});