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 ffi::String &prefix, std::unordered_map< std::string, int > name_map)
 Constructor. More...
 
ffi::String FreshName (const ffi::String &name, bool add_prefix=true, bool add_underscore=true)
 Generates a unique name from this NameSupply. More...
 
ffi::String ReserveName (const ffi::String &name, bool add_prefix=true)
 Reserves an existing name with this NameSupply. More...
 
bool ContainsName (const ffi::String &name, bool add_prefix=true)
 Checks if this NameSupply already generated a name. More...
 
 TVM_FFI_DECLARE_OBJECT_INFO_FINAL ("ir.NameSupply", NameSupplyNode, Object)
 

Public Attributes

std::string prefix_
 

Static Public Attributes

static constexpr const bool _type_mutable = true
 

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 ffi::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 ffi::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()

ffi::String tvm::NameSupplyNode::FreshName ( const ffi::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()

ffi::String tvm::NameSupplyNode::ReserveName ( const ffi::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_FFI_DECLARE_OBJECT_INFO_FINAL()

tvm::NameSupplyNode::TVM_FFI_DECLARE_OBJECT_INFO_FINAL ( "ir.NameSupply"  ,
NameSupplyNode  ,
Object   
)

Member Data Documentation

◆ _type_mutable

constexpr const bool tvm::NameSupplyNode::_type_mutable = true
staticconstexpr

◆ prefix_

std::string tvm::NameSupplyNode::prefix_

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