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 | |
20 | /*! |
21 | * \file meta_data.h |
22 | * \brief Meta data related utilities |
23 | */ |
24 | #ifndef TVM_RUNTIME_META_DATA_H_ |
25 | #define TVM_RUNTIME_META_DATA_H_ |
26 | |
27 | #include <dmlc/io.h> |
28 | #include <dmlc/json.h> |
29 | #include <tvm/runtime/executor_info.h> |
30 | #include <tvm/runtime/metadata.h> |
31 | #include <tvm/runtime/module.h> |
32 | #include <tvm/runtime/ndarray.h> |
33 | #include <tvm/runtime/packed_func.h> |
34 | |
35 | #include <string> |
36 | #include <unordered_map> |
37 | #include <utility> |
38 | #include <vector> |
39 | |
40 | #include "runtime_base.h" |
41 | |
42 | namespace tvm { |
43 | namespace runtime { |
44 | |
45 | inline String get_name_mangled(const String& module_name, const String& name) { |
46 | std::stringstream ss; |
47 | ICHECK(module_name.defined()); |
48 | ICHECK(name.defined()); |
49 | ss << module_name << "_" << name; |
50 | return ss.str(); |
51 | } |
52 | |
53 | /*! |
54 | * \brief Create a metadata module object. |
55 | * |
56 | * \param metadata Exported metadata structure. |
57 | * |
58 | * \return The created metadata module. |
59 | */ |
60 | Module MetadataModuleCreate(metadata::Metadata metadata); |
61 | |
62 | namespace launch_param { |
63 | |
64 | /*! \brief A tag to specify whether or not dynamic shared memory is used */ |
65 | constexpr const char* kUseDynamicSharedMemoryTag = "tir.use_dyn_shared_memory" ; |
66 | |
67 | } // namespace launch_param |
68 | |
69 | /*! \brief function information needed by device */ |
70 | struct FunctionInfo { |
71 | std::string name; |
72 | std::vector<DLDataType> arg_types; |
73 | std::vector<std::string> launch_param_tags; |
74 | |
75 | void Save(dmlc::JSONWriter* writer) const; |
76 | void Load(dmlc::JSONReader* reader); |
77 | void Save(dmlc::Stream* writer) const; |
78 | bool Load(dmlc::Stream* reader); |
79 | }; |
80 | } // namespace runtime |
81 | } // namespace tvm |
82 | |
83 | namespace dmlc { |
84 | DMLC_DECLARE_TRAITS(has_saveload, ::tvm::runtime::FunctionInfo, true); |
85 | } // namespace dmlc |
86 | #endif // TVM_RUNTIME_META_DATA_H_ |
87 | |