DataflowBlock

class hugr.ops.DataflowBlock(inputs: list[Type], _sum: Sum | None = None, _other_outputs: list[Type] | None = None)[source]

Bases: DfParentOp

Parent of non-entry basic block in a control flow graph.

Methods

inner_signature

Inner signature of the child dataflow graph.

name

Name of the operation.

nth_outputs

The outputs passed to the nth successor of the block.

port_kind

Get the kind of the given port.

Attributes

num_out

The number of output ports for this operation.

other_outputs

The non-branching outputs of the block which are passed to all successors.

sum_ty

If set, the sum type that defines the potential branching of the block.

inputs

Inputs types of the inner dataflow graph.

inner_signature() FunctionType[source]

Inner signature of the child dataflow graph.

inputs: list[Type]

Inputs types of the inner dataflow graph.

name() str[source]

Name of the operation.

nth_outputs(n: int) list[Type][source]

The outputs passed to the nth successor of the block. Concatenation of the nth variant of the sum type and the other outputs.

property num_out: int

The number of output ports for this operation.

Example

>>> op = Const(val.TRUE)
>>> op.num_out
1
property other_outputs: list[Type]

The non-branching outputs of the block which are passed to all successors.

Raises:

IncompleteOp – If the outputs have not been set.

port_kind(port: InPort | OutPort) ValueKind | ConstKind | FunctionKind | CFKind | OrderKind[source]

Get the kind of the given port.

Example

>>> op = Const(val.TRUE)
>>> op.port_kind(OutPort(Node(0), 0))
ConstKind(Bool)
property sum_ty: Sum

If set, the sum type that defines the potential branching of the block.

Raises:

IncompleteOp – If the sum type has not been set.