( onnx_model_path: typing.List[os.PathLike] config: PretrainedConfig )
Handles the ONNX Runtime optimization process for models shared on huggingface.co/models.
( model_or_path: typing.Union[str, os.PathLike, optimum.onnxruntime.modeling_ort.ORTModel] file_names: typing.Optional[typing.List[str]] = None )
Parameters
Union[str, os.PathLike, ORTModel]
) —
The path to a local directory hosting the model to optimize or an instance of an ORTModel
to quantize.
Can be either:Optional[List[str]]
, optional) —
The list of file names of the models to optimize.
( onnx_model_path: typing.Union[str, os.PathLike] )
Computes the dictionary mapping the name of the fused operators to their number of apparition in the model.
( onnx_model_path: typing.Union[str, os.PathLike] onnx_optimized_model_path: typing.Union[str, os.PathLike] )
Compute the difference in the number of nodes between the original and the optimized model.
( onnx_model_path: typing.Union[str, os.PathLike] onnx_optimized_model_path: typing.Union[str, os.PathLike] )
Compute the dictionary mapping the operators name to the difference in the number of corresponding nodes between the original and the optimized model.
( optimization_config: OptimizationConfig save_dir: typing.Union[str, os.PathLike] file_suffix: typing.Optional[str] = 'optimized' use_external_data_format: bool = False one_external_file: bool = True )
Parameters
Union[str, os.PathLike]
) —
The path used to save the optimized model.
str
, optional, defaults to "optimized"
) —
The file suffix used to save the optimized model.
bool
, optional, defaults to False
) —
Whether to use external data format to store model of size >= 2Gb.
bool
, defaults to True
) —
When use_external_data_format=True
, whether to save all tensors to one external file.
If false, save each tensor to a file named with the tensor name.
Optimizes a model given the optimization specifications defined in optimization_config
.