23 #ifndef TVM_NODE_STRUCTURAL_HASH_H_
24 #define TVM_NODE_STRUCTURAL_HASH_H_
42 template <
typename T,
typename U>
48 static_assert(
sizeof(
Union) ==
sizeof(T),
"sizeof(Union) != sizeof(T)");
49 static_assert(
sizeof(
Union) ==
sizeof(U),
"sizeof(Union) != sizeof(U)");
56 uint64_t
operator()(
const float& key)
const {
return Reinterpret<float, uint32_t>(key); }
62 return Reinterpret<double, uint64_t>(std::numeric_limits<double>::quiet_NaN());
64 return Reinterpret<double, uint64_t>(key);
67 uint64_t
operator()(
const int64_t& key)
const {
return Reinterpret<int64_t, uint64_t>(key); }
68 uint64_t
operator()(
const uint64_t& key)
const {
return key; }
69 uint64_t
operator()(
const int& key)
const {
return Reinterpret<int, uint32_t>(key); }
70 uint64_t
operator()(
const bool& key)
const {
return key; }
72 return Reinterpret<DLDataType, uint32_t>(key);
74 template <typename ENum, typename = typename std::enable_if<std::is_enum<ENum>::value>::type>
76 return Reinterpret<int64_t, uint64_t>(
static_cast<int64_t
>(key));
79 return tvm::ffi::details::StableHashBytes(key.data(), key.length());
81 uint64_t
operator()(
const Optional<int64_t>& key)
const {
82 if (key.has_value()) {
83 return Reinterpret<int64_t, uint64_t>(*key);
89 if (key.has_value()) {
90 return Reinterpret<double, uint64_t>(*key);
101 return ffi::details::AnyUnsafe::TVMFFIAnyPtrFromAny(key)->v_uint64;
119 using BaseValueHash::operator();
Hash definition of base value classes.
Definition: structural_hash.h:40
uint64_t operator()(const int &key) const
Definition: structural_hash.h:69
uint64_t operator()(const bool &key) const
Definition: structural_hash.h:70
uint64_t operator()(const double &key) const
Definition: structural_hash.h:57
uint64_t operator()(const runtime::DataType &key) const
Definition: structural_hash.h:71
uint64_t operator()(const std::string &key) const
Definition: structural_hash.h:78
TVM_FFI_INLINE uint64_t HashPODValueInAny(const ffi::Any &key) const
Compute structural hash value for a POD value in Any.
Definition: structural_hash.h:100
uint64_t Reinterpret(T value) const
Definition: structural_hash.h:43
uint64_t operator()(const ENum &key) const
Definition: structural_hash.h:75
uint64_t operator()(const Optional< double > &key) const
Definition: structural_hash.h:88
uint64_t operator()(const Optional< int64_t > &key) const
Definition: structural_hash.h:81
uint64_t operator()(const uint64_t &key) const
Definition: structural_hash.h:68
uint64_t operator()(const float &key) const
Definition: structural_hash.h:56
uint64_t operator()(const int64_t &key) const
Definition: structural_hash.h:67
Content-aware structural hashing.
Definition: structural_hash.h:116
uint64_t operator()(const ffi::Any &key) const
Compute structural hashing value for an object.
Runtime primitive data type.
Definition: data_type.h:47
Defines the Functor data structures.
IntSet Union(const Array< IntSet > &sets)
Create a union set of all sets, possibly relaxed.
const Op & isnan()
Check if value is nan.
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
A device-independent managed NDArray abstraction.