Skip to content

Adopt model editor custom ops - #34149

Open
Yateng Hong (toothache) wants to merge 2 commits into
microsoft:mainfrom
toothache:adopt-model-editor-custom-ops
Open

Yateng Hong (toothache) wants to merge 2 commits into
microsoft:mainfrom
toothache:adopt-model-editor-custom-ops

Conversation

@toothache

Copy link
Copy Markdown
Member

This pull request adds support for registering and using custom operator domains when creating sessions from models in the Model Editor C API. It also introduces a new test to verify this functionality.

Custom Operator Domain Support:

  • Added logic in CreateSessionFromModel (in model_editor_c_api.cc) to register custom operator domains from SessionOptions before loading the model, ensuring custom ops are available during session creation.

Testing Enhancements:

  • Introduced the CustomOpSession test in test_model_builder_api.cc to validate that sessions with custom operators can be created and used for inference, including both negative and positive test cases.### Description

Motivation and Context

Register session-option custom op domains before loading the model and add regression coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3959277e-1e1b-43f1-ae06-15c5f6b97d76
Rename the test operator to CustomOpOne and inline its compute function as a captureless lambda.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3959277e-1e1b-43f1-ae06-15c5f6b97d76
Copilot AI balanced review requested due to automatic review settings November 12, 2026 13:40
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block approval of the custom operator support change.

No open issues 🎉

What changed in this PR

Adds custom operator support to sessions created through the Model Editor C API, using domains registered in SessionOptions.

Changes:

  • Registers custom operator domains before loading the model.
  • Adds a regression test covering failure without registration and successful inference with a registered custom operator.
File Description
onnxruntime/​test/​shared_lib/​test_model_builder_api.cc Adds CustomOpSession coverage for custom operator registration and inference.
onnxruntime/​core/​session/​model_editor_c_api.cc Registers supplied custom operator domains before model loading.

Review effort: Balanced

This branch has not been deployed

No deployments
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