Skip to content
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

Incorrect Call input ports in docs. #778

Closed
aborgna-q opened this issue Jan 4, 2024 · 0 comments · Fixed by #783
Closed

Incorrect Call input ports in docs. #778

aborgna-q opened this issue Jan 4, 2024 · 0 comments · Fixed by #783
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@aborgna-q
Copy link
Collaborator

The Call operation is defined as:

hugr/src/ops/dataflow.rs

Lines 133 to 137 in 968c8b0

/// Call a function directly.
///
/// The first ports correspond to the signature of the function being
/// called. Immediately following those ports, the first input port is
/// connected to the def/declare block with a `ConstE<Graph>` edge.

However, it's dataflow input is just the called function's signature

hugr/src/ops/dataflow.rs

Lines 152 to 154 in 968c8b0

fn signature(&self) -> FunctionType {
self.signature.clone()
}

And only after those ports comes the static_port with the called function (hard-coded in OpType::other_static_input.

hugr/src/ops.rs

Lines 187 to 194 in 968c8b0

/// If the op has a static input (Call and LoadConstant), the port of that input.
pub fn static_input_port(&self) -> Option<IncomingPort> {
match self {
OpType::Call(call) => Some(call.called_function_port()),
OpType::LoadConstant(l) => Some(l.constant_port()),
_ => None,
}
}

@aborgna-q aborgna-q added bug Something isn't working documentation Improvements or additions to documentation labels Jan 4, 2024
github-merge-queue bot pushed a commit that referenced this issue Jan 8, 2024
Closes #777.

Now `OpTrait` clearly separates `other_port` from `static_port`, and
`OpType` has a uniform interface for `value` ports (from the signature),
`static` ports (contstants), and `other` ports.

Fixes #779. The bug was caused by the encoder ignoring the constant
input port offset, so the decoder reconnected the edge to the
`StateOrder` port instead. Now we use the proper OpType methods.

Fixes #778.

---------

Co-authored-by: Seyon Sivarajah <seyon.sivarajah@quantinuum.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant