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

Method DoInsert

tensorflow/core/kernels/lookup_table_op.h:230–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228 }
229
230 Status DoInsert(const Tensor& keys, const Tensor& values) override {
231 if (!table_) {
232 return errors::FailedPrecondition("HashTable is not prepared.");
233 }
234
235 const auto key_values = keys.flat<K>();
236 const auto value_values = values.flat<V>();
237 for (int64 i = 0; i < key_values.size(); ++i) {
238 const K key = SubtleMustCopyIfIntegral(key_values(i));
239 const V value = SubtleMustCopyIfIntegral(value_values(i));
240 const V& previous_value = gtl::LookupOrInsert(table_.get(), key, value);
241 if (previous_value != value) {
242 return errors::FailedPrecondition(
243 "HashTable has different value for same key. Key ", key, " has ",
244 previous_value, " and trying to add value ", value);
245 }
246 }
247 return Status::OK();
248 }
249
250 Status DoFind(const Tensor& key, Tensor* value,
251 const Tensor& default_value) override {

Callers

nothing calls this directly

Calls 4

FailedPreconditionFunction · 0.85
SubtleMustCopyIfIntegralFunction · 0.85
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected