25 #ifndef TVM_RELAX_BINDING_REWRITE_H_
27 #include <tvm/ffi/reflection/registry.h>
34 #include <type_traits>
49 void Add(String var_name,
Expr expr,
bool is_dfvar =
false) {
55 void Add(
Expr expr,
bool is_dfvar =
false) {
56 Add(name_supply_->FreshName(
"tmp"), expr, is_dfvar);
73 refl::ObjectDef<DataflowBlockRewriteNode>()
78 static constexpr
const char*
_type_key =
"relax.DataflowBlockRewrite";
107 ICHECK(get() !=
nullptr);
117 #define TVM_RELAX_BINDING_REWRITE_H_
Managed reference class to IRModuleNode.
Definition: module.h:257
Managed reference class to NameSupplyNode.
Definition: name_supply.h:110
Managed reference to RelaxExprNode.
Definition: expr.h:446
Statement rewriter for relax.DataflowBlock.
Definition: binding_rewrite.h:42
DataflowBlock MutatedDataflowBlock()
The rewritten dataflow block.
Definition: binding_rewrite.h:64
const FunctionNode * original_fn_ptr_
Pointer to the original function.
Definition: binding_rewrite.h:86
Function MutatedFunc()
The rewritten function.
Definition: binding_rewrite.h:66
void Add(String var_name, Expr expr, bool is_dfvar=false)
Insert an expression as VarBinding with variable name.
Definition: binding_rewrite.h:49
static void RegisterReflection()
Visit attributes.
Definition: binding_rewrite.h:71
Map< Var, Array< Var > > to_users_
Map from variable to its users.
Definition: binding_rewrite.h:87
TVM_DECLARE_FINAL_OBJECT_INFO(DataflowBlockRewriteNode, Object)
static constexpr const char * _type_key
Definition: binding_rewrite.h:78
void Add(Expr expr, bool is_dfvar=false)
Insert an expression as VarBinding with automatic variable name.
Definition: binding_rewrite.h:55
Array< Var > fn_outputs_
Variables required by function outputs.
Definition: binding_rewrite.h:88
void RemoveUnused(Var unused, bool allow_undef=false)
Remove the definition statement of an unused variable.
IRModule MutateIRModule(IRModule irmod)
The rewritten IRModule.
void ReplaceAllUses(Var old_var, Var new_var)
Replace all uses of old_var with new_var.
void RemoveAllUnused()
Remove the definition statements of all unused variables.
DataflowBlock dfb_
The rewritten dataflow block.
Definition: binding_rewrite.h:84
void Add(Binding binding)
Insert a Binding statement.
Optional< Function > root_fn_
The rewritten function.
Definition: binding_rewrite.h:85
A statement rewriter for relax.DataflowBlock.
Definition: binding_rewrite.h:98
TVM_DEFINE_OBJECT_REF_METHODS(DataflowBlockRewrite, ObjectRef, DataflowBlockRewriteNode)
DataflowBlockRewriteNode * operator->()
mutable accessor.
Definition: binding_rewrite.h:106
DataflowBlockRewrite(DataflowBlock dfb, Function root_fn)
A Relax function.
Definition: expr.h:837
NameSupply that can be used to generate unique variable names.
Definition: repr_printer.h:91
StructInfo GetStructInfo(const Expr &expr)
Get the underlying structure info of expr.
Definition: struct_info.h:401
Var var(std::string name_hint, DataType t=DataType::Int(32))
Construct a new Var expression.
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
The set of Relax specific analysis on IR.