Skip to content

[EP ABI] Add weight pre-packing support to kernel-based plugin EPs - #26754

Merged
Adrian Lizarraga (adrianlizarraga) merged 31 commits into
mainfrom
adrianl/plugin-ep-kernel-prepack
Dec 27, 2025
Merged

Adrian Lizarraga (adrianlizarraga) merged 31 commits into
mainfrom
adrianl/plugin-ep-kernel-prepack

Conversation

@adrianlizarraga

@adrianlizarraga Adrian Lizarraga (adrianlizarraga) commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Description

  • Adds C APIs to support pre-packing of const weights for OrtKernelImpl implementations.
    • APIs optionally support sharing of pre-packed weight data (for cpu-accessible memory).
  • Updates example kernel (Mul) to use new pre-packing API. Tested by existing unit test:
    TEST(OrtEpLibrary, KernelPluginEp_Inference) {
    RegisteredEpDeviceUniquePtr example_kernel_ep;
    ASSERT_NO_FATAL_FAILURE(Utils::RegisterAndGetExampleEp(*ort_env, Utils::example_ep_kernel_registry_info,
    example_kernel_ep));
    Ort::ConstEpDevice plugin_ep_device(example_kernel_ep.get());
    // Create session with example kernel-based plugin EP
    Ort::SessionOptions session_options;
    session_options.AddConfigEntry(kOrtSessionOptionsDisableCPUEPFallback, "1"); // Fail if any node assigned to CPU EP.
    std::unordered_map<std::string, std::string> ep_options;
    session_options.AppendExecutionProvider_V2(*ort_env, {plugin_ep_device}, ep_options);
    // This model has Squeeze, Mul, and Relu nodes. The example plugin EP supports all nodes using registered kernels.
    Ort::Session session(*ort_env, ORT_TSTR("testdata/squeeze_mul_relu.onnx"), session_options);

Motivation and Context

The previous PR added the base APIs that support kernel-based plugin EPs. This PR adds an additional feature that was identified as necessary for the port of WebGPU EP.

Comment thread include/onnxruntime/core/session/onnxruntime_ep_c_api.h Outdated
Comment thread onnxruntime/core/session/plugin_ep/ep_kernel_registration.cc Outdated
Comment thread onnxruntime/core/session/plugin_ep/ep_kernel_registration.cc
Comment thread onnxruntime/core/session/plugin_ep/ep_kernel_registration.cc Outdated
Comment thread include/onnxruntime/core/session/onnxruntime_ep_c_api.h Outdated
Comment thread onnxruntime/core/session/plugin_ep/ep_kernel_registration.cc Outdated
Comment thread onnxruntime/test/autoep/library/example_plugin_ep_kernel_registry/kernels/mul.cc Outdated
Comment thread onnxruntime/test/autoep/library/example_plugin_ep_kernel_registry/kernels/base.h Outdated
@adrianlizarraga
Adrian Lizarraga (adrianlizarraga) marked this pull request as ready for review December 17, 2025 18:06
Comment thread onnxruntime/core/session/plugin_ep/ep_kernel_registration.cc Outdated
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.

4 participants