aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/util/presized_cuckoo_map.h
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2016-08-25 14:28:26 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-08-25 20:16:17 -0700
commitdb7bdab6e586e02051556d9f36a7887500378cf9 (patch)
tree0285545a72591d7462b68d70f02ecbae69bdb1c7 /tensorflow/core/util/presized_cuckoo_map.h
parent4501365d9a5bee11bbdc66154acecaf6897db946 (diff)
Implement fast ParseExample.
Change: 131338565
Diffstat (limited to 'tensorflow/core/util/presized_cuckoo_map.h')
-rw-r--r--tensorflow/core/util/presized_cuckoo_map.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/tensorflow/core/util/presized_cuckoo_map.h b/tensorflow/core/util/presized_cuckoo_map.h
index b488d32e03..a1ae3ec248 100644
--- a/tensorflow/core/util/presized_cuckoo_map.h
+++ b/tensorflow/core/util/presized_cuckoo_map.h
@@ -50,7 +50,10 @@ class PresizedCuckooMap {
// The key type is fixed as a pre-hashed key for this specialized use.
typedef uint64 key_type;
- explicit PresizedCuckooMap(uint64 num_entries) : cpq_(new CuckooPathQueue) {
+ explicit PresizedCuckooMap(uint64 num_entries) { Clear(num_entries); }
+
+ void Clear(uint64 num_entries) {
+ cpq_.reset(new CuckooPathQueue());
double n(num_entries);
n /= kLoadFactor;
num_buckets_ = (static_cast<uint64>(n) / kSlotsPerBucket);
@@ -62,8 +65,10 @@ class PresizedCuckooMap {
for (int i = 0; i < kSlotsPerBucket; i++) {
empty_bucket.keys[i] = kUnusedSlot;
}
+ buckets_.clear();
buckets_.resize(num_buckets_, empty_bucket);
-#if !defined(__GCUDACC__) && !defined(__GCUDACC_HOST__)
+#if !defined(__GCUDACC__) && !defined(__GCUDACC_HOST__) && \
+ !defined(IS_MOBILE_PLATFORM)
buckets_divisor_ = Eigen::internal::TensorIntDivisor<uint64>(num_buckets_);
#endif
}
@@ -304,7 +309,8 @@ class PresizedCuckooMap {
inline uint64 fast_mod_by_buckets(uint64 x) const {
// Omitting the optimized bucket mod for CUDA platforms
// until Eigen supports 2^63 divisors on GPU.
-#if !defined(__GCUDACC__) && !defined(__GCUDACC_HOST__)
+#if !defined(__GCUDACC__) && !defined(__GCUDACC_HOST__) && \
+ !defined(IS_MOBILE_PLATFORM)
x &= ~(1ULL << 63); // Fast div can only handle 2^63-1
return x - num_buckets_ * (x / buckets_divisor_);
#else
@@ -317,7 +323,7 @@ class PresizedCuckooMap {
std::vector<Bucket> buckets_;
Eigen::internal::TensorIntDivisor<uint64> buckets_divisor_; // for fast mod
- const std::unique_ptr<CuckooPathQueue> cpq_;
+ std::unique_ptr<CuckooPathQueue> cpq_;
CuckooPathEntry visited_[kVisitedListSize];
TF_DISALLOW_COPY_AND_ASSIGN(PresizedCuckooMap);