tqchen commented on code in PR #14204:
URL: https://github.com/apache/tvm/pull/14204#discussion_r1126452605
##########
include/tvm/runtime/container/string.h:
##########
@@ -247,10 +247,53 @@ class String : public ObjectRef {
* \param size The size of the bytes.
* \return the hash value.
*/
- static size_t HashBytes(const char* data, size_t size) {
- // This function falls back to string copy with c++11 compiler and is
- // recommended to be compiled with c++14
- return std::hash<std::string_view>()(std::string_view(data, size));
+ static uint64_t StableHashBytes(const char* data, size_t size) {
+ const constexpr uint64_t kMultiplier = 1099511628211ULL;
+ const constexpr uint64_t kMod = 2147483647ULL;
+ union Union {
+ uint8_t a[8];
+ uint64_t b;
+ } u;
+ static_assert(sizeof(Union) == sizeof(uint64_t), "sizeof(Union) !=
sizeof(uint64_t)");
Review Comment:
Add endian swap here so we can be endian agnostic, see
https://github.com/apache/tvm/blob/2860a50ff97a2791c876bdca2685d4f35f0e2e03/src/runtime/rpc/rpc_endpoint.cc#L419
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]