Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 16, 2025

The fix prevents removing initializers that are graph outputs during constant folding. This test validates that behavior.

Changes

  • Added test_initializer_as_graph_output_is_not_removed to verify initializers used in foldable nodes are preserved when they are graph outputs

Test Case

# Model with constant used in operation AND as graph output
agraph (float[N] x) => (float[N] y, float z) {
    constant = Constant <value_float=2.0> ()
    y = Mul(x, constant)
    z = Identity(constant)  # constant is also output
}

After constant folding:

  • Identity node is removed
  • Constant becomes initializer 'z'
  • Initializer 'z' is NOT removed despite having no uses (it's a graph output)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

gramalingam and others added 2 commits December 16, 2025 09:47
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unused initializer check in constant-folder Add test for unused initializer check with graph outputs Dec 16, 2025
Copilot AI requested a review from justinchuby December 16, 2025 18:23
@justinchuby justinchuby marked this pull request as ready for review December 16, 2025 18:24
Base automatically changed from rama/init-bug to main December 16, 2025 18:25
@justinchuby
Copy link
Collaborator

@gramalingam

@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.08%. Comparing base (f958061) to head (b719f4a).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2733   +/-   ##
=======================================
  Coverage   70.07%   70.08%           
=======================================
  Files         226      226           
  Lines       27276    27285    +9     
  Branches     2754     2754           
=======================================
+ Hits        19113    19122    +9     
  Misses       7213     7213           
  Partials      950      950           

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

@justinchuby justinchuby enabled auto-merge (squash) December 17, 2025 01:34
@justinchuby justinchuby merged commit 726be2b into main Dec 19, 2025
33 checks passed
@justinchuby justinchuby deleted the copilot/sub-pr-2732 branch December 19, 2025 18:54
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