diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-03-08 12:01:23 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-03-08 12:12:23 -0800 |
commit | 25b970971a58f9e49008eecfce113b7d342dbec2 (patch) | |
tree | e39bb18c3105f8d70cd91bd700e929d498f1ea1e /tensorflow/core/lib/hash | |
parent | 543454b282bbcffd63d1348204662dbfed82fb86 (diff) |
Decoupling hash and protobuf. This simplifies a little bit the dependency chain as
we don't have to link protobuf libraries just to use basic hash functions. The case
for deterministic serialization of protocol buffers if very specific and can be
handled by a new header file.
PiperOrigin-RevId: 188366713
Diffstat (limited to 'tensorflow/core/lib/hash')
-rw-r--r-- | tensorflow/core/lib/hash/hash.cc | 11 | ||||
-rw-r--r-- | tensorflow/core/lib/hash/hash.h | 10 |
2 files changed, 0 insertions, 21 deletions
diff --git a/tensorflow/core/lib/hash/hash.cc b/tensorflow/core/lib/hash/hash.cc index ed9b4df37a..dc9d300d00 100644 --- a/tensorflow/core/lib/hash/hash.cc +++ b/tensorflow/core/lib/hash/hash.cc @@ -126,15 +126,4 @@ uint64 Hash64(const char* data, size_t n, uint64 seed) { return h; } -bool SerializeToStringDeterministic(const protobuf::MessageLite& msg, - string* result) { - const size_t size = msg.ByteSizeLong(); - *result = string(size, '\0'); - protobuf::io::ArrayOutputStream array_stream(&(*result)[0], size); - protobuf::io::CodedOutputStream output_stream(&array_stream); - output_stream.SetSerializationDeterministic(true); - msg.SerializeWithCachedSizes(&output_stream); - return !output_stream.HadError() && size == output_stream.ByteCount(); -} - } // namespace tensorflow diff --git a/tensorflow/core/lib/hash/hash.h b/tensorflow/core/lib/hash/hash.h index 4d312ab7e8..b90c6514f2 100644 --- a/tensorflow/core/lib/hash/hash.h +++ b/tensorflow/core/lib/hash/hash.h @@ -24,7 +24,6 @@ limitations under the License. #include <string> #include "tensorflow/core/lib/core/stringpiece.h" -#include "tensorflow/core/platform/protobuf.h" #include "tensorflow/core/platform/types.h" namespace tensorflow { @@ -92,15 +91,6 @@ struct hash<std::pair<T, U>> { } }; -// Wrapper around protocol buffer serialization that requests deterministic -// serialization, in particular for Map fields, which serialize in a random -// order by default. Returns true on success. -// Serialization is guaranteed to be deterministic for a given binary only. -// See the following for more details: -// https://github.com/google/protobuf/blob/a1bb147e96b6f74db6cdf3c3fcb00492472dbbfa/src/google/protobuf/io/coded_stream.h#L834 -bool SerializeToStringDeterministic(const protobuf::MessageLite& msg, - string* result); - } // namespace tensorflow #endif // TENSORFLOW_LIB_HASH_HASH_H_ |