Skip to content

Conversation

adrianlizarraga
Copy link
Contributor

@adrianlizarraga adrianlizarraga commented Sep 11, 2025

Description

Draft only. May not be merged.

Allows an application to use SessionOptionsAppendExecutionProvider with a plugin EP from a library registered with ORT. The SessionOptionsAppendExecutionProvider implementation first tries to use an EP built with ORT. If not found, it looks for a plugin EP with the matching name. If a plugin EP exists, an EP factory with all OrtEpDevice instances it supports is added to the session options.

 const OrtApi& c_api = Ort::GetApi();
  ASSERT_ORTSTATUS_OK(c_api.RegisterExecutionProviderLibrary(*ort_env,
                                                             Utils::example_ep_info.registration_name.c_str(),
                                                             Utils::example_ep_info.library_path.c_str()));
  const std::string& plugin_ep_name = Utils::example_ep_info.registration_name;

  {
    Ort::SessionOptions session_options;
    std::unordered_map<std::string, std::string> ep_options;
    session_options.AppendExecutionProvider(plugin_ep_name, ep_options);  // Support added by this PR

    Ort::ModelCompilationOptions compile_options(*ort_env, session_options);
    compile_options.SetFlags(OrtCompileApiFlags::OrtCompileApiFlags_ERROR_IF_NO_NODES_COMPILED);
    compile_options.SetInputModelPath(input_model_file);
    compile_options.SetOutputModelPath(output_model_file);

    Ort::Status status = Ort::CompileModel(*ort_env, compile_options);
  }

  ASSERT_ORTSTATUS_OK(c_api.UnregisterExecutionProviderLibrary(*ort_env,
                                                               Utils::example_ep_info.registration_name.c_str()));

Motivation and Context

@adrianlizarraga adrianlizarraga changed the title Support plugin EPs with original SessionOptionsAppendExecutionProviders API Support plugin EPs with original SessionOptionsAppendExecutionProvider API Sep 11, 2025
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.

1 participant