Skip to content

Commit

Permalink
Move platform/default/fingerprint.h into platform/fingerprint.h.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 245060405
  • Loading branch information
sjamesr authored and tensorflower-gardener committed Apr 24, 2019
1 parent 7fc8865 commit 70800b7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 48 deletions.
37 changes: 0 additions & 37 deletions tensorflow/core/platform/default/fingerprint.h

This file was deleted.

41 changes: 30 additions & 11 deletions tensorflow/core/platform/fingerprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ limitations under the License.
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/types.h"

// The following line is used by copybara to set or unset the USE_OSS_FARMHASH
// preprocessor symbol as needed. Please do not remove.
#define USE_OSS_FARMHASH

#ifdef USE_OSS_FARMHASH
#include <farmhash.h>
#else
#include "util/hash/farmhash_fingerprint.h"
#endif

namespace tensorflow {

struct Fprint128 {
Expand All @@ -37,13 +47,6 @@ struct Fprint128Hasher {
}
};

// This is a portable fingerprint interface for strings that will never change.
// However, it is not suitable for cryptography.
uint64 Fingerprint64(StringPiece s);

// 128-bit variant of Fingerprint64 above (same properties and caveats apply).
Fprint128 Fingerprint128(StringPiece s);

namespace internal {
// Mixes some of the bits that got propagated to the high bits back into the
// low bits.
Expand Down Expand Up @@ -72,12 +75,28 @@ inline uint64 FingerprintCat64(const uint64 fp1, const uint64 fp2) {
return result;
}

} // namespace tensorflow
// This is a portable fingerprint interface for strings that will never change.
// However, it is not suitable for cryptography.
inline uint64 Fingerprint64(StringPiece s) {
#ifdef USE_OSS_FARMHASH
return ::util::Fingerprint64(s.data(), s.size());
#else
return farmhash::Fingerprint64(s.data(), s.size());
#endif
}

#if defined(PLATFORM_GOOGLE) || defined(PLATFORM_GOOGLE_ANDROID)
#include "tensorflow/core/platform/google/fingerprint.h"
// 128-bit variant of Fingerprint64 above (same properties and caveats apply).
inline Fprint128 Fingerprint128(StringPiece s) {
#ifdef USE_OSS_FARMHASH
const auto fingerprint = ::util::Fingerprint128(s.data(), s.size());
return {::util::Uint128Low64(fingerprint),
::util::Uint128High64(fingerprint)};
#else
#include "tensorflow/core/platform/default/fingerprint.h"
const auto fingerprint = farmhash::Fingerprint128(s.data(), s.size());
return {absl::Uint128Low64(fingerprint), absl::Uint128High64(fingerprint)};
#endif
}

} // namespace tensorflow

#endif // TENSORFLOW_CORE_PLATFORM_FINGERPRINT_H_

0 comments on commit 70800b7

Please sign in to comment.