Move platform/default/fingerprint.h into platform/fingerprint.h.
PiperOrigin-RevId: 245060405
This commit is contained in:
parent
7fc8865004
commit
70800b7f7f
@ -1,37 +0,0 @@
|
|||||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
==============================================================================*/
|
|
||||||
|
|
||||||
#ifndef TENSORFLOW_CORE_PLATFORM_DEFAULT_FINGERPRINT_H_
|
|
||||||
#define TENSORFLOW_CORE_PLATFORM_DEFAULT_FINGERPRINT_H_
|
|
||||||
|
|
||||||
#include <farmhash.h>
|
|
||||||
|
|
||||||
#include "tensorflow/core/lib/core/stringpiece.h"
|
|
||||||
|
|
||||||
namespace tensorflow {
|
|
||||||
|
|
||||||
inline uint64 Fingerprint64(StringPiece s) {
|
|
||||||
return ::util::Fingerprint64(s.data(), s.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Fprint128 Fingerprint128(StringPiece s) {
|
|
||||||
const auto fingerprint = ::util::Fingerprint128(s.data(), s.size());
|
|
||||||
return {::util::Uint128Low64(fingerprint),
|
|
||||||
::util::Uint128High64(fingerprint)};
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace tensorflow
|
|
||||||
|
|
||||||
#endif // TENSORFLOW_CORE_PLATFORM_DEFAULT_FINGERPRINT_H_
|
|
@ -19,6 +19,16 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/lib/core/stringpiece.h"
|
#include "tensorflow/core/lib/core/stringpiece.h"
|
||||||
#include "tensorflow/core/platform/types.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 {
|
namespace tensorflow {
|
||||||
|
|
||||||
struct Fprint128 {
|
struct Fprint128 {
|
||||||
@ -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 {
|
namespace internal {
|
||||||
// Mixes some of the bits that got propagated to the high bits back into the
|
// Mixes some of the bits that got propagated to the high bits back into the
|
||||||
// low bits.
|
// low bits.
|
||||||
@ -72,12 +75,28 @@ inline uint64 FingerprintCat64(const uint64 fp1, const uint64 fp2) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
const auto fingerprint = farmhash::Fingerprint128(s.data(), s.size());
|
||||||
|
return {absl::Uint128Low64(fingerprint), absl::Uint128High64(fingerprint)};
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace tensorflow
|
} // namespace tensorflow
|
||||||
|
|
||||||
#if defined(PLATFORM_GOOGLE) || defined(PLATFORM_GOOGLE_ANDROID)
|
|
||||||
#include "tensorflow/core/platform/google/fingerprint.h"
|
|
||||||
#else
|
|
||||||
#include "tensorflow/core/platform/default/fingerprint.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // TENSORFLOW_CORE_PLATFORM_FINGERPRINT_H_
|
#endif // TENSORFLOW_CORE_PLATFORM_FINGERPRINT_H_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user