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
## Description
Adds a `qc.inv` and `qco.inv` Op, similar to the existing `CtrlOp`.
**Example**:
QC:
```mlir
qc.inv {
qc.s %q0 : !qc.qubit
}
```
QCO:
```mlir
%targets_out = qco.inv (%arg0 = %targets_in) {
%targets_res = qco.s %arg0 : !qco.qubit -> !qco.qubit
qco.yield %targets_res : !qco.qubit
} : {!qco.qubit} -> {!qco.qubit}
```
**Things to note:**
- The canonicalizations are currently in QCO (such as replacing known
gates with their inverse). Could happen already in QC or in both.
- QuantumComputing (which eagerly replaces gates by their inverse) is
not touched by this PR. Afaik, the QC and QCO dialects are not directly
used by QuantumComputing yet.
- Missing: Handling of invs of unknown gates, for example iSWAP (the
only standard gate for which there's no "trivial" inverse). `inv { iSWAP
}` will currently error on the translation to QIR. A reasonable tactic
could be to get the inverse unitary matrix and decompose it into native
gates. I think this is outside the scope of this PR, though.
Fixes#1130
## Checklist:
- [x] The pull request only contains commits that are focused and
relevant to this change.
- [x] I have added appropriate tests that cover the new/changed
functionality.
- [x] I have updated the documentation to reflect these changes.
- [ ] I have added entries to the changelog for any noteworthy
additions, changes, fixes, or removals.
- [ ] I have added migration instructions to the upgrade guide (if
needed).
- [x] The changes follow the project's style guidelines and introduce no
new warnings.
- [x] The changes are fully tested and pass the CI checks.
- [x] I have reviewed my own code changes.
---------
Signed-off-by: burgholzer <[email protected]>
Co-authored-by: burgholzer <[email protected]>
0 commit comments