• 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 #ifndef MINDSPORE_LITE_INCLUDE_REGISTRY_NODE_PARSER_REGISTRY_H_
18 #define MINDSPORE_LITE_INCLUDE_REGISTRY_NODE_PARSER_REGISTRY_H_
19 
20 #include <string>
21 #include "include/registry/node_parser.h"
22 
23 namespace mindspore {
24 namespace registry {
25 /// \brief NodeParserRegistry defined registration of NodeParser.
26 class MS_API NodeParserRegistry {
27  public:
28   /// \brief Constructor of NodeParserRegistry to register NodeParser.
29   ///
30   /// \param[in] fmk_type Define the framework.
31   /// \param[in] node_type Define the type of the node to be resolved.
32   /// \param[in] node_parser Define the NodeParser instance to parse the node.
33   NodeParserRegistry(converter::FmkType fmk_type, const std::string &node_type,
34                      const converter::NodeParserPtr &node_parser);
35 
36   /// \brief Destructor
37   ~NodeParserRegistry() = default;
38 
39   /// \brief Static method to obtain NodeParser instance of a certain node.
40   ///
41   /// \param[in] fmk_type Define the framework.
42   /// \param[in] node_type Define the type of the node to be resolved.
43   ///
44   /// \return NodeParser instance.
45   static converter::NodeParserPtr GetNodeParser(converter::FmkType fmk_type, const std::string &node_type);
46 };
47 
48 /// \brief Defined registering macro to register NodeParser instance.
49 ///
50 /// \param[in] fmk_type Define the framework.
51 /// \param[in] node_type Define the type of the node to be resolved.
52 /// \param[in] NodeParser instance corresponding with its framework and node type.
53 #define REG_NODE_PARSER(fmk_type, node_type, node_parser) \
54   static mindspore::registry::NodeParserRegistry g_##fmk_type##node_type##ParserReg(fmk_type, #node_type, node_parser);
55 }  // namespace registry
56 }  // namespace mindspore
57 
58 #endif  // MINDSPORE_LITE_INCLUDE_REGISTRY_NODE_PARSER_REGISTRY_H_
59