1 /** 2 * Copyright 2021 Huawei Technologies Co., Ltd 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 MINDSPORE_LITE_MICRO_CODER_OPCODERS_KERNEL_REGISTER_H_ 18 #define MINDSPORE_LITE_MICRO_CODER_OPCODERS_KERNEL_REGISTER_H_ 19 20 #include <map> 21 #include <vector> 22 #include <string> 23 #include <set> 24 #include "coder/config.h" 25 #include "coder/opcoders/op_coder_register.h" 26 #include "ir/dtype/type_id.h" 27 #include "schema/ops_generated.h" 28 29 namespace mindspore::lite::micro { 30 31 constexpr char kCustomKernelName[] = "CustomKernel"; 32 constexpr char kCustomKernelParam[] = "CustomParameter"; 33 34 class KernelRegistry { 35 public: 36 KernelRegistry() = default; 37 38 static KernelRegistry *GetInstance(); 39 40 void RegisterKernel(schema::PrimitiveType op); 41 42 bool CheckRegistered(schema::PrimitiveType op); 43 44 bool HasKernelRegistered(); 45 46 std::string GenKernelInterface(const char *func, const char *param); 47 ~KernelRegistry()48 ~KernelRegistry() { registry_.clear(); } 49 50 private: 51 std::set<schema::PrimitiveType> registry_; 52 }; 53 } // namespace mindspore::lite::micro 54 55 #endif // MINDSPORE_LITE_MICRO_CODER_OPCODERS_KERNEL_REGISTER_H_ 56