MCPcopy
hub / github.com/OpenPPL/ppq / export

Method export

ppq/parser/caffe_exporter.py:220–245  ·  view source on GitHub ↗
(self, file_path: str, graph: BaseGraph, config_path: str = None, input_shapes: List[List[int]] = [[1, 3, 224, 224]])

Source from the content-addressed store, hash-verified

218 json.dump(var_quant_info_recorder, file, indent=4)
219
220 def export(self, file_path: str, graph: BaseGraph, config_path: str = None, input_shapes: List[List[int]] = [[1, 3, 224, 224]]):
221 # dump config
222 if config_path is not None:
223 self.export_quantization_config(config_path=config_path, graph=graph)
224
225 caffe_model, caffe_proto = self.prepare_model(graph, input_shapes)
226
227 # can not edit structure of protobuf with python, have to edit it as pure string.
228 caffe_proto, str_buffer = str(caffe_proto), ''
229 lines = caffe_proto.split('\n')
230 for idx in range(len(lines)):
231 line = lines[idx]
232 # snpe do not want hole and ceil_mode
233 if 'hole' in line or 'ceil_mode' in line: continue
234 # snpe do not want quantize_param
235 if 'quantize_param' in line:
236 idx += 4
237 continue
238 str_buffer = (str_buffer + line) + '\n'
239 caffe_proto = str_buffer
240
241 # dump model
242 self.dump_to_file(
243 caffe_model = caffe_model,
244 caffe_proto = caffe_proto,
245 file_path = file_path)
246
247
248class PPLDSPCaffeExporter(CaffeExporter):

Callers

nothing calls this directly

Calls 3

prepare_modelMethod · 0.80
dump_to_fileMethod · 0.80

Tested by

no test coverage detected