microsoft/onnxruntime-extensions

Public

mirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
zhanxi/debug_linux_wheel

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cmake/externals/farmhash/dev/f.cc

99lines · modecode

1namespace NAMESPACE_FOR_HASH_FUNCTIONS {
2
3// BASIC STRING HASHING
4
5// Hash function for a byte array. See also Hash(), below.
6// May change from time to time, may differ on different platforms, may differ
7// depending on NDEBUG.
8uint32_t Hash32(const char* s, size_t len) {
9 return DebugTweak(
10 (can_use_sse41 & x86_64) ? farmhashnt::Hash32(s, len) :
11 (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32(s, len) :
12 can_use_sse42 ? farmhashsa::Hash32(s, len) :
13 farmhashmk::Hash32(s, len));
14}
15
16// Hash function for a byte array. For convenience, a 32-bit seed is also
17// hashed into the result.
18// May change from time to time, may differ on different platforms, may differ
19// depending on NDEBUG.
20uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) {
21 return DebugTweak(
22 (can_use_sse41 & x86_64) ? farmhashnt::Hash32WithSeed(s, len, seed) :
23 (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32WithSeed(s, len, seed) :
24 can_use_sse42 ? farmhashsa::Hash32WithSeed(s, len, seed) :
25 farmhashmk::Hash32WithSeed(s, len, seed));
26}
27
28// Hash function for a byte array. For convenience, a 64-bit seed is also
29// hashed into the result. See also Hash(), below.
30// May change from time to time, may differ on different platforms, may differ
31// depending on NDEBUG.
32uint64_t Hash64(const char* s, size_t len) {
33 return DebugTweak(
34 (can_use_sse42 & x86_64) ?
35 farmhashte::Hash64(s, len) :
36 farmhashxo::Hash64(s, len));
37}
38
39// Hash function for a byte array.
40// May change from time to time, may differ on different platforms, may differ
41// depending on NDEBUG.
42size_t Hash(const char* s, size_t len) {
43 return sizeof(size_t) == 8 ? Hash64(s, len) : Hash32(s, len);
44}
45
46// Hash function for a byte array. For convenience, a 64-bit seed is also
47// hashed into the result.
48// May change from time to time, may differ on different platforms, may differ
49// depending on NDEBUG.
50uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) {
51 return DebugTweak(farmhashna::Hash64WithSeed(s, len, seed));
52}
53
54// Hash function for a byte array. For convenience, two seeds are also
55// hashed into the result.
56// May change from time to time, may differ on different platforms, may differ
57// depending on NDEBUG.
58uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1) {
59 return DebugTweak(farmhashna::Hash64WithSeeds(s, len, seed0, seed1));
60}
61
62// Hash function for a byte array.
63// May change from time to time, may differ on different platforms, may differ
64// depending on NDEBUG.
65NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t Hash128(const char* s, size_t len) {
66 return DebugTweak(farmhashcc::Fingerprint128(s, len));
67}
68
69// Hash function for a byte array. For convenience, a 128-bit seed is also
70// hashed into the result.
71// May change from time to time, may differ on different platforms, may differ
72// depending on NDEBUG.
73NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t Hash128WithSeed(const char* s, size_t len, NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t seed) {
74 return DebugTweak(farmhashcc::CityHash128WithSeed(s, len, seed));
75}
76
77// BASIC NON-STRING HASHING
78
79// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
80
81// Fingerprint function for a byte array. Most useful in 32-bit binaries.
82uint32_t Fingerprint32(const char* s, size_t len) {
83 return farmhashmk::Hash32(s, len);
84}
85
86// Fingerprint function for a byte array.
87uint64_t Fingerprint64(const char* s, size_t len) {
88 return farmhashna::Hash64(s, len);
89}
90
91// Fingerprint function for a byte array.
92NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t Fingerprint128(const char* s, size_t len) {
93 return farmhashcc::Fingerprint128(s, len);
94}
95
96// Older and still available but perhaps not as fast as the above:
97// farmhashns::Hash32{,WithSeed}()
98
99} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
100