File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 55from bloqade .analysis .measure_id import MeasurementIDAnalysis
66from bloqade .stim .passes .flatten import Flatten
77from bloqade .analysis .measure_id .lattice import (
8+ AnyMeasureId ,
89 NotMeasureId ,
910 MeasureIdBool ,
1011 MeasureIdTuple ,
@@ -160,6 +161,33 @@ def test():
160161 assert len (analysis_results ) == 2
161162
162163
164+ def test_scf_cond_unknown ():
165+
166+ @squin .kernel
167+ def test (cond : bool ):
168+ q = squin .qalloc (5 )
169+ squin .x (q [2 ])
170+
171+ if cond :
172+ ms = squin .broadcast .measure (q )
173+ else :
174+ ms = squin .measure (q [0 ])
175+
176+ return ms
177+
178+ InlinePass (test .dialects ).fixpoint (test )
179+ frame , _ = MeasurementIDAnalysis (test .dialects ).run_analysis (test )
180+ # the result of the analysis on this Scf.IfElse should be two AnyMeasureIds.
181+ # One AnyMeasureId is from resolving the boolean type, which does not change
182+ # during any of the branches. The other is from the fact that broadcast.measure gives
183+ # an AnyMeasureId because it cannot figure out the concrete number of measurements, which has to be
184+ # joined against the MeasureIdBool from the other branch.
185+ assert list (frame .entries .values ())[- 2 :] == [AnyMeasureId (), AnyMeasureId ()]
186+
187+
188+ test_scf_cond_unknown ()
189+
190+
163191def test_slice ():
164192 @squin .kernel
165193 def test ():
You can’t perform that action at this time.
0 commit comments