amazon-braket-sdk-python
amazon-braket-sdk-python copied to clipboard
Implement Program -> Program transformation to inline a variable
A program with an input variable is transformed to replace the variable with a value and simplify the program where possible. Example:
import braket.experimental.autoqasm as aq
from braket.experimental.autoqasm.instructions import x
@aq.main
def flip_if_k_gt_5(k: int):
if k > 5:
x(0)
print(flip_if_k_gt_5.to_ir())
OPENQASM 3.0;
input int[32] k;
qubit[1] __qubits__;
bool __bool_0__;
__bool_0__ = k > 5;
if (__bool_0__) {
x __qubits__[0];
}
flip_if_7_gt_5 = flip_if_k_gt_5.inline(k=7)
print(flip_if_7_gt_5.to_ir())
OPENQASM 3.0;
qubit[1] __qubits__;
x __qubits__[0];