-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix!: Ops require their own extension #1226
Conversation
0e6fd1e
to
d4d1c4e
Compare
c0d6432
to
ce6638f
Compare
ce6638f
to
a238f21
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1226 +/- ##
==========================================
- Coverage 87.18% 87.09% -0.10%
==========================================
Files 107 99 -8
Lines 19538 18959 -579
Branches 17276 17302 +26
==========================================
- Hits 17034 16512 -522
+ Misses 1719 1663 -56
+ Partials 785 784 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Nice! We can finally close one of the longest-standing issues.
I mostly have doc comments.
I agree with having the _exts
suffix variants.
It's better to not muddle things with another trait that will still be set to None
most of the time.
I'd just suggest swapping the extra argument to the end, to keep it consistent with the non-suffix ones.
f(*inputs, *outputs)
f_exts(*inputs, *outputs, extension_delta)
Also, it's not part of this PR but I think the ::builder::{ft1, ft2}
helpers are quite confusing. They are used in doc examples but their names don't say anything (they rather look like local variables).
@@ -449,12 +470,12 @@ pub trait Dataflow: Container { | |||
/// | |||
/// This function will return an error if there is an error when building | |||
/// the Conditional node. | |||
fn conditional_builder( | |||
fn conditional_builder_exts( |
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.
Mention extension_delta
in the fn docs.
hugr-core/src/builder/cfg.rs
Outdated
/// Return a builder for the entry [`DataflowBlock`] child graph with `inputs` | ||
/// and `outputs` and the variants of the branching Sum value | ||
/// specified by `sum_rows`. |
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.
/// Return a builder for the entry [`DataflowBlock`] child graph with `inputs` | |
/// and `outputs` and the variants of the branching Sum value | |
/// specified by `sum_rows`. | |
/// Return a builder for the entry [`DataflowBlock`] child graph with | |
/// `outputs`, the variants of the branching Sum value | |
/// specified by `sum_rows`, and `extension_delta` explicitly specified. |
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.
Yes, pretty much did this, also noted that delta will be inferred on the implicit version
hugr-core/src/builder/cfg.rs
Outdated
/// Return a builder for the entry [`DataflowBlock`] child graph with `inputs` | ||
/// and `outputs` and a UnitSum type: a Sum of `n_cases` unit types. |
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.
/// Return a builder for the entry [`DataflowBlock`] child graph with `inputs` | |
/// and `outputs` and a UnitSum type: a Sum of `n_cases` unit types. | |
/// Return a builder for the entry [`DataflowBlock`] child graph with | |
/// `outputs`, a Sum of `n_cases` unit types, and `extension_delta` | |
/// explicitly specified. |
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 fact I removed mention of non-existent parameter inputs
from both, too. Plus cross-link.
In response to [this comment](#1226 (review)) that "the builder...helpers are quite confusing", this offers a better compromise between brevity and readability, i.e. slightly more of the latter. BREAKING CHANGE: builder::ft1 is now `builder::endo_ft`, similarly `ft2` is new `inout_ft`
Description cleaned up - note
|
Thanks @aborgna-q - merged with #1297 rename, added docs cross-links (I can take those out if you don't like them, but I think it's fine to put them in one way only, we want to encourage use of inference-by-default) |
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.
Nice.
I don't want to get too caught up on the docs wording, so feel free to merge.
/// | ||
/// The `other_inputs` must be an iterable over pairs of the type of the input and | ||
/// the corresponding wire. | ||
/// The `outputs` are the types of the outputs. Extension delta will be inferred. |
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.
/// The `outputs` are the types of the outputs. Extension delta will be inferred. | |
/// The `output_types` are the types of the outputs. Extension delta will be inferred. |
/// The `outputs` are the types of the outputs. | ||
/// `exts` is the extension delta, here explicit. [conditional_builder](Self::conditional_builder) may be used to infer. |
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.
Using the same names as the parameters
/// The `outputs` are the types of the outputs. | |
/// `exts` is the extension delta, here explicit. [conditional_builder](Self::conditional_builder) may be used to infer. | |
/// The `output_types` are the types of the outputs. | |
/// `extension_delta` defines an explicit delta for the conditional. See [conditional_builder](Self::conditional_builder) may be used to infer it instead. |
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.
Yes-ish
## 🤖 New release * `hugr`: 0.7.0 -> 0.8.0 * `hugr-core`: 0.4.0 -> 0.5.0 * `hugr-passes`: 0.4.0 -> 0.5.0 * `hugr-cli`: 0.1.3 -> 0.1.4 <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr` <blockquote> ## 0.8.0 (2024-07-16) ### Bug Fixes - [**breaking**] Force_order failing on Const nodes, add arg to rank. ([#1300](#1300)) - NonConvex error on SiblingSubgraph::from_nodes with multiports ([#1295](#1295)) - [**breaking**] Ops require their own extension ([#1226](#1226)) ### Documentation - Attempt to correct force_order docs ([#1299](#1299)) ### Features - Make `DataflowOpTrait` public ([#1283](#1283)) - Make op members consistently public ([#1274](#1274)) ### Refactor - [**breaking**] Rename builder helpers: ft1->endo_ft, ft2->inout_ft ([#1297](#1297)) </blockquote> ## `hugr-core` <blockquote> ## 0.5.0 (2024-07-16) ### Bug Fixes - NonConvex error on SiblingSubgraph::from_nodes with multiports ([#1295](#1295)) - [**breaking**] Ops require their own extension ([#1226](#1226)) ### Features - Make `DataflowOpTrait` public ([#1283](#1283)) - Make op members consistently public ([#1274](#1274)) ### Refactor - [**breaking**] Rename builder helpers: ft1->endo_ft, ft2->inout_ft ([#1297](#1297)) </blockquote> ## `hugr-passes` <blockquote> ## 0.5.0 (2024-07-16) ### Bug Fixes - [**breaking**] Ops require their own extension ([#1226](#1226)) - [**breaking**] Force_order failing on Const nodes, add arg to rank. ([#1300](#1300)) ### Documentation - Attempt to correct force_order docs ([#1299](#1299)) ### Refactor - [**breaking**] Rename builder helpers: ft1->endo_ft, ft2->inout_ft ([#1297](#1297)) </blockquote> ## `hugr-cli` <blockquote> ## 0.1.3 (2024-07-10) ### Styling - Change "serialise" etc to "serialize" etc. ([#1251](#1251)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/).
closes #1318 and also deals with BlockBuilder not mentioned there. I think this is now all of the nested-structures covered: | | XBuilder::new | fn x | |----|----|----| |Conditional|**here**|in #1226| |\->Case|takes `Signature`|inherits exts| |TailLoop|**here**|**here**| |DFG|takes `Signature`|takes `Signature` (`dfg_builder_endo` in #1219)| |CFG|takes `Signature`|**here**| |\->Block|**here**|in #1226| (FuncDefn takes `Signature` and is *not supported by inference yet* anyway) BREAKING CHANGE: `cfg_builder`, `tail_loop_builder`, `ConditionalBuilder::new`, `BlockBuilder::new` and `TailLoopBuilder::new` no longer take an ExtensionSet parameter; either remove the argument (to use extension inference) or use the `_exts` variant
Includes adding new variants of
block_builder
,entry_builder
,simple_entry_builder
andconditional_builder
: the default version omits the extension set parameter, the_exts
variant takes an extra parameter (being an ExtensionSet).simple_block_builder
is untouched (as it takes a FunctionType, so can useendo_ft
/inout_ft
)We'll need similar updates to
cfg_builder
,tail_loop_builder
,ConditionalBuilder::new
andTailLoopBuilder::new
but I'll leave those for another PR, there's quite enough here ;)closes #388
BREAKING CHANGE: (1) container-node extension-deltas will need to be enlarged to include ops therein; for FuncDefn this will have to be manually specified but for other containers TO_BE_INFERRED,
endo_ft
orinout_ft
all work. (2)block_builder
,entry_builder
,simple_entry_builder
andconditional_builder
no longer take an ExtensionSet; either drop the argument or use the..._exts
variant.