Skip to content

Modified Create Options to pass config options to execution Provider#448

Merged
sfatimar merged 2 commits intoovep-develop-lnl-1.2from
sahar/redesign_factory_create
Sep 23, 2024
Merged

Modified Create Options to pass config options to execution Provider#448
sfatimar merged 2 commits intoovep-develop-lnl-1.2from
sahar/redesign_factory_create

Conversation

@sfatimar
Copy link

Description

Create Passes in a single buffer ProviderOptions and SessionOptions Config to the
The Factory Creator which stores the reference to config and when createprovider is invoked
same reference is used to get config options

Motivation and Context


std::shared_ptr<IExecutionProviderFactory> CreateExecutionProviderFactory(const void* void_params) override {
auto& provider_options_map = *reinterpret_cast<const ProviderOptions*>(void_params);
typedef std::pair<const ProviderOptions*, const ConfigOptions&> buffer_t;

Choose a reason for hiding this comment

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

Suggested change
typedef std::pair<const ProviderOptions*, const ConfigOptions&> buffer_t;
typedef std::pair<const ProviderOptions*, const ConfigOptions&> ConfigBuffer;

typedef naming case must be similar to the case of a class as the return type creates confusion whether the its a variable or a type while reading.

Choose a reason for hiding this comment

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

Below can optimally look like -

const ConfigBuffer* buffer = reinterpret_cast<const ConfigBuffer*>(void_params);

// Add new provider option below
ov_options_converted_map["num_streams"] = "1";
ov_options_converted_map["export_ep_ctx_blob"] = "false";
//ov_options_converted_map["export_ep_ctx_blob"] = "false";

Choose a reason for hiding this comment

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

Please remove the redundant comment

onnxruntime::ORTSessionOptionsToOrtOpenVINOProviderOptions(*provider_options_map, session_options);
}
return s_library_openvino.Get().CreateExecutionProviderFactory(provider_options_map);
std::pair<const ProviderOptions*, const ConfigOptions&> buffer = {provider_options_map, session_options->config_options};

Choose a reason for hiding this comment

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

Suggested change
std::pair<const ProviderOptions*, const ConfigOptions&> buffer = {provider_options_map, session_options->config_options};
std::pair<const ProviderOptions*, const ConfigOptions&> config_buffer = {provider_options_map, session_options->config_options};

buffer as a variable name can carry many assumptions like memory, registers, cache etc. Its better to use above for clarity

return s_library_openvino.Get().CreateExecutionProviderFactory(provider_options_map);
std::pair<const ProviderOptions*, const ConfigOptions&> buffer = {provider_options_map, session_options->config_options};
const void* obj = reinterpret_cast<const void*>(&buffer);
return s_library_openvino.Get().CreateExecutionProviderFactory(obj);
Copy link

@ankitm3k ankitm3k Sep 23, 2024

Choose a reason for hiding this comment

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

Optional

Suggested change
return s_library_openvino.Get().CreateExecutionProviderFactory(obj);
return s_library_openvino.Get().CreateExecutionProviderFactory(reinterpret_cast<const void*>(&config_buffer));

Copy link

@ankitm3k ankitm3k left a comment

Choose a reason for hiding this comment

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

Please fix the lint issues additionally.

@sfatimar
Copy link
Author

LGTM

@sfatimar sfatimar merged commit 63026cd into ovep-develop-lnl-1.2 Sep 23, 2024
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.

2 participants