-
Notifications
You must be signed in to change notification settings - Fork 4k
Weightless support for all initializers #29607
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
base: main
Are you sure you want to change the base?
Changes from all commits
7464a15
fcc0a8d
966a441
8729eac
cc481da
b586726
ce87089
4a10750
5cf4612
580216a
e54cc91
c5ca19b
c69081c
4ca3f30
218dba4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| #include <cassert> | ||
| #include <climits> | ||
| #include <cstring> | ||
| #include <filesystem> | ||
|
Check warning on line 8 in onnxruntime/core/session/onnxruntime_c_api.cc
|
||
| #include <functional> | ||
| #include <mutex> | ||
| #include <sstream> | ||
|
|
@@ -2758,6 +2759,42 @@ | |
| API_IMPL_END | ||
| } | ||
|
|
||
| ORT_API_STATUS_IMPL(OrtApis::SessionOptionsSetWeightlessSourceModelPath, _Inout_ OrtSessionOptions* options, | ||
| _In_ const ORTCHAR_T* source_model_path) { | ||
| API_IMPL_BEGIN | ||
| if (source_model_path == nullptr || source_model_path[0] == '\0') { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it also validate that the path is valid? Say with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch, added the check |
||
| return OrtApis::CreateStatus(ORT_INVALID_ARGUMENT, "Invalid source model path: path is null or empty"); | ||
| } | ||
|
|
||
| if (!std::filesystem::exists(source_model_path)) { | ||
| return OrtApis::CreateStatus(ORT_NO_SUCHFILE, "Weightless source model path does not exist"); | ||
| } | ||
|
|
||
| options->weightless_source_model_path = source_model_path; | ||
| options->weightless_source_model_data = nullptr; | ||
| options->weightless_source_model_data_size = 0; | ||
| return nullptr; | ||
| API_IMPL_END | ||
| } | ||
|
|
||
| ORT_API_STATUS_IMPL(OrtApis::SessionOptionsSetWeightlessSourceModelFromBuffer, _Inout_ OrtSessionOptions* options, | ||
| _In_ const void* source_model_data, _In_ size_t source_model_data_length) { | ||
| API_IMPL_BEGIN | ||
| if (source_model_data == nullptr) { | ||
| return OrtApis::CreateStatus(ORT_INVALID_ARGUMENT, "Invalid source model: data pointer is null"); | ||
| } | ||
|
|
||
| if (source_model_data_length == 0) { | ||
| return OrtApis::CreateStatus(ORT_INVALID_ARGUMENT, "Invalid source model: data size is 0"); | ||
| } | ||
|
|
||
| options->weightless_source_model_data = source_model_data; | ||
| options->weightless_source_model_data_size = source_model_data_length; | ||
| options->weightless_source_model_path.clear(); | ||
| return nullptr; | ||
| API_IMPL_END | ||
| } | ||
|
|
||
| ORT_API(void, OrtApis::ReleaseValueInfo, _Frees_ptr_opt_ OrtValueInfo* value_info) { | ||
| delete value_info; | ||
| } | ||
|
|
@@ -4918,6 +4955,9 @@ | |
| &OrtApis::GetExperimentalFunction, | ||
| &OrtApis::KernelContext_GetSyncStream, | ||
| // End of Version 28 - DO NOT MODIFY ABOVE (see above text for more information) | ||
|
|
||
| &OrtApis::SessionOptionsSetWeightlessSourceModelPath, | ||
| &OrtApis::SessionOptionsSetWeightlessSourceModelFromBuffer, | ||
| }; | ||
|
|
||
| // OrtApiBase can never change as there is no way to know what version of OrtApiBase is returned by OrtGetApiBase. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add this option to the list of recognized path options in model package
onnxruntime/onnxruntime/core/session/model_package/model_package_context.cc
Line 32 in 632de62
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, just added