You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the Circuit trait is implemented on anything that implements HugrView.
That means you can ask for a CommandIterator over any Hugr. The logic is that any input linear wires go in to the indexable array, and CircuitUnit::Linear is used to refer to operations that update these linear operations.
Command of op on CircuitUnit::Linear(i) really means op takes the Wire corresponding to i and returns a Wire, and from now on i will refer to that new wire. This is useful for qubits because of how we are used to building quantum circuits, so I wonder if it is actually helpful to do it in general and not just for qubit types (and specific input qubits at that, like how the CircuitBuilder does it rather than all of them).
Further, if the op doesn't return a linear wire for every linear wire it took in (e.. MakeTuple) the current logic is that the previous indices no longer appear in commands and a new index is assigned for the new linear wire. I ran in to an issue where the tuple was then unpacked (and so in theory you could go back to using the old indices) but all the indices had now been shifted.
This behaviour is unintuitive, I suggest instead that the command iterator either terminates or errors when it cannot continue tracking every linear wire it has been charged with.
The text was updated successfully, but these errors were encountered:
Returns a subset of `Circuit::commands`, corresponding to the commands
counted by `Circuit::num_operations`.
This is useful to ignore `LoadConst`s and tuple operations when we only
care about "gate like" operations in the circuit. But mainly, it's meant
as an iterator with similar behaviour to `num_operations`.
Note that #199 is still an open issue; tuple operations in the middle of
the circuit may result in confusing linear indices.
Currently the
Circuit
trait is implemented on anything that implementsHugrView
.That means you can ask for a
CommandIterator
over any Hugr. The logic is that any input linear wires go in to the indexable array, andCircuitUnit::Linear
is used to refer to operations that update these linear operations.Command of
op
onCircuitUnit::Linear(i)
really meansop
takes the Wire corresponding toi
and returns a Wire, and from now oni
will refer to that new wire. This is useful for qubits because of how we are used to building quantum circuits, so I wonder if it is actually helpful to do it in general and not just for qubit types (and specific input qubits at that, like how theCircuitBuilder
does it rather than all of them).Further, if the
op
doesn't return a linear wire for every linear wire it took in (e..MakeTuple
) the current logic is that the previous indices no longer appear in commands and a new index is assigned for the new linear wire. I ran in to an issue where the tuple was then unpacked (and so in theory you could go back to using the old indices) but all the indices had now been shifted.This behaviour is unintuitive, I suggest instead that the command iterator either terminates or errors when it cannot continue tracking every linear wire it has been charged with.
The text was updated successfully, but these errors were encountered: