How to use transform.split_handle op in python?

Hi!

I’m trying to use the transform.split_handle op in Python (MLIR python binding), but the op is not implemented in mlir/python/mlir/dialects/transform/structured.py; I tried a few ways but failed. I also didn’t find any example of doing so in the project; I would like to know if there is a way to use that op in Python.

with InsertionPoint(module.body):
        call = structured.MatchOp.match_op_names(sequence.bodyTarget, ["func.call"])
        transform.SplitHandleOp(call)

The signature for constructing SplitHandleOp is

def __init__(self, results_, handle, *, 
    pass_through_empty_handle=None, 
    fail_on_payload_too_small=None, 
    overflow_result=None, loc=None, ip=None):

so your snippet is missing the list of results. It is only logical since the op needs to somehow know into how many handles to split the given handle.

It is possible to find auto-generated signatures by inspecting _transform_ops_gen.py, or similar files, in the build directory. For my setup, it is build/tools/mlir/python/dialects/_transform_ops_gen.py.

Also note that this op is not part of the “structured” subset, as its name indicates, so it won’t be found in structured.py.