24#ifndef TVM_IR_UNIQUE_NAME_SUPPLY_H_
25#define TVM_IR_UNIQUE_NAME_SUPPLY_H_
27#include <tvm/ffi/reflection/registry.h>
89 namespace refl = tvm::ffi::reflection;
90 refl::ObjectDef<UniqueNameSupplyNode>();
97 ffi::String AddPrefixToName(
const ffi::String& name);
105 std::string GetUniqueName(std::string name,
bool add_underscore =
true);
108 ffi::Map<ffi::String, int64_t> name_map;
123 ffi::Map<ffi::String, int64_t> name_map = {});
130 template <
typename Iter,
typename Lambda>
133 this->operator->()->ReserveName(
f(*
it),
false);
UniqueNameSupply can be used to generate unique names.
Definition unique_name_supply.h:39
static void RegisterReflection()
Definition unique_name_supply.h:88
static constexpr const bool _type_mutable
Definition unique_name_supply.h:86
std::string prefix_
Definition unique_name_supply.h:84
bool ContainsName(const ffi::String &name, bool add_prefix=true)
Checks if this UniqueNameSupply already generated a name.
ffi::String ReserveName(const ffi::String &name, bool add_prefix=true)
Reserves an existing name with this UniqueNameSupply.
UniqueNameSupplyNode(const ffi::String &prefix, ffi::Map< ffi::String, int64_t > name_map)
Constructor.
Definition unique_name_supply.h:51
ffi::String FreshName(const ffi::String &name, bool add_prefix=true, bool add_underscore=true)
Generates a unique name from this UniqueNameSupply.
UniqueNameSupplyNode()=default
Empty constructor. Needed by the TVM_REGISTER_NODE_TYPE macro.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.UniqueNameSupply", UniqueNameSupplyNode, ffi::Object)
Managed reference class to UniqueNameSupplyNode.
Definition unique_name_supply.h:115
UniqueNameSupply(const ffi::String &prefix="", ffi::Map< ffi::String, int64_t > name_map={})
Constructor.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(UniqueNameSupply, ffi::ObjectRef, UniqueNameSupplyNode)
UniqueNameSupply(Iter begin, Iter end, Lambda f)
Construct UniqueNameSupply by reserving names from the given iterator range.
Definition unique_name_supply.h:131
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40