diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2016-08-19 10:44:37 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-08-19 11:48:07 -0700 |
commit | 0b9f0f53ddbf693bb30afb211a6d514a1fce1c22 (patch) | |
tree | fcc68dbf0d05ba6e093b58274645aaaa9d9b7c39 /tensorflow/core/util/presized_cuckoo_map.h | |
parent | 859e47fd8ebcdd7fb1411fd0090d0e95a801e7cb (diff) |
Implement fast ParseExample.
Change: 130775324
Diffstat (limited to 'tensorflow/core/util/presized_cuckoo_map.h')
-rw-r--r-- | tensorflow/core/util/presized_cuckoo_map.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tensorflow/core/util/presized_cuckoo_map.h b/tensorflow/core/util/presized_cuckoo_map.h index b488d32e03..5244ab693a 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,6 +65,7 @@ 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__) buckets_divisor_ = Eigen::internal::TensorIntDivisor<uint64>(num_buckets_); @@ -317,7 +321,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); |