onnxruntime/onnxruntime/python
pengwa 0668600255
Share scalar constant initializer (#12878)
**Description**: 
1. Share scalar constant for same data type, value and shape. 
2. Fix the order of Graph resolve context clear and
CleanUnusedInitializersAndNodeArgs().

**Share initializer for those who hold same value in same type and
shape, currently only handle scalar value or 1-D single value array.**
  
The transformation itself did not bring much impact on memory/perf,
instead is helpful to simplify the graph, making it easier for common
subexpression eliminations (CSE). Imagine graphs like this:


![image](https://user-images.githubusercontent.com/10530022/188895598-e06f9bf9-5466-4009-a68c-6b339133936c.png)

Add is NOT shared as inputs of Clip after CSE transformation because,
all Add's second constant input are different NodeArg*, so if we change
all constant initializer share the same NodeArg*, then only one Add will
be preserved after CSE transformation. There are few other similar cases
in one of 1P deberta models.

E2E measurement on 1P DEBERTA model, we see an increase from
SamplesPerSec=562.041593991271 to 568.0106130440271, 1.07% gains.

**Fix the order of Graph resolve context clear and
CleanUnusedInitializersAndNodeArgs().**

Graph resolve context will be cleared every time by end of
Graph.Resolve(), one of the thing to be cleared is the
"inputs_and_initializers" who hold string_view of all initializers.
While CleanUnusedInitializersAndNodeArgs removed some initializers, so
some strings that is referenced by string_view in
"inputs_and_initializers" remain to be there BUT in an invalid state.

**Motivation and Context**
- Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here.
2022-10-10 13:32:33 +08:00
..
backend replace 'master' branch ref to 'main' for onnx repo (#12678) 2022-08-30 13:41:42 -07:00
datasets
providers/tvm Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
tools Share scalar constant initializer (#12878) 2022-10-10 13:32:33 +08:00
torch_cpp_extensions ATen Fallback for Inference (#11597) 2022-06-09 16:07:30 +08:00
training
__init__.py
_ld_preload.py Fix python manylinux to not load cuda if it fails to load dependencies (#8882) 2021-09-07 11:09:25 -07:00
_pybind_state.py.in Make ORT callable from various Pytorch compilers (LazyTensor, TorchDynamo, etc) (#10460) 2022-08-22 09:40:40 -07:00
exported_symbols.lst
numpy_helper.h Fix SDL warnings in CPU EP (#9975) 2021-12-19 20:54:29 -08:00
onnxruntime_collect_build_info.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
onnxruntime_inference_collection.py Move OrtValueVector from onnxruntime-training to onnxruntime (#11176) 2022-06-15 09:36:28 +02:00
onnxruntime_pybind.h fix windows ci debug build break (#11495) 2022-05-12 16:54:00 -07:00
onnxruntime_pybind_exceptions.cc
onnxruntime_pybind_exceptions.h Fix issue with debug VS2022 build when python bindings are enabled (#9794) 2021-11-18 16:58:02 +10:00
onnxruntime_pybind_iobinding.cc Adds missing numpy type when looking for the ort correspondance (#10943) 2022-03-22 14:44:48 -07:00
onnxruntime_pybind_mlvalue.cc Address static analysis warnings (#12711) 2022-08-26 14:24:14 -07:00
onnxruntime_pybind_mlvalue.h Move OrtValueVector from onnxruntime-training to onnxruntime (#11176) 2022-06-15 09:36:28 +02:00
onnxruntime_pybind_module.cc Fix issue with debug VS2022 build when python bindings are enabled (#9794) 2021-11-18 16:58:02 +10:00
onnxruntime_pybind_ortvalue.cc Move OrtValueVector from onnxruntime-training to onnxruntime (#11176) 2022-06-15 09:36:28 +02:00
onnxruntime_pybind_schema.cc Add CANN EP (#12416) 2022-09-22 14:53:40 -07:00
onnxruntime_pybind_sparse_tensor.cc Adds missing numpy type when looking for the ort correspondance (#10943) 2022-03-22 14:44:48 -07:00
onnxruntime_pybind_state.cc Add CANN EP (#12416) 2022-09-22 14:53:40 -07:00
onnxruntime_pybind_state.h Fix issue with debug VS2022 build when python bindings are enabled (#9794) 2021-11-18 16:58:02 +10:00
onnxruntime_pybind_state_common.cc Drop nuphar (#11555) 2022-09-07 15:11:18 -07:00
onnxruntime_pybind_state_common.h Add CANN EP (#12416) 2022-09-22 14:53:40 -07:00
onnxruntime_validation.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
pybind.def
version_script.lds
version_script_expose_onnx_protobuf.lds