( onnx_model_path: Path config: typing.Optional[ForwardRef('PretrainedConfig')] = None )
Handles the ONNX Runtime quantization process for models shared on huggingface.co/models.
Computes the quantization ranges.
( dataset: Dataset calibration_config: CalibrationConfig onnx_augmented_model_name: typing.Union[str, pathlib.Path] = 'augmented_model.onnx' operators_to_quantize: typing.Optional[typing.List[str]] = None batch_size: int = 1 use_external_data_format: bool = False use_gpu: bool = False force_symmetric_range: bool = False )
Parameters
Dataset
) —
The dataset to use when performing the calibration step. ~CalibrationConfig
) —
The configuration containing the parameters related to the calibration step. Union[str, Path]
, defaults to "augmented_model.onnx"
) —
The path used to save the augmented model used to collect the quantization ranges. Optional[List[str]]
, defaults to None
) —
List of the operators types to quantize. int
, defaults to 1) —
The batch size to use when collecting the quantization ranges values. bool
, defaults to False
) —
Whether to use external data format to store model which size is >= 2Gb. bool
, defaults to False
) —
Whether to use the GPU when collecting the quantization ranges values. bool
, defaults to False
) —
Whether to make the quantization ranges symmetric. Performs the calibration step and computes the quantization ranges.
( model_or_path: typing.Union[ForwardRef('ORTModel'), str, pathlib.Path] file_name: typing.Optional[str] = None )
Parameters
Union[ORTModel, str, Path]
) —
Can be either:ORTModelForXX
class, e.g., ORTModelForQuestionAnswering
.Optional[str]
, defaults to None
) —
Overwrites the default model file name from "model.onnx"
to file_name
.
This allows you to load different model files from the same repository or directory. Instantiates a ORTQuantizer
from an ONNX model file or an ORTModel
.
( dataset_name: str num_samples: int = 100 dataset_config_name: typing.Optional[str] = None dataset_split: typing.Optional[str] = None preprocess_function: typing.Optional[typing.Callable] = None preprocess_batch: bool = True seed: int = 2016 use_auth_token: typing.Union[bool, str, NoneType] = None token: typing.Union[bool, str, NoneType] = None )
Parameters
str
) —
The dataset repository name on the Hugging Face Hub or path to a local directory containing data files
to load to use for the calibration step. int
, defaults to 100) —
The maximum number of samples composing the calibration dataset. Optional[str]
, defaults to None
) —
The name of the dataset configuration. Optional[str]
, defaults to None
) —
Which split of the dataset to use to perform the calibration step. Optional[Callable]
, defaults to None
) —
Processing function to apply to each example after loading dataset. bool
, defaults to True
) —
Whether the preprocess_function
should be batched. int
, defaults to 2016) —
The random seed to use when shuffling the calibration dataset. Optional[Union[bool,str]]
, defaults to None
) —
Deprecated. Please use the token
argument instead. Optional[Union[bool,str]]
, defaults to None
) —
The token to use as HTTP bearer authorization for remote files. If True
, will use the token generated
when running huggingface-cli login
(stored in huggingface_hub.constants.HF_TOKEN_PATH
). Creates the calibration datasets.Dataset
to use for the post-training static quantization calibration step.
( dataset: Dataset calibration_config: CalibrationConfig onnx_augmented_model_name: typing.Union[str, pathlib.Path] = 'augmented_model.onnx' operators_to_quantize: typing.Optional[typing.List[str]] = None batch_size: int = 1 use_external_data_format: bool = False use_gpu: bool = False force_symmetric_range: bool = False )
Parameters
Dataset
) —
The dataset to use when performing the calibration step. CalibrationConfig
) —
The configuration containing the parameters related to the calibration step. Union[str, Path]
, defaults to "augmented_model.onnx"
) —
The path used to save the augmented model used to collect the quantization ranges. Optional[List[str]]
, defaults to None
) —
List of the operators types to quantize. int
, defaults to 1) —
The batch size to use when collecting the quantization ranges values. bool
, defaults to False
) —
Whether uto se external data format to store model which size is >= 2Gb. bool
, defaults to False
) —
Whether to use the GPU when collecting the quantization ranges values. bool
, defaults to False
) —
Whether to make the quantization ranges symmetric. Performs the calibration step and collects the quantization ranges without computing them.
( quantization_config: QuantizationConfig save_dir: typing.Union[str, pathlib.Path] file_suffix: typing.Optional[str] = 'quantized' calibration_tensors_range: typing.Optional[typing.Dict[str, typing.Tuple[float, float]]] = None use_external_data_format: bool = False preprocessor: typing.Optional[optimum.onnxruntime.preprocessors.quantization.QuantizationPreprocessor] = None )
Parameters
QuantizationConfig
) —
The configuration containing the parameters related to quantization. Union[str, Path]
) —
The directory where the quantized model should be saved. Optional[str]
, defaults to "quantized"
) —
The file_suffix used to save the quantized model. Optional[Dict[str, Tuple[float, float]]]
, defaults to None
) —
The dictionary mapping the nodes name to their quantization ranges, used and required only when applying static quantization. bool
, defaults to False
) —
Whether to use external data format to store model which size is >= 2Gb. Optional[QuantizationPreprocessor]
, defaults to None
) —
The preprocessor to use to collect the nodes to include or exclude from quantization. Quantizes a model given the optimization specifications defined in quantization_config
.