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

Method Initialize

tensorflow/core/kernels/initializable_lookup_table.cc:41–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41Status InitializableLookupTable::Initialize(InitTableIterator& iter) {
42 if (!iter.Valid()) {
43 return iter.status();
44 }
45 TF_RETURN_IF_ERROR(
46 CheckKeyAndValueTensorsForInsert(iter.keys(), iter.values()));
47
48 mutex_lock l(mu_);
49 if (is_initialized()) {
50 bool result;
51 TF_RETURN_IF_ERROR(AreEntriesSame(iter, &result));
52 // If the table is already initialized, we make sure that the entries in the
53 // table are the same that we want to initialize the table with.
54 if (!result) {
55 return errors::FailedPrecondition(
56 "Table was already initialized with "
57 "different data.");
58 } else {
59 return Status::OK();
60 }
61 }
62 TF_RETURN_IF_ERROR(DoLazyPrepare([&iter]() { return iter.total_size(); }));
63 while (iter.Valid()) {
64 TF_RETURN_IF_ERROR(DoInsert(iter.keys(), iter.values()));
65 iter.Next();
66 }
67 if (!errors::IsOutOfRange(iter.status())) {
68 return iter.status();
69 }
70
71 // Prevent compiler/memory reordering of is_initialized and
72 // the initialization itself.
73 std::atomic_thread_fence(std::memory_order_release);
74 is_initialized_ = true;
75 return Status::OK();
76}
77
78Status InitializableLookupTable::AreEntriesSame(const InitTableIterator& iter,
79 bool* result) {

Callers

nothing calls this directly

Calls 7

FailedPreconditionFunction · 0.85
ValidMethod · 0.45
statusMethod · 0.45
keysMethod · 0.45
valuesMethod · 0.45
total_sizeMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected