ONE - On-device Neural Engine
Loading...
Searching...
No Matches
circletensordump::DumpTensors Class Referencefinal

#include <Dump.h>

Collaboration diagram for circletensordump::DumpTensors:

Public Member Functions

 DumpTensors ()=default
 
void run (std::ostream &os, const circle::Model *model, const std::string &) override
 
- Public Member Functions inherited from circletensordump::DumpInterface
virtual ~DumpInterface ()=default
 

Detailed Description

Definition at line 37 of file Dump.h.

Constructor & Destructor Documentation

◆ DumpTensors()

circletensordump::DumpTensors::DumpTensors ( )
default

Member Function Documentation

◆ run()

void circletensordump::DumpTensors::run ( std::ostream &  os,
const circle::Model *  model,
const std::string &   
)
overridevirtual

Implements circletensordump::DumpInterface.

Definition at line 104 of file Dump.cpp.

105{
106 mio::circle::Reader reader(model);
107 uint32_t num_subgraph = reader.num_subgraph();
108 auto buffers = reader.buffers();
109
110 for (uint32_t subgraph_idx = 0; subgraph_idx < num_subgraph; subgraph_idx++)
111 {
112 reader.select_subgraph(subgraph_idx);
113
114 auto tensors = reader.tensors();
115 for (const auto &tensor : *tensors)
116 {
117 const auto tensor_name = tensor->name();
118 std::string tensor_name_str = tensor_name ? tensor_name->str() : "no_name";
119 os << std::string(70, '-') << std::endl;
120 os << "[" << tensor_name_str << "]" << std::endl;
121 auto buff_idx = tensor->buffer();
122 auto buff_data_ptr = reader.buffers()->Get(buff_idx)->data();
123 auto quant_param = tensor->quantization();
124 std::string print_format = (!buff_data_ptr && !quant_param) ? "└──" : "├──";
125
126 // shape
127 auto shape = tensor->shape();
128 os << " " + print_format + " shape : (";
129 ::print_comma_sepearted(os, shape);
130 os << ")" << std::endl;
131
132 // quantization paramters
133 if (quant_param)
134 {
135 std::string print_format1 = buff_data_ptr ? "├──" : "└──";
136 std::string print_format2 = buff_data_ptr ? "│" : " ";
137 os << " " + print_format1 + " quantization" << std::endl;
138 auto min = quant_param->min();
139 auto max = quant_param->max();
140 auto scale = quant_param->scale();
141 auto zero_point = quant_param->zero_point();
142 auto quantized_dimension = quant_param->quantized_dimension();
143
144 os << " " + print_format2 + "   ├── min : ";
145 ::print_comma_sepearted(os, min);
146 os << std::endl;
147 os << " " + print_format2 + "   ├── max : ";
148 ::print_comma_sepearted(os, max);
149 os << std::endl;
150 os << " " + print_format2 + "   ├── scale : ";
151 ::print_comma_sepearted(os, scale);
152 os << std::endl;
153 os << " " + print_format2 + "   ├── zero_point : ";
154 ::print_comma_sepearted(os, zero_point);
155 os << std::endl;
156 os << " " + print_format2 + "   └── quantized_dimension : " << quantized_dimension;
157 os << std::endl;
158 }
159
160 // buffer
161 print_buffer(os, buff_idx, buff_data_ptr, tensor->type());
162 os << std::endl;
163 }
164 }
165}
Loads Circle file and provides helpers to access attributes.
Definition Reader.h:39
const char * tensor_name(const circle::Tensor *tensor)

References mio::circle::Reader::buffers(), flatbuffers::Vector< T >::Get(), mio::circle::Reader::num_subgraph(), mio::circle::Reader::select_subgraph(), and mio::circle::Reader::tensors().

Referenced by package.infer.session::inference().


The documentation for this class was generated from the following files: