• 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 #include "include/registry/register_kernel_interface.h"
17 #include <set>
18 #include <utility>
19 #include "include/errorcode.h"
20 #include "src/common/log_adapter.h"
21 #include "src/registry/kernel_interface_registry.h"
22 
23 namespace mindspore {
24 namespace registry {
Reg(const std::string & provider,int op_type,const KernelInterfaceCreator creator)25 Status RegisterKernelInterface::Reg(const std::string &provider, int op_type, const KernelInterfaceCreator creator) {
26 #ifndef CUSTOM_KERNEL_REGISTRY_CLIP
27   return KernelInterfaceRegistry::Instance()->Reg(provider, op_type, creator);
28 #else
29   MS_LOG(ERROR) << unsupport_custom_kernel_register_log;
30   return kLiteNotSupport;
31 #endif
32 }
33 
CustomReg(const std::string & provider,const std::string & op_type,const KernelInterfaceCreator creator)34 Status RegisterKernelInterface::CustomReg(const std::string &provider, const std::string &op_type,
35                                           const KernelInterfaceCreator creator) {
36 #ifndef CUSTOM_KERNEL_REGISTRY_CLIP
37   return KernelInterfaceRegistry::Instance()->CustomReg(provider, op_type, creator);
38 #else
39   MS_LOG(ERROR) << unsupport_custom_kernel_register_log;
40   return kLiteNotSupport;
41 #endif
42 }
43 
GetKernelInterface(const std::string & provider,const schema::Primitive * primitive,const kernel::Kernel * kernel)44 std::shared_ptr<kernel::KernelInterface> RegisterKernelInterface::GetKernelInterface(const std::string &provider,
45                                                                                      const schema::Primitive *primitive,
46                                                                                      const kernel::Kernel *kernel) {
47 #ifndef CUSTOM_KERNEL_REGISTRY_CLIP
48   return KernelInterfaceRegistry::Instance()->GetKernelInterface(provider, primitive, kernel);
49 #else
50   MS_LOG(ERROR) << unsupport_custom_kernel_register_log;
51   return nullptr;
52 #endif
53 }
54 }  // namespace registry
55 }  // namespace mindspore
56