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

Method export

ppq/parser/caffe_exporter.py:154–176  ·  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

152 with open(caffemodel_path, 'wb') as f: f.write(caffe_model.SerializeToString())
153
154 def export(self, file_path: str, graph: BaseGraph, config_path: str=None, input_shapes: List[List[int]]=[[1,3,224,224]]):
155 # dump config
156 if config_path is not None:
157 self.export_quantization_config(config_path=config_path, graph=graph)
158
159 # dump model
160 caffe_model, caffe_proto = self.prepare_model(graph, input_shapes)
161
162 caffe_proto, str_buffer = str(caffe_proto), ''
163 lines = caffe_proto.split('\n')
164
165 for idx in range(len(lines)):
166 line = lines[idx]
167 # snpe do not want hole and ceil_mode
168 if 'hole' in line or 'ceil_mode' in line: continue
169 # snpe do not want quantize_param
170 if 'quantize_param' in line:
171 idx += 4
172 continue
173 str_buffer = (str_buffer + line) + '\n'
174 caffe_proto = str_buffer
175 self.dump_to_file(caffe_model = caffe_model,
176 caffe_proto = caffe_proto, file_path = file_path)
177
178
179class SNPECaffeExporter(CaffeExporter):

Callers

nothing calls this directly

Calls 3

prepare_modelMethod · 0.95
dump_to_fileMethod · 0.95

Tested by

no test coverage detected