MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / add_to_cache

Method add_to_cache

tensorflow/core/framework/embedding/cache.h:237–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235 }
236
237 void add_to_cache(const K* batch_ids, const size_t batch_size) {
238 mutex_lock l(mu_);
239 std::vector<K> ids_to_cache(batch_size);
240 int64 nums_to_cache = 0;
241 for (size_t i = 0; i < batch_size; ++i) {
242 K id = batch_ids[i];
243 auto it_prefetch = prefetch_id_table.find(id);
244 if (it_prefetch == prefetch_id_table.end()) {
245 LOG(FATAL)<<"The id should be prefetched before being used.";
246 }
247 it_prefetch->second->UnRef();
248 if (it_prefetch->second->ref_count() == 0) {
249 delete it_prefetch->second;
250 prefetch_id_table.erase(id);
251 ids_to_cache[nums_to_cache] = id;
252 nums_to_cache++;
253 }
254 }
255 update(ids_to_cache.data(), nums_to_cache, false);
256 }
257
258 private:
259 class LRUNode {

Callers 2

AddToCacheMethod · 0.45
TESTFunction · 0.45

Calls 7

ref_countMethod · 0.80
updateFunction · 0.50
findMethod · 0.45
endMethod · 0.45
UnRefMethod · 0.45
eraseMethod · 0.45
dataMethod · 0.45

Tested by 1

TESTFunction · 0.36