1 | /******************************************************************************* |
2 | * Copyright 2020 Intel Corporation |
3 | * |
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 |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
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. |
15 | *******************************************************************************/ |
16 | |
17 | #ifndef GPU_COMPUTE_KERNEL_LIST_HPP |
18 | #define GPU_COMPUTE_KERNEL_LIST_HPP |
19 | |
20 | #include <cassert> |
21 | #include <unordered_map> |
22 | |
23 | #include "gpu/compute/kernel.hpp" |
24 | |
25 | namespace dnnl { |
26 | namespace impl { |
27 | namespace gpu { |
28 | namespace compute { |
29 | |
30 | class kernel_list_t { |
31 | public: |
32 | void add(const char *name, kernel_t *kernel) { |
33 | assert(kernels_.count(name) == 0); |
34 | kernels_[name] = kernel; |
35 | } |
36 | |
37 | void set(const char *name, const kernel_t &kernel) { |
38 | assert(kernels_.count(name) > 0); |
39 | *kernels_[name] = kernel; |
40 | } |
41 | |
42 | const std::unordered_map<std::string, kernel_t *> &kernels() const { |
43 | return kernels_; |
44 | } |
45 | |
46 | private: |
47 | std::unordered_map<std::string, kernel_t *> kernels_; |
48 | }; |
49 | |
50 | } // namespace compute |
51 | } // namespace gpu |
52 | } // namespace impl |
53 | } // namespace dnnl |
54 | |
55 | #endif // GPU_COMPUTE_KERNEL_LIST_HPP |
56 | |