tvm_tirx.script.ir_builder.IRBuilder#
- class tvm_tirx.script.ir_builder.IRBuilder#
Bases:
ObjectA shared construction context for any language variant’s IR.
Examples
Enter the builder before using a language variant’s construction frames. Each completed frame contributes to the result returned by
get.from tvm_tirx.script.ir_builder import IRBuilder def build(frame, emit_body): with IRBuilder() as builder: with frame: emit_body() return builder.get()
- static current()#
Get the current IRBuilder put in the with-scope.
- Returns:
builder (IRBuilder) – The current IRBuilder.
- Return type:
- static is_in_scope()#
See if the current thread-local scope has an IRBuilder.
- Returns:
bool – Whether the current thread-local scope has an IRBuilder
- Return type:
- get()#
Get the constructed IR.
- Return type:
Object
- line_trace_scope(*, exclude_paths=())#
Track Python source lines while executing builder code.
TVM and Python implementation frames are excluded automatically.
exclude_pathssupplies additional implementation directories. User helpers retain their own line and the caller’s location. Nested scopes and exceptions restore the preceding trace and location state. Locations cover whole lines; use the parser for expression ranges. Tracing only supplies locations: script-facing void calls emit under any active builder, independently of this scope.
- with_loc(loc)#
Attach
locto IR nodes constructed in the nested scope.Nested scopes are retained as a
CallSiteLocwhen they describe distinct source ranges, such as a TVMScript inline expansion.- Parameters:
loc (tvm_tirx.ir.Location) – The frontend source range active in the nested scope.
- static name(s, v)#
Set the name of an object.
- Parameters:
s (str) – The name of the object.
v (Any) – The object to name.
- Returns:
v (Any) – The same object with the name set.
- Return type:
Any
- static name_many(s, vs)#
Set the name of a list of objects.
- Parameters:
s (List[str]) – The names of the objects.
vs (List[Any]) – The objects to name.
- Returns:
vs (List[Any]) – The same objects with the names set.
- Return type:
list[Any]
- property frames#
- property result#