aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yutaka Leon <yutaka.leon@gmail.com>2016-03-14 12:51:13 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-03-14 14:26:56 -0700
commitdefc7870810c9503ebad3626f9f9a411a53597d9 (patch)
treed902517b3de173874999e2d9693f60d587beaf8d
parent79453c19714cd8bc19b445fb7e29478e868ae4e2 (diff)
Ensure the table size is returned only when the table is initialized.
Change: 117166443
-rw-r--r--tensorflow/core/kernels/lookup_table_op.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/tensorflow/core/kernels/lookup_table_op.cc b/tensorflow/core/kernels/lookup_table_op.cc
index acaed73bbd..ebbf8aa7aa 100644
--- a/tensorflow/core/kernels/lookup_table_op.cc
+++ b/tensorflow/core/kernels/lookup_table_op.cc
@@ -51,7 +51,10 @@ namespace lookup {
template <class K, class V>
class HashTable : public InitializableLookupTable {
public:
- size_t size() const override { return table_ ? table_->size() : 0; }
+ size_t size() const override {
+ // return the size of the table only if it's initialized, otherwise 0.
+ return table_ && is_initialized_ ? table_->size() : 0;
+ }
DataType key_dtype() const override { return DataTypeToEnum<K>::v(); }