Target
QASM2
QASM2(
main_target: ir.DialectGroup | None = None,
gate_target: ir.DialectGroup | None = None,
qelib1: bool = False,
)
QASM2 target for Bloqade kernels.
QASM2 target that accepts a Bloqade kernel and produces an AST that you can then obtain a string for printing or saving as a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
main_target
|
DialectGroup | None
|
The dialects that were used in the definition of the kernel. This is used to
generate the correct header for the resulting QASM2 AST. Argument defaults to |
None
|
gate_target
|
DialectGroup | None
|
The dialects involved in defining any custom gates in the kernel. Argument defaults to |
None
|
qelib1
|
bool
|
Include the |
False
|
Source code in src/bloqade/qasm2/emit/target.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
emit
emit(entry: ir.Method) -> ast.MainProgram
Emit a QASM2 AST from the Bloqade kernel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry
|
Method
|
The Bloqade kernel to convert to the QASM2 AST |
required |
Returns:
Type | Description |
---|---|
MainProgram
|
ast.MainProgram: A QASM2 AST object |
Source code in src/bloqade/qasm2/emit/target.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
emit_str
emit_str(entry: ir.Method) -> str
Emit a QASM2 AST from the Bloqade kernel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry
|
Method
|
The Bloqade kernel to convert to the QASM2 AST |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A string with the QASM2 representation of the kernel |
Source code in src/bloqade/qasm2/emit/target.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|