(
model: GraphModule,
example_inputs: Tuple[torch.Tensor],
compile_spec,
model_name: str,
strict_export: bool,
quant_mode: QuantMode,
calibration_samples: Optional[List[Tuple[torch.Tensor, ...]]],
)
| 798 | |
| 799 | |
| 800 | def quantize_model( |
| 801 | model: GraphModule, |
| 802 | example_inputs: Tuple[torch.Tensor], |
| 803 | compile_spec, |
| 804 | model_name: str, |
| 805 | strict_export: bool, |
| 806 | quant_mode: QuantMode, |
| 807 | calibration_samples: Optional[List[Tuple[torch.Tensor, ...]]], |
| 808 | ) -> Tuple[GraphModule, ExportedProgram]: |
| 809 | model_quant = quantize( |
| 810 | model, |
| 811 | model_name, |
| 812 | compile_spec, |
| 813 | example_inputs, |
| 814 | quant_mode, |
| 815 | calibration_samples, |
| 816 | ) |
| 817 | # Wrap quantized model back into an exported_program |
| 818 | exported_program = torch.export.export( |
| 819 | model_quant, example_inputs, strict=strict_export |
| 820 | ) |
| 821 | |
| 822 | return model_quant, exported_program |
| 823 | |
| 824 | |
| 825 | def _to_edge_TOSA_delegate( |
no test coverage detected