-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add hugr-core StaticGraph, deprecate hugr-passes CallGraph #2698
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2698 +/- ##
==========================================
- Coverage 83.53% 83.49% -0.05%
==========================================
Files 264 265 +1
Lines 51538 51643 +105
Branches 47006 47108 +102
==========================================
+ Hits 43051 43117 +66
- Misses 6114 6154 +40
+ Partials 2373 2372 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mark-koch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
In terms of naming, I think I slightly prefer ModuleGraph since it only contains nodes on module level and not all static edges are included (e.g. consts inside functions)
| } | ||
|
|
||
| /// Details the [`FuncDefn`]s, [`FuncDecl`]s and module-level [`Const`]s in a Hugr, | ||
| /// in a Hugr, along with the [`Call`]s, [`LoadFunction`]s, and [`LoadConstant`]s connecting them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// in a Hugr, along with the [`Call`]s, [`LoadFunction`]s, and [`LoadConstant`]s connecting them. | |
| /// along with the [`Call`]s, [`LoadFunction`]s, and [`LoadConstant`]s connecting them. |
hugr-core/src/static_graph.rs
Outdated
| } | ||
|
|
||
| impl<N: HugrNode> StaticGraph<N> { | ||
| /// Makes a new `CallGraph` for a Hugr. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// Makes a new `CallGraph` for a Hugr. | |
| /// Makes a new `StaticGraph` for a Hugr. |
| /// | ||
| /// If the node is not recognised as a function or the entrypoint, | ||
| /// for example if it is a [`Const`](OpType::Const), the iterator will be empty. | ||
| pub fn out_edges(&self, n: N) -> impl Iterator<Item = (&StaticEdge<N>, &StaticNode<N>)> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also want an in_edges method?
Respin of #2531, marking the node/edge enums in the new StaticGraph as
non-exhaustiveand adding Consts + LoadConstants.(Lukas originally planned to make something like this to reflect references from Terms to functions, and non-exhaustive allows extending this StaticGraph for that purpose - if we do go that way, however, I have a different plan, can describe if relevant. Rather I think non-exhaustive is just a reasonable allowance for future extension to new use-cases hopefully without damaging existing use-cases.)
This is taken from #2555, i.e. which uses it (although there it is still called CallGraph in hugr-core).
Naming: could be ModuleGraph ?? Other ideas welcome.
I will add a test with some Consts + use of
out_edges(tho will be supplied in #2555 !)