mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-11 17:48:34 +00:00
Update api backward compatibility (#20136)
### Description Update api backward compatibility ### Motivation and Context Update api backward compatibility
This commit is contained in:
parent
3e2b659fce
commit
3979f53aa4
2 changed files with 16 additions and 3 deletions
|
|
@ -23,8 +23,8 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def quant_pre_process(
|
||||
input_model: Union[str, Path, onnx.ModelProto],
|
||||
output_model_path: Union[str, Path],
|
||||
input_model: Optional[Union[str, Path, onnx.ModelProto]] = None,
|
||||
output_model_path: Optional[Union[str, Path]] = None,
|
||||
skip_optimization: bool = False,
|
||||
skip_onnx_shape: bool = False,
|
||||
skip_symbolic_shape: bool = False,
|
||||
|
|
@ -36,6 +36,7 @@ def quant_pre_process(
|
|||
all_tensors_to_one_file: bool = False,
|
||||
external_data_location: Optional[str] = None,
|
||||
external_data_size_threshold: int = 1024,
|
||||
**deprecated_kwargs,
|
||||
) -> None:
|
||||
"""Shape inference and model optimization, in preparation for quantization.
|
||||
|
||||
|
|
@ -63,6 +64,13 @@ def quant_pre_process(
|
|||
external_data_location: The file location to save the external file
|
||||
external_data_size_threshold: The size threshold for external data
|
||||
"""
|
||||
|
||||
if input_model is None:
|
||||
input_model = deprecated_kwargs.pop("input_model_path", None)
|
||||
assert input_model is not None
|
||||
|
||||
assert output_model_path is not None, "output_model_path is required."
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="pre.quant.") as quant_tmp_dir:
|
||||
temp_path = Path(quant_tmp_dir)
|
||||
model = None
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ MODEL_TYPES = {
|
|||
|
||||
|
||||
def optimize_by_onnxruntime(
|
||||
onnx_model: Union[str, ModelProto],
|
||||
onnx_model: Optional[Union[str, ModelProto]] = None,
|
||||
use_gpu: bool = False,
|
||||
optimized_model_path: Optional[str] = None,
|
||||
opt_level: Optional[int] = 99,
|
||||
|
|
@ -79,6 +79,7 @@ def optimize_by_onnxruntime(
|
|||
external_data_file_threshold: int = 1024,
|
||||
*,
|
||||
provider: Optional[str] = None,
|
||||
**deprecated_kwargs,
|
||||
) -> str:
|
||||
"""
|
||||
Use onnxruntime to optimize model.
|
||||
|
|
@ -99,6 +100,10 @@ def optimize_by_onnxruntime(
|
|||
assert opt_level in [1, 2, 99]
|
||||
from torch import version as torch_version
|
||||
|
||||
if onnx_model is None:
|
||||
onnx_model = deprecated_kwargs.pop("onnx_model_path", None)
|
||||
assert onnx_model is not None
|
||||
|
||||
if (
|
||||
use_gpu
|
||||
and provider is None
|
||||
|
|
|
|||
Loading…
Reference in a new issue