23 #ifndef TVM_NODE_STRUCTURAL_HASH_H_ 24 #define TVM_NODE_STRUCTURAL_HASH_H_ 40 size_t operator()(
const double& key)
const {
return std::hash<double>()(key); }
42 size_t operator()(
const int64_t& key)
const {
return std::hash<int64_t>()(key); }
44 size_t operator()(
const uint64_t& key)
const {
return std::hash<uint64_t>()(key); }
46 size_t operator()(
const int& key)
const {
return std::hash<int>()(key); }
48 size_t operator()(
const bool& key)
const {
return std::hash<bool>()(key); }
50 size_t operator()(
const std::string& key)
const {
return std::hash<std::string>()(key); }
53 return std::hash<int32_t>()(static_cast<int32_t>(key.
code()) |
54 (static_cast<int32_t>(key.
bits()) << 8) |
55 (
static_cast<int32_t
>(key.
lanes()) << 16));
58 template <typename ENum, typename = typename std::enable_if<std::is_enum<ENum>::value>::type>
60 return std::hash<size_t>()(static_cast<size_t>(key));
78 using BaseValueHash::operator();
112 virtual void SHashReduceHashedValue(
size_t hashed_value) = 0;
119 virtual void SHashReduce(
const ObjectRef& key,
bool map_free_vars) = 0;
142 virtual bool LookupHashedValue(
const ObjectRef& key,
size_t* hashed_value) = 0;
147 virtual void MarkGraphNode() = 0;
158 : handler_(handler), map_free_vars_(map_free_vars) {}
163 template <
typename T,
164 typename =
typename std::enable_if<!std::is_base_of<ObjectRef, T>::value>::type>
186 handler_->SHashReduceFreeVar(var, map_free_vars_);
205 static constexpr
const std::nullptr_t VisitAttrs =
nullptr;
212 #endif // TVM_NODE_STRUCTURAL_HASH_H_ void FreeVarHashImpl(const runtime::Object *var) const
Implementation for hash for a free var.
Definition: structural_hash.h:185
bool operator()(const ENum &key) const
Definition: structural_hash.h:59
Internal handler that defines custom behaviors.
Definition: structural_hash.h:105
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:124
size_t operator()(const double &key) const
Definition: structural_hash.h:40
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A Reducer class to reduce the structural hash value.
Definition: structural_hash.h:102
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
int code() const
Definition: data_type.h:81
size_t operator()(const bool &key) const
Definition: structural_hash.h:48
size_t operator()(const int64_t &key) const
Definition: structural_hash.h:42
base class of all object containers.
Definition: object.h:167
A device-independent managed NDArray abstraction.
Definition: structural_hash.h:204
Handler * operator->() const
Definition: structural_hash.h:190
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:38
Object container class that backs NDArray.
Definition: ndarray.h:294
size_t operator()(const int &key) const
Definition: structural_hash.h:46
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:511
SHashReducer(Handler *handler, bool map_free_vars)
Constructor with a specific handler.
Definition: structural_hash.h:157
size_t operator()(const runtime::DataType &key) const
Definition: structural_hash.h:52
size_t operator()(const std::string &key) const
Definition: structural_hash.h:50
void operator()(const T &key) const
Push hash of key to the current sequence of hash values.
Definition: structural_hash.h:165
Content-aware structural hasing.
Definition: structural_hash.h:75
size_t operator()(const uint64_t &key) const
Definition: structural_hash.h:44
void operator()(const ObjectRef &key) const
Push hash of key to the current sequence of hash values.
Definition: structural_hash.h:173
void DefHash(const ObjectRef &key) const
Push hash of key to the current sequence of hash values.
Definition: structural_hash.h:179