MCPcopy Create free account
hub / github.com/pytorch/executorch / quantize_model

Function quantize_model

backends/arm/scripts/aot_arm_compiler.py:800–822  ·  view source on GitHub ↗
(
    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, ...]]],
)

Source from the content-addressed store, hash-verified

798
799
800def 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
825def _to_edge_TOSA_delegate(

Callers 3

mainFunction · 0.90
_to_edge_TOSA_delegateFunction · 0.70
_to_edge_no_delegateFunction · 0.70

Calls 2

quantizeFunction · 0.70
exportMethod · 0.45

Tested by

no test coverage detected