Skip to content

Commit bafd278

Browse files
authored
Merge branch 'feature/control-flow-clusters' into feature/visualize-nodes
2 parents 74e8358 + d8c1b7a commit bafd278

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

frontend/catalyst/python_interface/visualization/construct_circuit_dag.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,16 @@ def _flatten_if_op(op: scf.IfOp) -> list[Region]:
357357
has_quantum_ops = False
358358
nested_if_op = None
359359
for op in else_block.ops:
360+
if isinstance(op, scf.IfOp):
361+
nested_if_op = op
362+
# No need to walk this op as this will be
363+
# recursively handled down below
364+
continue
360365
for internal_op in op.walk():
361-
if isinstance(internal_op, scf.IfOp):
362-
nested_if_op = internal_op
363-
break
364-
if "quantum" in internal_op.name:
366+
if type(internal_op) in quantum.Quantum.operations:
365367
has_quantum_ops = True
368+
# No need to check anything else
369+
break
366370

367371
if nested_if_op and not has_quantum_ops:
368372
# Recursively flatten any IfOps found in said block

0 commit comments

Comments
 (0)