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_CIRCLE06_READER_H__
18#define __MIO_CIRCLE06_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 ::circle::DataFormat &data_format() const { return _data_format; }
63 const CircleMetadata_t *metadata() const { return _metadata; }
64 const CircleSignatureDef_t *signature_defs() const { return _signature_defs; }
65
66 uint32_t num_subgraph() const { return _subgraphs->Length(); }
67
68 size_t buffer_info(uint32_t buf_idx, const uint8_t **buff_data);
69 ::circle::BuiltinOperator builtin_code(const ::circle::Operator *op) const;
70 std::string opcode_name(const ::circle::Operator *op) const;
71 std::vector<int32_t> outputs(const ::circle::Operator *op) const;
72 std::string tensor_name(const ::circle::Tensor *tensor) const;
73 std::string tensor_dtype(const ::circle::Tensor *tensor) const;
74
75public:
76 bool select_subgraph(uint32_t subgraph);
77 const std::string &subgraph_name(void) const { return _subgraph_name; }
78 uint32_t subgraph_index(void) const { return _subgraph_index; }
79
80private:
81 uint32_t _version;
82
83 const CircleSubGraphs_t *_subgraphs{nullptr};
84 const CircleBuffers_t *_buffers{nullptr};
85 const CircleTensors_t *_tensors{nullptr};
86 const CircleOperators_t *_operators{nullptr};
87 const CircleMetadata_t *_metadata{nullptr};
88 const CircleSignatureDef_t *_signature_defs{nullptr};
89
90 uint32_t _subgraph_index = 0;
91 std::string _subgraph_name;
92 std::vector<const ::circle::OperatorCode *> _op_codes;
93 std::vector<int32_t> _inputs;
94 std::vector<int32_t> _outputs;
95 ::circle::DataFormat _data_format = ::circle::DataFormat::DataFormat_CHANNELS_FIRST;
96};
97
98} // namespace circle
99} // namespace mio
100
101#endif // __MIO_CIRCLE06_READER_H__
::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:66
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:78
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:64
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:63
const std::string & subgraph_name(void) const
Definition Reader.h:77
const ::circle::DataFormat & data_format() const
Definition Reader.h:62
bool select_subgraph(uint32_t subgraph)
Definition Helper.h:23