-
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
Changes from 21 commits
7832cf0
d6802c3
2c32b1a
5cb15ca
5b05df3
78f7aed
856bfd4
b2c09d5
10bab5d
9e47b98
290bb6a
eca016d
abbfa2a
3994ee9
0da41d8
a238f21
79da288
ab4ef40
1b5eebd
eb6d1d0
a574c6d
aaa1cf3
2c56bf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -437,24 +437,46 @@ pub trait Dataflow: Container { | |||||||||
TailLoopBuilder::create_with_io(self.hugr_mut(), loop_node, &tail_loop) | ||||||||||
} | ||||||||||
|
||||||||||
/// Return a builder for a [`crate::ops::Conditional`] node. | ||||||||||
/// `sum_input` is a tuple of the type of the Sum | ||||||||||
/// variants and the corresponding wire. | ||||||||||
/// | ||||||||||
/// 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. | ||||||||||
/// | ||||||||||
/// # Errors | ||||||||||
/// | ||||||||||
/// This function will return an error if there is an error when building | ||||||||||
/// the Conditional node. | ||||||||||
fn conditional_builder( | ||||||||||
&mut self, | ||||||||||
sum_input: (impl IntoIterator<Item = TypeRow>, Wire), | ||||||||||
other_inputs: impl IntoIterator<Item = (Type, Wire)>, | ||||||||||
output_types: TypeRow, | ||||||||||
) -> Result<ConditionalBuilder<&mut Hugr>, BuildError> { | ||||||||||
self.conditional_builder_exts(sum_input, other_inputs, TO_BE_INFERRED, output_types) | ||||||||||
} | ||||||||||
|
||||||||||
/// Return a builder for a [`crate::ops::Conditional`] node. | ||||||||||
/// `sum_rows` and `sum_wire` define the type of the Sum | ||||||||||
/// variants and the wire carrying the Sum respectively. | ||||||||||
/// | ||||||||||
/// 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. | ||||||||||
/// `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 commentThe reason will be displayed to describe this comment to others. Learn more. Using the same names as the parameters
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes-ish |
||||||||||
/// | ||||||||||
/// # Errors | ||||||||||
/// | ||||||||||
/// 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 commentThe reason will be displayed to describe this comment to others. Learn more. Mention |
||||||||||
&mut self, | ||||||||||
(sum_rows, sum_wire): (impl IntoIterator<Item = TypeRow>, Wire), | ||||||||||
other_inputs: impl IntoIterator<Item = (Type, Wire)>, | ||||||||||
extension_delta: impl Into<ExtensionSet>, | ||||||||||
output_types: TypeRow, | ||||||||||
extension_delta: ExtensionSet, | ||||||||||
) -> Result<ConditionalBuilder<&mut Hugr>, BuildError> { | ||||||||||
let mut input_wires = vec![sum_wire]; | ||||||||||
let (input_types, rest_input_wires): (Vec<Type>, Vec<Wire>) = | ||||||||||
|
@@ -471,7 +493,7 @@ pub trait Dataflow: Container { | |||||||||
sum_rows, | ||||||||||
other_inputs: inputs, | ||||||||||
outputs: output_types, | ||||||||||
extension_delta, | ||||||||||
extension_delta: extension_delta.into(), | ||||||||||
}, | ||||||||||
input_wires, | ||||||||||
)?; | ||||||||||
|
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.