tvm
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
tvm::NameSupplyNode Class Reference

NameSupply can be used to generate unique names. More...

#include <name_supply.h>

Inheritance diagram for tvm::NameSupplyNode:
Collaboration diagram for tvm::NameSupplyNode:

Public Member Functions

 NameSupplyNode ()=default
 Empty constructor. Needed by the TVM_REGISTER_NODE_TYPE macro. More...
 
 NameSupplyNode (const String &prefix, std::unordered_map< std::string, int > name_map)
 Constructor. More...
 
String FreshName (const String &name, bool add_prefix=true, bool add_underscore=true)
 Generates a unique name from this NameSupply. More...
 
String ReserveName (const String &name, bool add_prefix=true)
 Reserves an existing name with this NameSupply. More...
 
bool ContainsName (const String &name, bool add_prefix=true)
 Checks if this NameSupply already generated a name. More...
 
 TVM_DECLARE_FINAL_OBJECT_INFO (NameSupplyNode, Object)
 

Public Attributes

std::string prefix_
 

Static Public Attributes

static constexpr const char * _type_key = "ir.NameSupply"
 

Detailed Description

NameSupply can be used to generate unique names.

Constructor & Destructor Documentation

◆ NameSupplyNode() [1/2]

tvm::NameSupplyNode::NameSupplyNode ( )
default

Empty constructor. Needed by the TVM_REGISTER_NODE_TYPE macro.

◆ NameSupplyNode() [2/2]

tvm::NameSupplyNode::NameSupplyNode ( const String &  prefix,
std::unordered_map< std::string, int >  name_map 
)
inline

Constructor.

Parameters
prefixThe prefix to be used with this NameSupply.
name_mapThe map used to guarantee uniqueness.

Member Function Documentation

◆ ContainsName()

bool tvm::NameSupplyNode::ContainsName ( const String &  name,
bool  add_prefix = true 
)

Checks if this NameSupply already generated a name.

Parameters
nameThe name to check.
add_prefixIf set to true, then the prefix of this NameSupply will be prepended to the name before checking for it.
Returns
True if the name has already been generated. False otherwise.

◆ FreshName()

String tvm::NameSupplyNode::FreshName ( const String &  name,
bool  add_prefix = true,
bool  add_underscore = true 
)

Generates a unique name from this NameSupply.

Parameters
nameThe name from which the generated name is derived.
add_prefixIf set to true, then the prefix of this NameSupply will be prepended to the name.
add_underscoreIf set to true, add '_' between prefix and a digit.
Returns
A unique name.

◆ ReserveName()

String tvm::NameSupplyNode::ReserveName ( const String &  name,
bool  add_prefix = true 
)

Reserves an existing name with this NameSupply.

Parameters
nameThe name to be reserved.
add_prefixIf set to true, then the prefix of this NameSupply will be prepended to the name before reserving it.
Returns
The name that was reserved with the NameSupply. It can be different if a prefix is added.

◆ TVM_DECLARE_FINAL_OBJECT_INFO()

tvm::NameSupplyNode::TVM_DECLARE_FINAL_OBJECT_INFO ( NameSupplyNode  ,
Object   
)

Member Data Documentation

◆ _type_key

constexpr const char* tvm::NameSupplyNode::_type_key = "ir.NameSupply"
staticconstexpr

◆ prefix_

std::string tvm::NameSupplyNode::prefix_

The documentation for this class was generated from the following file: