mxnet
packed_func_ext.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
25 #ifndef NNVM_COMPILER_PACKED_FUNC_EXT_H_
26 #define NNVM_COMPILER_PACKED_FUNC_EXT_H_
27 
28 #include <tvm/runtime/packed_func.h>
29 #include <tvm/runtime/registry.h>
30 #include <nnvm/graph.h>
31 #include <nnvm/symbolic.h>
32 #include <string>
33 #include <vector>
34 #include <unordered_map>
35 
36 namespace nnvm {
37 namespace compiler {
38 
39 using tvm::runtime::PackedFunc;
40 
41 using AttrDict = std::unordered_map<std::string, std::string>;
42 
49 inline const PackedFunc& GetPackedFunc(const std::string& name) {
50  const PackedFunc* pf = tvm::runtime::Registry::Get(name);
51  CHECK(pf != nullptr) << "Cannot find function " << name << " in registry";
52  return *pf;
53 }
54 } // namespace compiler
55 } // namespace nnvm
56 
57 // Enable the graph and symbol object exchange.
58 namespace tvm {
59 namespace runtime {
60 
61 template<>
62 struct extension_type_info<nnvm::Symbol> {
63  static const int code = 16;
64 };
65 
66 template<>
67 struct extension_type_info<nnvm::Graph> {
68  static const int code = 17;
69 };
70 
71 template<>
72 struct extension_type_info<nnvm::compiler::AttrDict> {
73  static const int code = 18;
74 };
75 
76 } // namespace runtime
77 } // namespace tvm
78 #endif // NNVM_COMPILER_PACKED_FUNC_EXT_H_
Definition: base.h:36
Definition: packed_func_ext.h:58
Configuation of nnvm as well as basic data structure.
Symbolic graph construction API.
const PackedFunc & GetPackedFunc(const std::string &name)
Get PackedFunction from global registry and report error if it does not exist.
Definition: packed_func_ext.h:49
std::unordered_map< std::string, std::string > AttrDict
Definition: packed_func_ext.h:41