ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Reader.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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 __MIO_CIRCLE07_READER_H__
18#define __MIO_CIRCLE07_READER_H__
19
20#include <mio/circle/schema_generated.h>
21
22#include <map>
23#include <string>
24#include <vector>
25
26// NOTE Reader class originated from circledump and for circle-tensordump
27// where this class has more work to be done for stability
28// as the tools are for developers not customores.
29
30namespace mio
31{
32namespace circle
33{
34
38class Reader
39{
40private:
47
48public:
49 Reader(const ::circle::Model *model);
50
51 Reader() = delete;
52
53public:
54 uint32_t version() const { return _version; }
55
56 const std::vector<const ::circle::OperatorCode *> &opcodes() { return _op_codes; }
57 const CircleBuffers_t *buffers() { return _buffers; }
58 const CircleTensors_t *tensors() { return _tensors; }
59 const CircleOperators_t *operators() { return _operators; }
60 const std::vector<int32_t> &inputs() const { return _inputs; }
61 const std::vector<int32_t> &outputs() const { return _outputs; }
62 const CircleMetadata_t *metadata() const { return _metadata; }
63 const CircleSignatureDef_t *signature_defs() const { return _signature_defs; }
64
65 uint32_t num_subgraph() const { return _subgraphs->size(); }
66
67 size_t buffer_info(uint32_t buf_idx, const uint8_t **buff_data);
68 ::circle::BuiltinOperator builtin_code(const ::circle::Operator *op) const;
69 std::string opcode_name(const ::circle::Operator *op) const;
70 std::vector<int32_t> outputs(const ::circle::Operator *op) const;
71 std::string tensor_name(const ::circle::Tensor *tensor) const;
72 std::string tensor_dtype(const ::circle::Tensor *tensor) const;
73
74public:
75 bool select_subgraph(uint32_t subgraph);
76 const std::string &subgraph_name(void) const { return _subgraph_name; }
77 uint32_t subgraph_index(void) const { return _subgraph_index; }
78
79private:
80 uint32_t _version;
81
82 const CircleSubGraphs_t *_subgraphs{nullptr};
83 const CircleBuffers_t *_buffers{nullptr};
84 const CircleTensors_t *_tensors{nullptr};
85 const CircleOperators_t *_operators{nullptr};
86 const CircleMetadata_t *_metadata{nullptr};
87 const CircleSignatureDef_t *_signature_defs{nullptr};
88
89 uint32_t _subgraph_index = 0;
90 std::string _subgraph_name;
91 std::vector<const ::circle::OperatorCode *> _op_codes;
92 std::vector<int32_t> _inputs;
93 std::vector<int32_t> _outputs;
94};
95
96} // namespace circle
97} // namespace mio
98
99#endif // __MIO_CIRCLE07_READER_H__
uoffset_t size() const
::circle::BuiltinOperator builtin_code(const ::circle::Operator *op) const
const std::vector< const ::circle::OperatorCode * > & opcodes()
Definition Reader.h:56
const CircleTensors_t * tensors()
Definition Reader.h:58
std::string opcode_name(const ::circle::Operator *op) const
uint32_t num_subgraph() const
Definition Reader.h:65
const std::vector< int32_t > & outputs() const
Definition Reader.h:61
const CircleBuffers_t * buffers()
Definition Reader.h:57
const CircleOperators_t * operators()
Definition Reader.h:59
std::string tensor_name(const ::circle::Tensor *tensor) const
uint32_t subgraph_index(void) const
Definition Reader.h:77
uint32_t version() const
Definition Reader.h:54
size_t buffer_info(uint32_t buf_idx, const uint8_t **buff_data)
std::string tensor_dtype(const ::circle::Tensor *tensor) const
Reader(const ::circle::Model *model)
const CircleSignatureDef_t * signature_defs() const
Definition Reader.h:63
const std::vector< int32_t > & inputs() const
Definition Reader.h:60
std::vector< int32_t > outputs(const ::circle::Operator *op) const
const CircleMetadata_t * metadata() const
Definition Reader.h:62
const std::string & subgraph_name(void) const
Definition Reader.h:76
bool select_subgraph(uint32_t subgraph)
Definition Helper.h:23