onnxruntime/tools/python
Edward Chen 454f77cd94
Update kernel matching logic: decouple from op schemas and remove kernel def hashes (#12791)
# Motivation
Currently, ORT minimal builds use kernel def hashes to map from nodes to
kernels to execute when loading the model. As the kernel def hashes must
be known ahead of time, this works for statically registered kernels.
This works well for the CPU EP.
For this approach to work, the kernel def hashes must also be known at
ORT format model conversion time, which means the EP with statically
registered kernels must also be enabled then. This is not an issue for
the always-available CPU EP. However, we do not want to require that any
EP which statically registers kernels is always available too.
Consequently, we explore another approach to match nodes to kernels that
does not rely on kernel def hashes. An added benefit of this is the
possibility of moving away from kernel def hashes completely, which
would eliminate the maintenance burden of keeping the hashes stable.

# Approach
In a full build, ORT uses some information from the ONNX op schema to
match a node to a kernel. We want to avoid including the ONNX op schema
in a minimal build to reduce binary size. Essentially, we take the
necessary information from the ONNX op schema and make it available in a
minimal build.
We decouple the ONNX op schema from the kernel matching logic. The
kernel matching logic instead relies on per-op information which can
either be obtained from the ONNX op schema or another source.
This per-op information must be available in a minimal build when there
are no ONNX op schemas. We put it in the ORT format model.
Existing uses of kernel def hashes to look up kernels are replaced
with the updated kernel matching logic. We no longer store
kernel def hashes in the ORT format model’s session state and runtime
optimization representations. We no longer keep the logic to
generate and ensure stability of kernel def hashes.
2022-09-20 14:24:59 -07:00
..
util Add --output_dir option to convert_onnx_models_to_ort.py. (#12844) 2022-09-12 15:36:03 -07:00
__init__.py
check_onnx_model_mobile_usability.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
convert_onnx_models_to_ort.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
create_reduced_build_config.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
dump_ort_model.py Update kernel matching logic: decouple from op schemas and remove kernel def hashes (#12791) 2022-09-20 14:24:59 -07:00
dump_subgraphs.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
example_operator_perf_test.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
find_optimizer_opset_version_updates_required.py Update script to find optimizers that potentially need supported opset updates (#12330) 2022-08-04 07:37:27 +10:00
gen_contrib_doc.py Replace 'master' branch ref to 'main' in the code (#12547) 2022-08-22 10:48:12 -07:00
gen_opkernel_doc.py Replace 'master' branch ref to 'main' in the code (#12547) 2022-08-22 10:48:12 -07:00
gen_ort_mobile_pkg_doc.py Replace 'master' branch ref to 'main' in the code (#12547) 2022-08-22 10:48:12 -07:00
get_submodules.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
onnx_test_data_utils.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
ort_test_dir_utils.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
PythonTools.md Maintain aspect ratio by doing resize + crop in image_to_pb tool (#10887) 2022-03-19 07:08:45 +10:00
remove_initializer_from_input.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
run_android_emulator.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
run_CIs_for_external_pr.py Add azp run helper (#12832) 2022-09-07 11:48:31 +10:00
sparsify_initializers.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00
update_version.py Format all python files under onnxruntime with black and isort (#11324) 2022-04-26 09:35:16 -07:00