|
virtual NameSupply | name_supply ()=0 |
| Get the name supply for generating unique names. More...
|
|
virtual IRModule | GetContextIRModule () const =0 |
| Get the context IRModule in this builder. More...
|
|
virtual IRModule | Finalize ()=0 |
| Finalize the building process and return the result IRModule. Possibly rename GlobalVars in the IRModule to ensure name uniqueness and the invariant: every public function has the same name as its "global_symbol" attribute. More...
|
|
virtual GlobalVar | AddFunction (const BaseFunc &func, String func_name_hint)=0 |
| Add a Relax function or a TIR PrimFunc to internal context module. More...
|
|
virtual void | UpdateFunction (const GlobalVar &gv, BaseFunc function)=0 |
| Update a Relax function or a TIR PrimFunc in the internal context module. More...
|
|
virtual void | ReportFatal (const Diagnostic &diagnostic)=0 |
| Report an error during transformation construction. More...
|
|
virtual Optional< Expr > | LookupBinding (const Var &var)=0 |
| Lookup the binding value that var binds to in the current emitted sequences. More...
|
|
virtual void | BeginScope (Optional< Array< Var >> params)=0 |
| Begin a new scope, with optional parameters that are visible within the scope. More...
|
|
virtual void | BeginInnerScope ()=0 |
| Begin a new scope, which inherits visible parameters from its parent scope. More...
|
|
virtual void | AddDefinitionToScope (Var var)=0 |
| Append a definition to the current scope. More...
|
|
virtual void | EndScope ()=0 |
| End the previously defined scope. More...
|
|
virtual void | BeginDataflowBlock ()=0 |
| Begin to build a DataflowBlock. More...
|
|
virtual void | BeginBindingBlock ()=0 |
| Begin to build a BindingBlock. More...
|
|
virtual BindingBlock | EndBlock ()=0 |
| End building a BindingBlock. More...
|
|
virtual bool | CurrentBlockIsDataFlow ()=0 |
| Check if the block being built is DataflowBlock or not. More...
|
|
virtual Var | Emit (Expr expr, String name_hint="")=0 |
| Emits an Expr, and returns the variable it is bound to. More...
|
|
virtual Var | EmitMatchCast (Expr value, StructInfo struct_info, String name_hint="")=0 |
| Emit a MatchCast. More...
|
|
virtual Var | EmitOutput (Expr output, String name_hint="")=0 |
| Generate an output for the current dataflow block. More...
|
|
virtual void | EmitNormalized (Binding normalized_binding)=0 |
| Emit a binding that is already normalized. More...
|
|
virtual Expr | Normalize (const Expr &expr)=0 |
| Convert an expression to normal form, and try to eagerly infer types and shapes. More...
|
|
virtual Expr | NormalizeArgument (const Expr &expr)=0 |
| Normalize argument to a call or another IRNode. More...
|
|
virtual arith::Analyzer * | GetAnalyzer ()=0 |
| Get the analyzer of the BlockBuilder. More...
|
|
| TVM_DECLARE_BASE_OBJECT_INFO (BlockBuilderNode, Object) |
|
A builder to build Relax binding blocks.
BlockBuilder provides the following three categories of main functionalities for IR building and transformations:
- Global context management: manages the IRModule, allowing query, update the surrounding global context. Provide context tools for analysis.
- Scope management:
- Manages block scopes for bulding nested blocks.
- Emit bindings to the current scope.
- Construct blocks by calling EndScope.
- Normalization: Take an Expr, normalize it to deduce shape/type, turn things into normal forms.
Importantly, these three categories of features can be dependent on each other. For example, when we emit into scope we will call normalize to ensure the code is in normal form. Similarly, when we normalize we could choose to emit into the current context.
We would encourage the developers to keep these three category in mind when using and developing BlockBuilder, we can group the code in a logically clean way.
BlockBuilderNode is implemented as a virtual interface to allow logically grouped implementation and internal data structures that are hidden from the users.