Skip to content

Conversation

justinchuby
Copy link
Member

No description provided.

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Copy link
Contributor

@Copilot 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 PR prevents values already produced by nodes from being added as graph inputs by adding a check in _set_graph.

  • Adds a guard in _set_graph to raise an error if value has a producer.
  • Ensures graph inputs are only values without an existing producer.
Comments suppressed due to low confidence (1)

src/onnx_ir/_graph_containers.py:156

  • There's a syntax error: the f-string literal isn't closed. Add the missing closing quote before the parenthesis. For example:
raise ValueError(f"Value '{value}' is produced by a node and cannot be an input to the graph")
raise ValueError(f"Value '{value}' is produced by a node and cannot be an input to the graph)

Copy link

codecov bot commented Jun 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.75%. Comparing base (eede39b) to head (d2a0fe3).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
+ Coverage   81.72%   81.75%   +0.02%     
==========================================
  Files          57       57              
  Lines        6955     6965      +10     
  Branches      947      948       +1     
==========================================
+ Hits         5684     5694      +10     
  Misses        905      905              
  Partials      366      366              

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

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Copy link
Collaborator

@titaiwangms titaiwangms left a comment

Choose a reason for hiding this comment

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

I wonder if this breaks the input of subgraphs? Isn't subgraph using node outputed vlaues?

@justinchuby
Copy link
Member Author

justinchuby commented Jun 2, 2025

I wonder if this breaks the input of subgraphs? Isn't subgraph using node outputed vlaues?

It shouldn’t. There are two ways for subgraphs to use external values. One is by implicitly capturing and directly referring to those values in the subgraphs, which is what we do with the If op. The other is to define graph inputs and explicitly define in the op definition how these inputs correlates with the node inputs. (Aka the values are connected according to the op definition, not graph topology). This is what happens with the subgraph inputs of the Scan op.

@justinchuby justinchuby merged commit d28c4e6 into main Jun 2, 2025
24 checks passed
@justinchuby justinchuby deleted the justinchu/graph-input-check branch June 2, 2025 19:46
titaiwangms pushed a commit to titaiwangms/ir-py that referenced this pull request Jun 2, 2025
…nnx#51)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants