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 ...
30{
31 arser::Arser arser{
"tfl-inspect allows users to retrieve various information from a TensorFlow "
32 "Lite model files"};
33 arser.add_argument(
"--operators").nargs(0).help(
"Dump operators in tflite file");
34 arser.add_argument(
"--conv2d_weight")
35 .nargs(0)
36 .help("Dump Conv2D series weight operators in tflite file");
37 arser.add_argument(
"--op_version").nargs(0).help(
"Dump versions of the operators in tflite file");
38 arser.add_argument(
"tflite").help(
"TFLite file to inspect");
39
40 try
41 {
42 arser.parse(argc, argv);
43 }
44 catch (const std::runtime_error &err)
45 {
46 std::cout << err.what() << std::endl;
48 return 255;
49 }
50
51 if (!
arser[
"--operators"] && !
arser[
"--conv2d_weight"] && !
arser[
"--op_version"])
52 {
53 std::cout << "At least one option must be specified" << std::endl;
55 return 255;
56 }
57
58 std::vector<std::unique_ptr<tflinspect::DumpInterface>> dumps;
59
60 if (
arser[
"--operators"])
61 dumps.push_back(std::make_unique<tflinspect::DumpOperators>());
62 if (
arser[
"--conv2d_weight"])
63 dumps.push_back(std::make_unique<tflinspect::DumpConv2DWeight>());
64 if (
arser[
"--op_version"])
65 dumps.push_back(std::make_unique<tflinspect::DumpOperatorVersion>());
66
67 std::string model_file =
arser.get<std::string>(
"tflite");
68
69
71 std::vector<char> modelData = fileLoader.
load();
72 const tflite::Model *tfliteModel = tflite::GetModel(modelData.data());
73 if (tfliteModel == nullptr)
74 {
75 std::cerr << "ERROR: Failed to load tflite '" << model_file << "'" << std::endl;
76 return 255;
77 }
78
79 for (
auto &
dump : dumps)
80 {
81 dump->run(std::cout, tfliteModel);
82 }
83
84 return 0;
85}
DataBuffer load(void) const
void dump(const coco::Op *op, int indent)