mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Enable symbolic shape inference in ORTModule (#7282)
Co-authored-by: Ethan Tao <ettao@OrtTrainingDev4.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
This commit is contained in:
parent
d272c8434d
commit
e14b291ce7
1 changed files with 7 additions and 0 deletions
|
|
@ -9,6 +9,8 @@ from . import _ortmodule_logger as _logger
|
|||
from onnxruntime.capi.onnxruntime_inference_collection import OrtValue
|
||||
from onnxruntime.capi import _pybind_state as C
|
||||
|
||||
from onnxruntime.tools.symbolic_shape_infer import SymbolicShapeInference
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
import io
|
||||
import inspect
|
||||
|
|
@ -90,6 +92,8 @@ class GraphExecutionManager(ABC):
|
|||
# default execution order is priority-based for both dynamic/static shape input for now
|
||||
# if we observe benefit of static shape, we can expose this flag to user
|
||||
self._use_static_shape = False
|
||||
# flag to enable symbolic shape inference for dynamic shape inputs to improve performance
|
||||
self._run_symbolic_shape_infer = False
|
||||
self._input_names_require_grad = None
|
||||
self._module_output_schema = None
|
||||
|
||||
|
|
@ -184,6 +188,9 @@ class GraphExecutionManager(ABC):
|
|||
self._set_device_from_module()
|
||||
self._onnx_model = self._get_exported_model(*inputs, **kwargs)
|
||||
|
||||
if self._run_symbolic_shape_infer:
|
||||
self._onnx_model = SymbolicShapeInference.infer_shapes(self._onnx_model, auto_merge=True, guess_output_rank=True)
|
||||
|
||||
return True
|
||||
|
||||
def _get_exported_model(self, *inputs, **kwargs):
|
||||
|
|
|
|||
Loading…
Reference in a new issue