23 #ifndef TVM_NODE_STRUCTURAL_HASH_H_ 24 #define TVM_NODE_STRUCTURAL_HASH_H_ 39 size_t operator()(
const double& key)
const {
return std::hash<double>()(key); }
41 size_t operator()(
const int64_t& key)
const {
return std::hash<int64_t>()(key); }
43 size_t operator()(
const uint64_t& key)
const {
return std::hash<uint64_t>()(key); }
45 size_t operator()(
const int& key)
const {
return std::hash<int>()(key); }
47 size_t operator()(
const bool& key)
const {
return std::hash<bool>()(key); }
49 size_t operator()(
const std::string& key)
const {
return std::hash<std::string>()(key); }
52 return std::hash<int32_t>()(static_cast<int32_t>(key.
code()) |
53 (static_cast<int32_t>(key.
bits()) << 8) |
54 (
static_cast<int32_t
>(key.
lanes()) << 16));
57 template <typename ENum, typename = typename std::enable_if<std::is_enum<ENum>::value>::type>
59 return std::hash<size_t>()(static_cast<size_t>(key));
77 using BaseValueHash::operator();
111 virtual void SHashReduceHashedValue(
size_t hashed_value) = 0;
118 virtual void SHashReduce(
const ObjectRef& key,
bool map_free_vars) = 0;
141 virtual bool LookupHashedValue(
const ObjectRef& key,
size_t* hashed_value) = 0;
146 virtual void MarkGraphNode() = 0;
157 : handler_(handler), map_free_vars_(map_free_vars) {}
162 template <
typename T,
163 typename =
typename std::enable_if<!std::is_base_of<ObjectRef, T>::value>::type>
185 handler_->SHashReduceFreeVar(var, map_free_vars_);
203 #endif // TVM_NODE_STRUCTURAL_HASH_H_ void FreeVarHashImpl(const runtime::Object *var) const
Implementation for hash for a free var.
Definition: structural_hash.h:184
bool operator()(const ENum &key) const
Definition: structural_hash.h:58
Internal handler that defines custom behaviors.
Definition: structural_hash.h:104
size_t operator()(const double &key) const
Definition: structural_hash.h:39
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
A Reducer class to reduce the structural hash value.
Definition: structural_hash.h:101
int code() const
Definition: data_type.h:81
size_t operator()(const bool &key) const
Definition: structural_hash.h:47
size_t operator()(const int64_t &key) const
Definition: structural_hash.h:41
base class of all object containers.
Definition: object.h:165
Handler * operator->() const
Definition: structural_hash.h:189
Runtime primitive data type.
Definition: data_type.h:41
int bits() const
Definition: data_type.h:83
Hash definition of base value classes.
Definition: structural_hash.h:37
size_t operator()(const int &key) const
Definition: structural_hash.h:45
int lanes() const
Definition: data_type.h:87
Var var(std::string name_hint, DataType t=DataType::Int(32))
Construct a new Var expression.
Defines the Functor data structures.
Base class of all object reference.
Definition: object.h:504
SHashReducer(Handler *handler, bool map_free_vars)
Constructor with a specific handler.
Definition: structural_hash.h:156
size_t operator()(const runtime::DataType &key) const
Definition: structural_hash.h:51
size_t operator()(const std::string &key) const
Definition: structural_hash.h:49
void operator()(const T &key) const
Push hash of key to the current sequence of hash values.
Definition: structural_hash.h:164
Content-aware structural hasing.
Definition: structural_hash.h:74
size_t operator()(const uint64_t &key) const
Definition: structural_hash.h:43
void operator()(const ObjectRef &key) const
Push hash of key to the current sequence of hash values.
Definition: structural_hash.h:172
void DefHash(const ObjectRef &key) const
Push hash of key to the current sequence of hash values.
Definition: structural_hash.h:178