24 #ifndef TVM_IR_NAME_SUPPLY_H_
25 #define TVM_IR_NAME_SUPPLY_H_
28 #include <unordered_map>
51 :
prefix_(prefix), name_map(std::move(name_map)) {}
84 static constexpr
const char*
_type_key =
"NameSupply";
98 std::string GetUniqueName(std::string name);
101 std::unordered_map<std::string, int> name_map;
116 std::unordered_map<std::string, int> name_map = {});
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
NameSupply can be used to generate unique names.
Definition: name_supply.h:38
NameSupplyNode(const String &prefix, std::unordered_map< std::string, int > name_map)
Constructor.
Definition: name_supply.h:50
void VisitAttrs(AttrVisitor *v)
Definition: name_supply.h:79
TVM_DECLARE_FINAL_OBJECT_INFO(NameSupplyNode, Object)
static constexpr const char * _type_key
Definition: name_supply.h:84
String ReserveName(const String &name, bool add_prefix=true)
Reserves an existing name with this NameSupply.
std::string prefix_
Definition: name_supply.h:82
String FreshName(const String &name, bool add_prefix=true)
Generates a unique name from this NameSupply.
NameSupplyNode()=default
Empty constructor. Needed by the TVM_REGISTER_NODE_TYPE macro.
static constexpr const bool _type_has_method_shash_reduce
Definition: name_supply.h:86
bool ContainsName(const String &name, bool add_prefix=true)
Checks if this NameSupply already generated a name.
static constexpr const bool _type_has_method_sequal_reduce
Definition: name_supply.h:85
Managed reference class to NameSupplyNode.
Definition: name_supply.h:108
TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(NameSupply, ObjectRef, NameSupplyNode)
NameSupply(const String &prefix, std::unordered_map< std::string, int > name_map={})
Constructor.
Base class of all object reference.
Definition: object.h:517
base class of all object containers.
Definition: object.h:169
Reference to string objects.
Definition: string.h:98
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36