tvm_tirx.script.ir_builder.parser_protocol.then_

Contents

tvm_tirx.script.ir_builder.parser_protocol.then_#

tvm_tirx.script.ir_builder.parser_protocol.then_(*, loc=None)#

Create the true branch of the active conditional.

Parameters:

loc (LocationEntry, Location or None, optional) – Location for the constructed result. None (the default) leaves explicit location unspecified; active source-call provenance is composed by the builder. Frames retain their location until finalization.

Returns:

IRBuilderFrame – The native branch context manager; its exit finalizes its region.

Return type:

IRBuilderFrame

Notes

Requires an active if_ frame and records the true branch. Invalid ordering or repeated branches raise native builder errors. The frame stores its source location; statements keep their individual locations. Lexical helpers take zero explicit arguments and run inside the entered frame.

# Source
if condition:
    pass
else:
    pass
# Generated builder, inside X.if_(condition)
with X.then_():
    def branch():
        pass
    branch()