Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion onnxruntime/core/session/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,24 @@ OrtStatus* InitializeSession(_In_ const OrtSessionOptions* options,

if (has_provider_factories) {
std::vector<std::unique_ptr<IExecutionProvider>> provider_list;

// Create OrtSessionOptions wrapper for the CreateProvider call.
// Once the InferenceSession is created, its SessionOptions is the source of truth
// and contains all the values from the user provided OrtSessionOptions.
// We wrap the session's copy so any modifications made by the EP (e.g., DisableMemPattern)
// will affect the actual session options that will be used.
auto& session_options = sess.GetMutableSessionOptions();
OrtSessionOptions ort_so;
ort_so.value = session_options;

for (auto& factory : options->provider_factories) {
auto provider = factory->CreateProvider(*options, *session_logger->ToExternal());
auto provider = factory->CreateProvider(ort_so, *session_logger->ToExternal());
provider_list.push_back(std::move(provider));
}

// Copy any modifications made by the EP back to the session's options
session_options = ort_so.value;

// register the providers
for (auto& provider : provider_list) {
if (provider) {
Expand Down
Loading