105{
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 {
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
127 auto shape =
tensor->shape();
128 os << " " + print_format + " shape : (";
129 ::print_comma_sepearted(os, shape);
130 os << ")" << std::endl;
131
132
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
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.
const char * tensor_name(const circle::Tensor *tensor)