• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "coder/opcoders/kernel_registry.h"
18 #include <set>
19 #include "schema/ops_generated.h"
20 
21 namespace mindspore::lite::micro {
GetInstance()22 KernelRegistry *KernelRegistry::GetInstance() {
23   static KernelRegistry reg;
24   return &reg;
25 }
26 
RegisterKernel(schema::PrimitiveType op)27 void KernelRegistry::RegisterKernel(schema::PrimitiveType op) { registry_.insert(op); }
28 
CheckRegistered(schema::PrimitiveType op)29 bool KernelRegistry::CheckRegistered(schema::PrimitiveType op) { return registry_.find(op) != registry_.end(); }
30 
HasKernelRegistered()31 bool KernelRegistry::HasKernelRegistered() { return !registry_.empty(); }
32 
GenKernelInterface(const char * func,const char * param)33 std::string KernelRegistry::GenKernelInterface(const char *func, const char *param) {
34   return "int " + std::string(func) + "(TensorC *inputs, int input_num, TensorC *outputs, int output_num, " +
35          std::string(param) + " *param);";
36 }
37 }  // namespace mindspore::lite::micro
38