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

Method ExportValues

tensorflow/core/kernels/lookup_table_op.h:185–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183 }
184
185 Status ExportValues(OpKernelContext* context) override {
186 if (!is_initialized_) {
187 return errors::Aborted("HashTable is not initialized.");
188 }
189
190 const int64 size = table_->size();
191
192 Tensor* keys;
193 Tensor* values;
194 TF_RETURN_IF_ERROR(
195 context->allocate_output("keys", TensorShape({size}), &keys));
196 TF_RETURN_IF_ERROR(
197 context->allocate_output("values", TensorShape({size}), &values));
198
199 auto keys_data = keys->flat<K>();
200 auto values_data = values->flat<V>();
201 int64 i = 0;
202 for (auto it = table_->begin(); it != table_->end(); ++it, ++i) {
203 keys_data(i) = it->first;
204 values_data(i) = it->second;
205 }
206 return Status::OK();
207 }
208
209 DataType key_dtype() const override { return DataTypeToEnum<K>::v(); }
210

Callers

nothing calls this directly

Calls 5

allocate_outputMethod · 0.80
TensorShapeClass · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected