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 ...
71{
72
74 arser.add_argument(
"--model")
75 .type(arser::DataType::STR)
76 .required(true)
77 .help("Path to model.circle file");
78 arser.add_argument(
"--input_prefix")
79 .type(arser::DataType::STR)
80 .help("Prefix for input files (generates random inputs if not provided)");
81 arser.add_argument(
"--output_prefix").type(arser::DataType::STR).help(
"Prefix for output files");
82
83 try
84 {
85 arser.parse(argc, argv);
86 }
87 catch (const std::runtime_error &err)
88 {
89 std::cerr << err.what() << std::endl;
91 return EXIT_FAILURE;
92 }
93
94 const auto filename =
arser.get<std::string>(
"--model");
95 std::string input_prefix;
96 std::string output_prefix;
97
98 if (
arser[
"--input_prefix"])
99 {
100 input_prefix =
arser.get<std::string>(
"--input_prefix");
101 }
102 if (
arser[
"--output_prefix"])
103 {
104 output_prefix =
arser.get<std::string>(
"--output_prefix");
105 }
106 const bool auto_input = !
arser[
"--input_prefix"];
108
109 std::ifstream
file(filename, std::ios::binary | std::ios::in);
111 {
112 std::string errmsg = "Failed to open file";
113 throw std::runtime_error(errmsg.c_str());
114 }
115
116 file.seekg(0, std::ios::end);
117 auto fileSize =
file.tellg();
118 file.seekg(0, std::ios::beg);
119
120
122
123
126 {
127 std::string errmsg = "Failed to read file";
128 throw std::runtime_error(errmsg.c_str());
129 }
130
131
135
137
138
139
140
141 int num_inference = 1;
142 for (int j = 0; j < num_inference; ++j)
143 {
147 {
150
151 if (auto_input)
152 {
153 generateRandomData(input_data, input_size);
154 }
155 else
156 {
158 }
159 }
160
161
163 }
164
165
168 {
170 size_t output_size =
interpreter.getOutputSizeAt(i);
171
172 if (
arser[
"--output_prefix"])
173 {
174 writeDataToFile(output_prefix + std::to_string(i),
reinterpret_cast<char *
>(data),
175 output_size);
176 }
177
178 }
180 return EXIT_SUCCESS;
181}
void writeDataToFile(const std::string &file_path, const std::string &data)
write data to file_path
void readDataFromFile(const std::string &filename, std::vector< char > &data, size_t data_size)
std::vector< char > DataBuffer