MCPcopy Index your code
hub / github.com/OpenPPL/ppq / export

Method export

ppq/parser/tensorRT.py:116–140  ·  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

114
115
116 def export(self, file_path: str, graph: BaseGraph, config_path: str = None, input_shapes: List[List[int]] = [[1, 3, 224, 224]]):
117 ppq_info(
118 'You are exporting PPQ Graph to TensorRT(Onnx + Json). \n'
119 'Please Compile the TensorRT INT8 engine manually: \n\n'
120 'from ppq.utils.TensorRTUtil import build_engine \n'
121 "build_engine(onnx_file='Quantized.onnx', int8_scale_file='Quantized.json', engine_file='Quantized.engine', int8=True)\n")
122 if config_path is not None:
123 self.export_quantization_config(config_path, graph)
124 self.export_weights(graph, config_path)
125 _, ext = os.path.splitext(file_path)
126 if ext == '.onnx':
127 exporter = OnnxExporter()
128 exporter.export(file_path=file_path, graph=graph, config_path=None)
129 elif ext in {'.prototxt', '.caffemodel'}:
130 exporter = CaffeExporter()
131 exporter.export(file_path=file_path, graph=graph, config_path=None, input_shapes=input_shapes)
132
133 # no pre-determined export format, we export according to the
134 # original model format
135 elif graph._built_from == NetworkFramework.CAFFE:
136 exporter = CaffeExporter()
137 exporter.export(file_path=file_path, graph=graph, config_path=None, input_shapes=input_shapes)
138 elif graph._built_from == NetworkFramework.ONNX:
139 exporter = OnnxExporter()
140 exporter.export(file_path=file_path, graph=graph, config_path=None)

Callers

nothing calls this directly

Calls 6

export_weightsMethod · 0.95
exportMethod · 0.95
ppq_infoFunction · 0.90
OnnxExporterClass · 0.85
CaffeExporterClass · 0.85

Tested by

no test coverage detected