-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Labels
mlir:pythonMLIR Python bindingsMLIR Python bindings
Description
Adding the following test case to mlir/test/python/dialects/scf.py demonstrates the behavior:
@constructAndPrintInModule
def testIndexSwitch():
from mlir.extras import types as T
i32 = T.i32()
@func.FuncOp.from_py_func(T.index())
def index_switch(index):
c1 = arith.constant(i32, 1)
switch_op = scf.IndexSwitchOp(results_=[i32], arg=index, cases=range(3), num_caseRegions=3)
print(f"{len(switch_op.regions)=}")
print(f"{len(switch_op.regions[2:])=}")
print(f"{len([i for i in switch_op.regions[2:]])=}")
print(f"{len(switch_op.caseRegions)=}")
print(f"{len([i for i in switch_op.caseRegions])=}")TEST: testIndexSwitch
len(switch_op.regions)=4
len(switch_op.regions[2:])=2
len([i for i in switch_op.regions[2:]])=4
len(switch_op.caseRegions)=3
len([i for i in switch_op.caseRegions])=4
"builtin.module"() ({
"func.func"() <{function_type = (index) -> (), sym_name = "index_switch"}> ({
^bb0(%arg0: index):
%0 = "arith.constant"() <{value = 1 : i32}> : () -> i32
%1 = "scf.index_switch"(%arg0) <{cases = array<i64: 0, 1, 2>}> ({
}, {
}, {
}, {
}) : (index) -> i32
"func.return"() : () -> ()
}) : () -> ()
}) : () -> ()
git show HEAD
'242d0c770ca3 Tue Nov 11 04:48:30 2025 +0000 (HEAD -> main, origin/main, origin/HEAD) SplitKit: Use initializer lists (#167449)'
Metadata
Metadata
Assignees
Labels
mlir:pythonMLIR Python bindingsMLIR Python bindings