mlir.dialects.scf

Classes

ForOp

Specialization for the SCF for op class.

ForallOp

Specialization for the SCF forall op class.

InParallelOp

Specialization of the SCF forall.in_parallel op class.

IfOp

Specialization for the SCF if op class.

IndexSwitchOp

The scf.index_switch is a control-flow operation that branches to one of

Functions

_dispatch_index_op_fold_results(→ Tuple[List[Value], ...)

mlir::dispatchIndexOpFoldResults

for_(start[, stop, step, iter_args, loc, ip])

index_switch(→ Union[OpResult, OpResultList, ...)

Module Contents

class mlir.dialects.scf.ForOp(lower_bound, upper_bound, step, iter_args: Operation | OpView | Sequence[Value] | None = None, *, loc=None, ip=None)

Bases: ForOp

Specialization for the SCF for op class.

property body

Returns the body (block) of the loop.

property induction_variable

Returns the induction variable of the loop.

property inner_iter_args

Returns the loop-carried arguments usable within the loop.

To obtain the loop-carried operands, use iter_args.

mlir.dialects.scf._dispatch_index_op_fold_results(ofrs: Sequence[Operation | OpView | Value | int]) Tuple[List[Value], List[int]]

mlir::dispatchIndexOpFoldResults

class mlir.dialects.scf.ForallOp(lower_bounds: Sequence[Operation | OpView | Value | int], upper_bounds: Sequence[Operation | OpView | Value | int], steps: Sequence[Value | int], shared_outs: Operation | OpView | Sequence[Value] | None = None, *, mapping=None, loc=None, ip=None)

Bases: ForallOp

Specialization for the SCF forall op class.

property body: Block

Returns the body (block) of the loop.

property rank: int

Returns the number of induction variables the loop has.

property induction_variables: BlockArgumentList

Returns the induction variables usable within the loop.

property inner_iter_args: BlockArgumentList

Returns the loop-carried arguments usable within the loop.

To obtain the loop-carried operands, use iter_args.

terminator() InParallelOp

Returns the loop terminator if it exists. Otherwise, creates a new one.

class mlir.dialects.scf.InParallelOp(loc=None, ip=None)

Bases: InParallelOp

Specialization of the SCF forall.in_parallel op class.

property block: Block
class mlir.dialects.scf.IfOp(cond, results_=None, *, hasElse=False, loc=None, ip=None)

Bases: IfOp

Specialization for the SCF if op class.

property then_block

Returns the then block of the if operation.

property else_block

Returns the else block of the if operation.

mlir.dialects.scf.for_(start, stop=None, step=None, iter_args: Sequence[Value] | None = None, *, loc=None, ip=None)
class mlir.dialects.scf.IndexSwitchOp(results, arg, cases, case_body_builder=None, default_body_builder=None, loc=None, ip=None)

Bases: IndexSwitchOp

The scf.index_switch is a control-flow operation that branches to one of the given regions based on the values of the argument and the cases. The argument is always of type index.

The operation always has a “default” region and any number of case regions denoted by integer constants. Control-flow transfers to the case region whose constant value equals the value of the argument. If the argument does not equal any of the case values, control-flow transfer to the “default” region.

Example:

%0 = scf.index_switch %arg0 : index -> i32
case 2 {
  %1 = arith.constant 10 : i32
  scf.yield %1 : i32
}
case 5 {
  %2 = arith.constant 20 : i32
  scf.yield %2 : i32
}
default {
  %3 = arith.constant 30 : i32
  scf.yield %3 : i32
}
__doc__
property default_region: Region
property default_block: Block
property case_regions: Sequence[Region]
case_region(i: int) Region
property case_blocks: Sequence[Block]
case_block(i: int) Block
mlir.dialects.scf.index_switch(results, arg, cases, case_body_builder=None, default_body_builder=None, loc=None, ip=None) OpResult | OpResultList | IndexSwitchOp