Imported Upstream version 1.18.0
[platform/core/ml/nnfw.git] / compiler / luci / import / src / CircleImportMetadata.h
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved
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 __LUCI_CIRCLE_IMPORT_METADATA_H__
18 #define __LUCI_CIRCLE_IMPORT_METADATA_H__
19
20 #include "luci/Import/CircleReader.h"
21
22 #include <luci/Profile/CircleNodeOrigin.h>
23 #include <luci/IR/ExecutionPlanTable.h>
24
25 #include <map>
26 #include <set>
27 #include <string>
28
29 namespace luci
30 {
31
32 using OriginTable = std::map<uint32_t, std::shared_ptr<CircleNodeOrigin>>;
33
34 class CircleImportMetadata
35 {
36 public:
37   CircleImportMetadata() = delete;
38
39   CircleImportMetadata(const luci::CircleReader &reader);
40
41 public:
42   /**
43    * @brief Create origin table using _source_table and _op_table in CircleImportMetadata
44    * @note  For creating origin table, both _op_table and _source_table should exist.
45    *        If one of them does not exist, empty table is returned.
46    */
47   const OriginTable origin_table(void);
48
49   const std::map<uint32_t, std::string> &source_table(void) const { return _source_table; }
50
51   const luci::ExecutionPlanTable &execution_plan_table(void) const { return _execution_plan_table; }
52
53 private:
54   // Decoded metadata is stored
55   std::map<uint32_t, std::string> _source_table;
56   std::map<uint32_t, std::set<uint32_t>> _op_table;
57   // _execution_plan_table stores for node with node_id order of execution,
58   // and offsets output tensors
59   luci::ExecutionPlanTable _execution_plan_table;
60 };
61
62 } // namespace luci
63
64 #endif // __LUCI_CIRCLE_IMPORT_METADATA_H__