Skip to content

Commit d765f09

Browse files
committed
fixed missing registry + improper impl returns
1 parent 5e1c221 commit d765f09

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

squin_op_playground.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,24 @@
33
from kirin.dialects import py, func
44

55
from bloqade import squin
6-
from bloqade.analysis import address
76
from bloqade.squin.analysis import shape
87

98

109
def as_int(value: int):
1110
return py.constant.Constant(value=value)
1211

1312

14-
squin_with_qasm_core = squin.groups.wired
13+
squin_with_qasm_core = squin.groups.wired.add(py)
1514

1615
stmts: list[ir.Statement] = [
1716
(h0 := squin.op.stmts.H()),
1817
(h1 := squin.op.stmts.H()),
1918
(hh := squin.op.stmts.Kron(lhs=h1.result, rhs=h0.result)),
20-
(func.Return(hh.result)),
19+
(chh := squin.op.stmts.Control(hh.result, n_controls=1)),
20+
(factor := as_int(1)),
21+
# schh for some reason causes it to blow up
22+
(schh := squin.op.stmts.Scale(chh.result, factor=factor.result)),
23+
(func.Return(schh.result)),
2124
]
2225

2326
block = ir.Block(stmts)
@@ -40,19 +43,18 @@ def as_int(value: int):
4043
fold_pass = Fold(squin_with_qasm_core)
4144
fold_pass(constructed_method)
4245

46+
""""
4347
address_frame, _ = address.AddressAnalysis(constructed_method.dialects).run_analysis(
4448
constructed_method, no_raise=False
4549
)
4650
51+
4752
constructed_method.print(analysis=address_frame.entries)
53+
"""
4854

4955
shape_frame, _ = shape.ShapeAnalysis(constructed_method.dialects).run_analysis(
5056
constructed_method, no_raise=False
5157
)
5258

53-
"""
54-
frame, _ = address.AddressAnalysis(constructed_method.dialects).run_analysis(
55-
constructed_method, no_raise=False
56-
"""
5759

5860
constructed_method.print(analysis=shape_frame.entries)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# Need this for impl registration to work properly!
2+
from . import impls as impls
13
from .analysis import ShapeAnalysis as ShapeAnalysis

src/bloqade/squin/analysis/shape/analysis.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ def initialize(self):
2626

2727
## This gets called before the registry look up
2828
def eval_stmt(self, frame: ForwardFrame, stmt: ir.Statement):
29-
# something fishy, registry pops up empty?
30-
# This doesn't happen with the
3129
method = self.lookup_registry(frame, stmt)
3230
if method is not None:
3331
return method(self, frame, stmt)

src/bloqade/squin/analysis/shape/impls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def control(
6161
@interp.impl(op.stmts.Rot)
6262
def rot(self, interp: ShapeAnalysis, frame: interp.Frame, stmt: op.stmts.Rot):
6363
op_shape = frame.get(stmt.axis)
64-
return op_shape
64+
return (op_shape,)
6565

6666
@interp.impl(op.stmts.Scale)
6767
def scale(self, interp: ShapeAnalysis, frame: interp.Frame, stmt: op.stmts.Scale):
6868
op_shape = frame.get(stmt.op)
69-
return op_shape
69+
return (op_shape,)

0 commit comments

Comments
 (0)