Skip to content

Add input() and add_output() methods to GraphBuilder#2828

Merged
gramalingam merged 4 commits intomainfrom
input-output
Apr 10, 2026
Merged

Add input() and add_output() methods to GraphBuilder#2828
gramalingam merged 4 commits intomainfrom
input-output

Conversation

@justinchuby
Copy link
Copy Markdown
Collaborator

This pull request adds new methods to the GraphBuilder class to simplify the creation and management of graph inputs and outputs, and introduces corresponding unit tests to ensure their correct behavior. The changes improve the usability and reliability of the graph-building API.

Enhancements to the GraphBuilder API:

  • Added a new input method to GraphBuilder for creating and registering graph input values with support for specifying name, dtype, shape, type, constant value, and metadata properties.
  • Added a new add_output method to GraphBuilder to append an output value to the graph and optionally rename it.

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

This pull request enhances the GraphBuilder class by adding two new convenience methods for managing graph inputs and outputs. The changes simplify the process of creating graph inputs with rich metadata and adding outputs with optional renaming, improving the ergonomics of the graph-building API.

Changes:

  • Added input() method to GraphBuilder for creating and registering graph input values with support for dtype, shape, type, const_value, and metadata properties
  • Added add_output() method to GraphBuilder for appending output values to the graph with optional renaming
  • Added comprehensive unit tests for both new methods, plus additional test coverage for the existing initializer() method's qualification behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
onnxscript/_internal/builder.py Implements the new input() and add_output() methods on the GraphBuilder class with full parameter support and documentation
onnxscript/_internal/builder_test.py Adds three new test methods covering the behavior of input(), add_output(), and initializer() qualification

Comment thread onnxscript/_internal/builder.py
Comment thread onnxscript/_internal/builder_test.py
Comment thread onnxscript/_internal/builder_test.py
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 98.14815% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.83%. Comparing base (ef2bc22) to head (e725875).
⚠️ Report is 25 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
onnxscript/_internal/builder.py 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2828      +/-   ##
==========================================
+ Coverage   71.78%   71.83%   +0.05%     
==========================================
  Files         239      239              
  Lines       28989    29043      +54     
  Branches     2859     2861       +2     
==========================================
+ Hits        20809    20864      +55     
+ Misses       7209     7208       -1     
  Partials      971      971              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread onnxscript/_internal/builder.py
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment thread onnxscript/_internal/builder.py
Comment thread onnxscript/_internal/builder.py
Comment thread onnxscript/_internal/builder.py
Comment thread onnxscript/_internal/builder_test.py
@gramalingam gramalingam enabled auto-merge (squash) April 10, 2026 21:13
@gramalingam gramalingam merged commit c7d13fb into main Apr 10, 2026
36 of 37 checks passed
@gramalingam gramalingam deleted the input-output branch April 10, 2026 21:13
justinchuby added a commit that referenced this pull request Apr 17, 2026
This pull request adds new methods to the `GraphBuilder` class to
simplify the creation and management of graph inputs and outputs, and
introduces corresponding unit tests to ensure their correct behavior.
The changes improve the usability and reliability of the graph-building
API.

**Enhancements to the GraphBuilder API:**

* Added a new `input` method to `GraphBuilder` for creating and
registering graph input values with support for specifying name, dtype,
shape, type, constant value, and metadata properties.
* Added a new `add_output` method to `GraphBuilder` to append an output
value to the graph and optionally rename it.

---------

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

3 participants