Dump IR for given arguments.
Call example: $ ./build/compiler/encodump/encodump \ –frontend build/compiler/enco/frontend/caffe/libenco_caffe_frontend.so \ –frontend-arg build/compiler/enco/test/caffe/Convolution_003.prototxt \ –frontend-arg build/compiler/enco/test/caffe/Convolution_003.caffemodel
GROUP "/" ㄴGROUP "name" ㄴATTRIBUTE "0" ㄴDATA (0): "input_01:0" ㄴATTRIBUTE "1" ㄴDATA (0): "input_02:0" ㄴGROUP "value" ㄴDATASET "0" ㄴDATA ... ㄴDATASET "1" ㄴDATA ...
194{
195
196
197
198
199
200 assert(argc == 5);
201 assert(std::string(argv[1]) == "-d");
202 assert(std::string(argv[2]) == "0.001");
203
204 H5::H5File lhs{
argv[3], H5F_ACC_RDONLY};
205 H5::H5File rhs{
argv[4], H5F_ACC_RDONLY};
206
207 ExitcodeTracker exitcode_tracker;
208
209 Mux mux;
210 mux.attach(&exitcode_tracker);
211
212
213 do
214 {
215
217
220
221
222 int64_t value_count = -1;
223 {
224 uint32_t lhs_value_count = static_cast<uint32_t>(lhs_value_grp.getNumObjs());
225 uint32_t rhs_value_count = static_cast<uint32_t>(rhs_value_grp.getNumObjs());
226
227 if (lhs_value_count != rhs_value_count)
228 {
229 ErrorDetail<ErrorCode::CountMismatch>
error{};
230 mux.notify(error);
231 break;
232 }
233
234 value_count = std::max<int64_t>(lhs_value_count, rhs_value_count);
235 }
236 assert(value_count >= 0);
237
238
239 for (int64_t n = 0; n < value_count; ++n)
240 {
241
242 const std::string dataset_name = std::to_string(n);
243
244 auto lhs_dataset = lhs_value_grp.openDataSet(dataset_name);
245 auto rhs_dataset = rhs_value_grp.openDataSet(dataset_name);
246
247 auto lhs_dtype = to_internal_dtype(lhs_dataset.getDataType());
248 auto rhs_dtype = to_internal_dtype(rhs_dataset.getDataType());
249
250
251 assert(rhs_dtype == DataType::FLOAT32);
252 assert(lhs_dtype == DataType::FLOAT32);
253
254 if (lhs_dtype != rhs_dtype)
255 {
256 ErrorDetail<ErrorCode::TypeMismatch>
error{};
257 mux.notify(error);
258 continue;
259 }
260
261 auto lhs_shape = to_internal_shape(lhs_dataset.getSpace());
262 auto rhs_shape = to_internal_shape(rhs_dataset.getSpace());
263
264 if (!(lhs_shape == rhs_shape))
265 {
266 ErrorDetail<ErrorCode::ShapeMismatch>
error{};
267 mux.notify(error);
268 continue;
269 }
270
271 assert(lhs_shape == rhs_shape);
272 assert(lhs_dtype == rhs_dtype);
273 const auto &shape = lhs_shape;
274 const auto &
dtype = lhs_dtype;
275
276 switch (dtype)
277 {
278 case DataType::FLOAT32:
279 {
280 auto lhs_vector = as_float_vector(lhs_dataset);
281 auto rhs_vector = as_float_vector(rhs_dataset);
282
283 assert(lhs_vector.size() == rhs_vector.size());
284
285 LexicalLayout layout;
286
287 for (TensorIndexEnumerator e{shape}; e.valid(); e.advance())
288 {
289 const auto &ind = e.current();
290 auto lhs_value = lhs_vector.at(layout.offset(shape, ind));
291 auto rhs_value = rhs_vector.at(layout.offset(shape, ind));
292
293
294 if (std::abs(lhs_value - rhs_value) >= 0.001f)
295 {
296 ErrorDetail<ErrorCode::ValueMismatch>
error{};
297 mux.notify(error);
298 continue;
299 }
300 }
301
302 break;
303 }
304 default:
305 throw std::runtime_error{"Not supported, yet"};
306 };
307 }
308 } while (false);
309
310
311
312 return exitcode_tracker.exitcode();
313}
std::string value_grpname(void)
Return the name of "value group".