tvm_tirx.script.ir_builder.parser_protocol.function_#
- tvm_tirx.script.ir_builder.parser_protocol.function_(*, decl=False, loc=None, **options)#
Create the native function frame used for signature and body construction.
- Parameters:
decl (bool, optional) – False (default) constructs a complete function on one entry. True collects a signature on the first entry and retains this frame for body re-entry.
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.
options (Any) – Language variant options: primitive function
privateandpersistentdefault to False. Relaxpuredefaults to True andprivate/localto False;local=Truerequires a declared reference when building its body. Seetvm_tirx.tirx.script.ir_builder.function_()andtvm.relax.script.ir_builder.function_()for their concrete options.
- Returns:
IRBuilderFrame – The native context manager. It owns params, result type, symbol map, reference and completed result.
- Return type:
IRBuilderFrame
Notes
Requires an active IRBuilder; module definitions also require its module frame. Declare every sibling signature before any body for forward references. Re-enter the same frame, define and invoke a zero-argument lexical helper inside it, then exit before validation. Invalid options/context raise builder errors. The frame stores its source location independently of exit-time ambient context.
# Source @T.function def f(a: T.int32): T.evaluate(a) # Generated builder with X.function_() as fn: X.func_name_("f") a = X.arg_("a", X.int32) X.emit_(X.evaluate(a))