-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
291 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from .utils import bc_to_module, is_entry_point, to_circuit | ||
|
||
from pytket.circuit import Circuit | ||
|
||
|
||
def qir_to_pytket(qir_bitcode: bytes) -> Circuit: | ||
"""Convert QIR to a pytket circuit. | ||
:param qir_bitcode: QIR bitcode | ||
:return: pytket circuit | ||
""" | ||
module = bc_to_module(qir_bitcode) | ||
entries = [f for f in module.functions if is_entry_point(f)] | ||
assert len(entries) == 1 | ||
blocks = list(entries[0].blocks) | ||
assert len(blocks) == 1 | ||
instructions = list( | ||
filter(lambda instr: instr.opcode == "call", blocks[0].instructions) | ||
) | ||
return to_circuit(instructions) |
Oops, something went wrong.