| 92 | } |
| 93 | |
| 94 | void Update(const Tensor& indices, OpKernelContext *ctx) { |
| 95 | const int64 N = indices.NumElements(); |
| 96 | auto thread_pool = *(ctx->device()->tensorflow_cpu_worker_threads()); |
| 97 | |
| 98 | std::vector<std::pair<int64, int64>> parts; |
| 99 | SplitParallelParts(N, |
| 100 | std::min(part_count_, thread_pool.workers->NumThreads()), parts); |
| 101 | |
| 102 | int part_count = parts.size(); |
| 103 | BlockingCounter counter(part_count); |
| 104 | for (int i = 0; i < part_count; i++) { |
| 105 | int64 start = parts[i].first; |
| 106 | int64 end = parts[i].second; |
| 107 | thread_pool.workers->Schedule([this, indices, i, start, end, &counter]() { |
| 108 | hash_maps_[i].Update(indices, start, end); |
| 109 | counter.DecrementCount(); |
| 110 | }); |
| 111 | } |
| 112 | counter.Wait(); |
| 113 | } |
| 114 | |
| 115 | void Swap(std::unordered_map<T, uint64> &indices) { |
| 116 | std::vector<std::unordered_map<T, uint64>> tmp_maps; |
no test coverage detected