2 // Copyright (c) 2016 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.
19 #include "kernel_selector_common.h"
20 #include "kernel_selector_params.h"
21 #include "primitive_db.h"
23 namespace kernel_selector
25 using primitive_db = kernel_selector::gpu::cache::primitive_db;
30 KernelBase(const std::string name) : kernelName(name) {}
31 virtual ~KernelBase() {}
33 virtual KernelsData GetKernelsData(const Params& params, const optional_params& options) const = 0;
34 virtual KernelsData GetKernelsDataForAutoTune(const Params& params, const optional_params& options) const
36 return GetKernelsData(params, options);
38 virtual KernelsData GetTunedKernelsDataByIndex(const Params& params, const optional_params& options, int /*autoTuneIndex*/) const
40 return GetKernelsData(params, options);
43 virtual bool Supports(const Params& params, const optional_params& options) const
45 const ParamsKey requireKey = params.GetParamsKey().Merge(options.GetSupportedKey());
46 return GetSupportedKey().Support(requireKey);
49 bool SupportsTuning() const
51 return GetSupportedKey().TuningSupport();
54 virtual const std::string GetName() const { return kernelName; }
56 static const primitive_db& get_db() { return db; }
59 static const primitive_db db;
60 const std::string kernelName;
62 static size_t UniqeID() { return counter++; } // TODO: use interlocked
63 virtual ParamsKey GetSupportedKey() const = 0;
66 static size_t counter;