Skip to content

fix: Fix inline_constant_functions pass #2135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025

Conversation

mark-koch
Copy link
Contributor

Fixes #2132

@mark-koch mark-koch requested a review from doug-q April 29, 2025 09:53
@mark-koch mark-koch requested a review from a team as a code owner April 29, 2025 09:53
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.16%. Comparing base (9cd24ff) to head (527ad1c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2135   +/-   ##
=======================================
  Coverage   82.15%   82.16%           
=======================================
  Files         227      227           
  Lines       39891    39897    +6     
  Branches    35990    35996    +6     
=======================================
+ Hits        32774    32781    +7     
+ Misses       5287     5286    -1     
  Partials     1830     1830           
Flag Coverage Δ
python 85.64% <ø> (ø)
rust 81.78% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@doug-q doug-q left a comment

Choose a reason for hiding this comment

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

Thanks Mark, one suggestion

hugr.insert_hugr(func_node, func_hugr);
func_hugr.replace_op(func_hugr.root(), func_defn).unwrap();
let func_node = hugr.insert_hugr(hugr.root(), func_hugr).new_root;
hugr.set_num_ports(func_node, 0, 1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

use add_ports here, and use the port it returns

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is about removing ports: If the inlined function value is a DFG, then it already has some inputs/outputs that we need to remove because it's now a FuncDefn


for lcn in load_constant_ns {
hugr.replace_op(lcn, LoadFunction::try_new(polysignature.clone(), [])?)?;

let src_port = hugr.node_outputs(func_node).next().unwrap();
let tgt_port = hugr.node_inputs(lcn).next().unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to delegate to LoadConstant what the input is. You don't have one at hand, so maybe not worth it.

@mark-koch mark-koch force-pushed the fix/inline_constant_functions branch from 15988dd to 527ad1c Compare May 7, 2025 11:05
@mark-koch mark-koch added this pull request to the merge queue May 7, 2025
Merged via the queue into main with commit 53d7282 May 7, 2025
27 checks passed
@mark-koch mark-koch deleted the fix/inline_constant_functions branch May 7, 2025 11:23
This was referenced May 7, 2025
@hugrbot hugrbot mentioned this pull request May 14, 2025
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.

inline_constant_functions pass produces invalid Hugrs
2 participants