(
model,
sample_inputs,
sample_kwargs=None,
dynamic_shapes=None,
qmode=QuantizationMode.NONE,
)
| 194 | |
| 195 | |
| 196 | def get_exported_graph( |
| 197 | model, |
| 198 | sample_inputs, |
| 199 | sample_kwargs=None, |
| 200 | dynamic_shapes=None, |
| 201 | qmode=QuantizationMode.NONE, |
| 202 | ) -> torch.fx.GraphModule: |
| 203 | export_training_graph = export( |
| 204 | model, |
| 205 | sample_inputs, |
| 206 | kwargs=sample_kwargs, |
| 207 | dynamic_shapes=dynamic_shapes, |
| 208 | strict=True, |
| 209 | ).module() |
| 210 | |
| 211 | if qmode == QuantizationMode.NONE: |
| 212 | return export_training_graph |
| 213 | |
| 214 | quantizer = XNNPACKQuantizer() |
| 215 | |
| 216 | operator_config = get_symmetric_quantization_config(is_per_channel=True) |
| 217 | quantizer.set_global(operator_config) |
| 218 | |
| 219 | prepared_graph = prepare_pt2e(export_training_graph, quantizer) |
| 220 | prepared_graph(*sample_inputs) |
| 221 | converted_graph = convert_pt2e(prepared_graph) |
| 222 | |
| 223 | return converted_graph |
| 224 | |
| 225 | |
| 226 | def random_uniform_tensor(shape, low=0.0, high=1.0, device=None, dtype=None): |
no test coverage detected