tvm_tirx.script.ir_builder.parser_protocol.bind_

Contents

tvm_tirx.script.ir_builder.parser_protocol.bind_#

tvm_tirx.script.ir_builder.parser_protocol.bind_(value=MISSING, *, ty=None, name=None, loc=None, value_loc=None, name_loc=None, frame_value=False)#

Apply the language variant’s ordinary assignment policy.

Parameters:
  • value (Any, optional) – Once-evaluated RHS. MISSING (the default) denotes an omitted initializer and is rejected unless the language variant supports the annotation-only form.

  • ty (Type or annotation callable, optional) – Already-rewritten source annotation. None (the default) lets the language variant infer the binding type.

  • name (str, optional) – Source target name. None (the default) requests no source-derived name.

  • loc (LocationEntry, Location or None, optional) – Binding-target location for a newly constructed binding. None (the default) leaves it unspecified; this is separate from the RHS location.

  • value_loc (LocationEntry, Location or None, optional) – RHS source location, passed separately without first stamping the returned value. None (the default) leaves explicit RHS attribution unspecified. The language variant applies it only when binding/conversion requires value attribution; TIRx variable and metadata passthrough retain producer names and locs.

  • name_loc (LocationEntry, Location or None, optional) – Location of the target identifier. None (the default) uses loc; it can differ from the emitted statement location.

  • frame_value (bool, optional) – False by default. True names an already-entered with-target without constructing another binding or entering its frame.

Returns:

Any – The value bound to the Python target; usually a native variable, or an unchanged host/frame-owned value.

Return type:

Any

Notes

Requires the language variant construction context when producing IR. TIRx emits immutable Bind statements; Relax emits normalized bindings and match-casts. Unsupported values/annotations raise TypeError or ValueError. Ordinary TIRx Vars (including TensorVars) pass through before general Expr binding, without naming, stamping or another binding. Other Expr values retain ordinary language variant binding. Non-Expr metadata such as Layout and ordinary meta_class instances passes through unchanged without inspecting or naming its resources. Explicit typed declarations, mutable storage and frame targets retain their separate contracts. AlreadyEmitted receipts retain RHS attribution without another emission. A DSL may opt into concise scope entry: register the returned child frame’s exit callback on the active parent before child entry, then return its entered value. Later statements enter that child, and parent exit closes it. This is language variant policy; it adds no parser-owned scope state. Direct-call results and source module aliases bypass this operation.

# Source
x = value
# Generated builder
x = X.bind_(value, name="x", loc=_L_0, value_loc=_L_1)

# TIRx concise scope entry
tid = T.launch_thread("threadIdx.x", 128)
# Generated builder
tid = X.bind_(X.launch_thread("threadIdx.x", 128), name="tid")