Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support disabling support for the optional type in ORT builds #9745

Merged
merged 11 commits into from
Nov 18, 2021

Conversation

hariharans29
Copy link
Member

@hariharans29 hariharans29 commented Nov 12, 2021

Description: As title

To disable, use cmake_extra_defines like this : build.bat --cmake_extra_defines onnxruntime_DISABLE_OPTIONAL_TYPE=1

Motivation and Context
Allow users to cut down on binary size if the optional type is not relevant in their scenario

#8802

@hariharans29 hariharans29 changed the title Support disabling the optional type in ORT builds Support disabling support for the optional type in ORT builds Nov 12, 2021
@@ -49,7 +49,6 @@ struct OrtValue {
template <typename T>
const T& Get() const {
ORT_ENFORCE(onnxruntime::DataTypeImpl::GetType<T>() == type_, onnxruntime::DataTypeImpl::GetType<T>(), " != ", type_);
ORT_ENFORCE(IsAllocated(), "OrtValue contains no data");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call is not needed. In the kernels that support optional type, this call is performed before calling Get(). Even if the check is missed and it runs into a fatal issue (i.e.) the OrtValue has no data, we will know when we de-reference the nullptr in the next line. Seems unnecessary to pay the cost of this check twice.

@skottmckay
Copy link
Contributor

                            ONNX_NAMESPACE::TypeProto&);

Do we need this?


Refers to: include/onnxruntime/core/framework/data_types.h:409 in 17f373a. [](commit_id = 17f373a, deletion_comment = False)

@skottmckay
Copy link
Contributor

AppendKernelDefHashesFromFile(ORT_TSTR("testdata/kernel_def_hashes/onnx.ml.cpu.json"), result);

The hashes for the Optional operators will need to be in a separate file so we can do the same as for the ML ops when they're disabled.


Refers to: onnxruntime/test/providers/kernel_def_hash_test.cc:170 in 17f373a. [](commit_id = 17f373a, deletion_comment = False)

@hariharans29
Copy link
Member Author

AppendKernelDefHashesFromFile(ORT_TSTR("testdata/kernel_def_hashes/onnx.ml.cpu.json"), result);

The hashes for the Optional operators will need to be in a separate file so we can do the same as for the ML ops when they're disabled.

Refers to: onnxruntime/test/providers/kernel_def_hash_test.cc:170 in 17f373a. [](commit_id = 17f373a, deletion_comment = False)

Done

Copy link
Contributor

@skottmckay skottmckay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@hariharans29 hariharans29 merged commit e23892d into master Nov 18, 2021
@hariharans29 hariharans29 deleted the hari/disable_optional_type branch November 18, 2021 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants