aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core
diff options
context:
space:
mode:
authorGravatar Justin Lebar <jlebar@google.com>2017-07-11 11:50:25 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-07-11 11:54:50 -0700
commitc3322543862e14482b3e108fb1b2d466641fd714 (patch)
tree00aa9afd2f2fe5d920f16fec50b25a51ff814352 /tensorflow/core
parentc1b6f48808fabc98797d21a78a14dd9ac2ca9d8a (diff)
Remove HashStr and HashStringPiece (a one-off).
Now that we have tensorflow::hash and it's the default hasher for FlatMap and FlatSet, we can get rid of HashStr and HashStringPiece. PiperOrigin-RevId: 161560034
Diffstat (limited to 'tensorflow/core')
-rw-r--r--tensorflow/core/common_runtime/executor.cc7
-rw-r--r--tensorflow/core/framework/function.h4
-rw-r--r--tensorflow/core/lib/gtl/flatmap_test.cc2
-rw-r--r--tensorflow/core/lib/gtl/flatset_test.cc2
-rw-r--r--tensorflow/core/lib/hash/hash.h18
5 files changed, 18 insertions, 15 deletions
diff --git a/tensorflow/core/common_runtime/executor.cc b/tensorflow/core/common_runtime/executor.cc
index ce6bbb0d65..e8a5b67546 100644
--- a/tensorflow/core/common_runtime/executor.cc
+++ b/tensorflow/core/common_runtime/executor.cc
@@ -363,7 +363,7 @@ class ExecutorImpl : public Executor {
friend class ExecutorState;
struct ControlFlowInfo {
- gtl::FlatSet<string, HashStr> unique_frame_names;
+ gtl::FlatSet<string> unique_frame_names;
std::vector<string> frame_names;
};
@@ -423,7 +423,7 @@ class ExecutorImpl : public Executor {
// Mapping from frame name to static information about the frame.
// TODO(yuanbyu): We could cache it along with the graph so to avoid
// the overhead of constructing it for each executor instance.
- gtl::FlatMap<string, FrameInfo*, HashStr> frame_info_;
+ gtl::FlatMap<string, FrameInfo*> frame_info_;
TF_DISALLOW_COPY_AND_ASSIGN(ExecutorImpl);
};
@@ -1209,8 +1209,7 @@ class ExecutorState {
// child frame is composed of the name of the parent frame, the iteration
// number at which the parent frame is creating the new frame, and the
// name of the new frame from nodedef.
- gtl::FlatMap<string, FrameState*, HashStr> outstanding_frames_
- GUARDED_BY(mu_);
+ gtl::FlatMap<string, FrameState*> outstanding_frames_ GUARDED_BY(mu_);
// The unique name of a frame.
inline string MakeFrameName(FrameState* frame, int64 iter_id,
diff --git a/tensorflow/core/framework/function.h b/tensorflow/core/framework/function.h
index 2342e08b38..059f2be629 100644
--- a/tensorflow/core/framework/function.h
+++ b/tensorflow/core/framework/function.h
@@ -354,9 +354,9 @@ class FunctionLibraryDefinition : public OpRegistryInterface {
};
const OpRegistryInterface* const default_registry_;
- gtl::FlatMap<string, std::unique_ptr<FunctionDefAndOpRegistration>, HashStr>
+ gtl::FlatMap<string, std::unique_ptr<FunctionDefAndOpRegistration>>
function_defs_;
- gtl::FlatMap<string, string, HashStr> func_grad_;
+ gtl::FlatMap<string, string> func_grad_;
// Helper function for GetAttr. Returns the FunctionDef* to get the
// attr from.
diff --git a/tensorflow/core/lib/gtl/flatmap_test.cc b/tensorflow/core/lib/gtl/flatmap_test.cc
index d8e50830e6..bb65e5357a 100644
--- a/tensorflow/core/lib/gtl/flatmap_test.cc
+++ b/tensorflow/core/lib/gtl/flatmap_test.cc
@@ -588,7 +588,7 @@ TEST(FlatMap, ForwardIterator) {
// or destructions will show up as errors under a sanitizer or
// heap checker.
TEST(FlatMap, ConstructDestruct) {
- FlatMap<string, string, HashStr> map;
+ FlatMap<string, string> map;
string k1 = "the quick brown fox jumped over the lazy dog";
string k2 = k1 + k1;
string k3 = k1 + k2;
diff --git a/tensorflow/core/lib/gtl/flatset_test.cc b/tensorflow/core/lib/gtl/flatset_test.cc
index 54def603c3..09fbbb1fb6 100644
--- a/tensorflow/core/lib/gtl/flatset_test.cc
+++ b/tensorflow/core/lib/gtl/flatset_test.cc
@@ -485,7 +485,7 @@ TEST(FlatSet, ForwardIterator) {
// or destructions will show up as errors under a sanitizer or
// heap checker.
TEST(FlatSet, ConstructDestruct) {
- FlatSet<string, HashStr> set;
+ FlatSet<string> set;
string k1 = "the quick brown fox jumped over the lazy dog";
string k2 = k1 + k1;
string k3 = k1 + k2;
diff --git a/tensorflow/core/lib/hash/hash.h b/tensorflow/core/lib/hash/hash.h
index b45391fac5..73b7c94d1f 100644
--- a/tensorflow/core/lib/hash/hash.h
+++ b/tensorflow/core/lib/hash/hash.h
@@ -23,6 +23,7 @@ limitations under the License.
#include <string>
+#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/types.h"
namespace tensorflow {
@@ -42,12 +43,6 @@ inline uint64 Hash64Combine(uint64 a, uint64 b) {
return a ^ (b + 0x9e3779b97f4a7800ULL + (a << 10) + (a >> 4));
}
-struct HashStr {
- size_t operator()(const string& s) const {
- return static_cast<size_t>(Hash64(s));
- }
-};
-
// Hash functor suitable for use with power-of-two sized hashtables. Use
// instead of std::hash<T>.
//
@@ -70,7 +65,16 @@ struct hash<T*> {
template <>
struct hash<string> {
- size_t operator()(const string& s) const { return HashStr()(s); }
+ size_t operator()(const string& s) const {
+ return static_cast<size_t>(Hash64(s));
+ }
+};
+
+template <>
+struct hash<StringPiece> {
+ size_t operator()(StringPiece sp) const {
+ return static_cast<size_t>(Hash64(sp.data(), sp.size()));
+ }
};
} // namespace tensorflow