25 #ifndef TVM_RELAX_BINDING_REWRITE_H_
33 #include <type_traits>
54 void Add(
Expr expr,
bool is_dfvar =
false) {
55 Add(name_supply_->FreshName(
"tmp"), expr, is_dfvar);
71 v->Visit(
"dfb", &
dfb_);
75 static constexpr
const char*
_type_key =
"relax.DataflowBlockRewrite";
104 ICHECK(
get() !=
nullptr);
114 #define TVM_RELAX_BINDING_REWRITE_H_
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
Managed reference class to IRModuleNode.
Definition: module.h:366
Managed reference class to NameSupplyNode.
Definition: name_supply.h:112
Managed reference to RelayExprNode.
Definition: expr.h:442
Statement rewriter for relax.DataflowBlock.
Definition: binding_rewrite.h:41
DataflowBlock MutatedDataflowBlock()
The rewritten dataflow block.
Definition: binding_rewrite.h:63
const FunctionNode * original_fn_ptr_
Pointer to the original function.
Definition: binding_rewrite.h:83
Function MutatedFunc()
The rewritten function.
Definition: binding_rewrite.h:65
void VisitAttrs(AttrVisitor *v)
Visit attributes.
Definition: binding_rewrite.h:70
void Add(String var_name, Expr expr, bool is_dfvar=false)
Insert an expression as VarBinding with variable name.
Definition: binding_rewrite.h:48
Map< Var, Array< Var > > to_users_
Map from variable to its users.
Definition: binding_rewrite.h:84
TVM_DECLARE_FINAL_OBJECT_INFO(DataflowBlockRewriteNode, Object)
static constexpr const char * _type_key
Definition: binding_rewrite.h:75
void Add(Expr expr, bool is_dfvar=false)
Insert an expression as VarBinding with automatic variable name.
Definition: binding_rewrite.h:54
Array< Var > fn_outputs_
Variables required by function outputs.
Definition: binding_rewrite.h:85
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:81
void Add(Binding binding)
Insert a Binding statement.
Optional< Function > root_fn_
The rewritten function.
Definition: binding_rewrite.h:82
A statement rewriter for relax.DataflowBlock.
Definition: binding_rewrite.h:95
TVM_DEFINE_OBJECT_REF_METHODS(DataflowBlockRewrite, ObjectRef, DataflowBlockRewriteNode)
DataflowBlockRewriteNode * operator->()
mutable accessor.
Definition: binding_rewrite.h:103
DataflowBlockRewrite(DataflowBlock dfb, Function root_fn)
A Relax function.
Definition: expr.h:950
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics,...
Definition: map.h:1271
Base class of all object reference.
Definition: object.h:519
const Object * get() const
Definition: object.h:554
Object * get_mutable() const
Definition: object.h:607
base class of all object containers.
Definition: object.h:171
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Reference to string objects.
Definition: string.h:98
NameSupply that can be used to generate unique variable names.
StructInfo GetStructInfo(const Expr &expr)
Get the underlying structure info of expr.
Definition: struct_info.h:445
Var var(std::string name_hint, DataType t=DataType::Int(32))
Construct a new Var expression.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
The set of Relax specific analysis on IR.