Skip to content

Support ONNX overloaded functions (IR version 10+)#28275

Merged
gramalingam merged 1 commit intomainfrom
rama/overload
May 3, 2026
Merged

Support ONNX overloaded functions (IR version 10+)#28275
gramalingam merged 1 commit intomainfrom
rama/overload

Conversation

@gramalingam
Copy link
Copy Markdown
Contributor

Add support for the overload field in FunctionProto and NodeProto, as specified in ONNX IR version 10. Functions are now uniquely identified by the triple (domain, name, overload) instead of just (domain, name).

Changes:

  • function_utils.h: GetFunctionIdentifier accepts optional overload param
  • function_utils.cc: CreateSchema takes overload for correct lookup
  • graph.h: Node class gains overload_ member, Overload()/SetOverload()
  • graph.cc: Store overload from NodeProto, serialize in ToProto, copy on AddNode, use overload in function resolution
  • model.cc: Include overload in all function map keys
  • graph_partitioner.cc: Include overload in not-inlined function tracking
  • function_test.cc: Add tests for overloaded and backward-compatible cases

Description

Support overloaded model-local functions as per ONNX spec.

Motivation and Context

Support ONNX spec.

Add support for the overload field in FunctionProto and NodeProto, as
specified in ONNX IR version 10. Functions are now uniquely identified by
the triple (domain, name, overload) instead of just (domain, name).

Changes:
- function_utils.h: GetFunctionIdentifier accepts optional overload param
- function_utils.cc: CreateSchema takes overload for correct lookup
- graph.h: Node class gains overload_ member, Overload()/SetOverload()
- graph.cc: Store overload from NodeProto, serialize in ToProto, copy on
  AddNode, use overload in function resolution
- model.cc: Include overload in all function map keys
- graph_partitioner.cc: Include overload in not-inlined function tracking
- function_test.cc: Add tests for overloaded and backward-compatible cases

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds ONNX IR v10+ model-local function overload support so function dispatch can differentiate multiple FunctionProtos with the same (domain, name) by additionally keying on overload.

Changes:

  • Extend function identifier/keying and schema creation to include overload (when present).
  • Persist NodeProto.overload through Node load/copy/serialize paths and use it for function resolution.
  • Update function inlining/partitioning bookkeeping and add unit tests covering overloaded + backward-compatible cases.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
onnxruntime/core/graph/function_utils.h Extends GetFunctionIdentifier and CreateSchema signature to accept optional overload and include it in function keys.
onnxruntime/core/graph/function_utils.cc Uses overload-aware identifiers for local function lookup and improves the thrown error context.
include/onnxruntime/core/graph/graph.h Adds Node::overload_ with Overload()/SetOverload() accessors for IR v10+ dispatch.
onnxruntime/core/graph/graph.cc Loads/serializes/copies node overload; uses overload when resolving model-local function templates.
onnxruntime/core/graph/model.cc Stores model-local functions and templates keyed by (domain, name, overload).
onnxruntime/core/framework/graph_partitioner.cc Tracks not-inlined functions using overload-aware identifiers.
onnxruntime/test/framework/function_test.cc Adds tests validating correct resolution of overloaded functions and backward compatibility when overload is empty.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@justinchuby justinchuby left a comment

Choose a reason for hiding this comment

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

@justinchuby
Copy link
Copy Markdown
Contributor

@copilot is this complete? Anything missing from the changeset?

Copy link
Copy Markdown
Contributor

Copilot AI commented May 1, 2026

@copilot is this complete? Anything missing from the changeset?

The changeset looks complete. Here's what's covered:

  • Node load/save: NodeProto.overloadNode.overload_ on load; serialized back in ToProto when non-empty
  • Node copy: Overload() preserved in AddNode copy path
  • Function resolution (Graph::Resolve): Uses GetFunctionIdentifier(domain, name, overload) for model-local function template lookup
  • Model function maps (model.cc): All insertions/lookups key on the full (domain, name, overload) triple, including RemoveLocalFunctionsProtos
  • Graph partitioner: Not-inlined function tracking uses the full triple
  • GetFunctionIdentifier: overload is an optional defaulted-to-empty parameter for backward compatibility
  • CreateSchema: Takes the overload for correct lookup

The ORT flatbuffers format (.ort files) doesn't need updating because model-local functions are fully inlined before those files are written.

Two new tests cover the overloaded dispatch (OverloadedFunctions) and backward compatibility with IR v10 models using non-overloaded functions (OverloadedFunctionBackwardCompat).

Copilot AI requested a review from justinchuby May 1, 2026 20:24
@gramalingam gramalingam merged commit 763c4e3 into main May 3, 2026
94 checks passed
@gramalingam gramalingam deleted the rama/overload branch May 3, 2026 22:49
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.

5 participants