Skip to content

Commit 44643f7

Browse files
authored
Merge branch 'feature/visualize-nodes' into feature/connect-nodes
2 parents d143ed0 + bafd278 commit 44643f7

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
@@ -427,12 +427,16 @@ def _flatten_if_op(op: scf.IfOp) -> list[Region]:
427427
has_quantum_ops = False
428428
nested_if_op = None
429429
for op in else_block.ops:
430+
if isinstance(op, scf.IfOp):
431+
nested_if_op = op
432+
# No need to walk this op as this will be
433+
# recursively handled down below
434+
continue
430435
for internal_op in op.walk():
431-
if isinstance(internal_op, scf.IfOp):
432-
nested_if_op = internal_op
433-
break
434-
if "quantum" in internal_op.name:
436+
if type(internal_op) in quantum.Quantum.operations:
435437
has_quantum_ops = True
438+
# No need to check anything else
439+
break
436440

437441
if nested_if_op and not has_quantum_ops:
438442
# Recursively flatten any IfOps found in said block

0 commit comments

Comments
 (0)