diff options
author | 2016-03-14 12:51:13 -0800 | |
---|---|---|
committer | 2016-03-14 14:26:56 -0700 | |
commit | defc7870810c9503ebad3626f9f9a411a53597d9 (patch) | |
tree | d902517b3de173874999e2d9693f60d587beaf8d | |
parent | 79453c19714cd8bc19b445fb7e29478e868ae4e2 (diff) |
Ensure the table size is returned only when the table is initialized.
Change: 117166443
-rw-r--r-- | tensorflow/core/kernels/lookup_table_op.cc | 5 |
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(); } |