Skip to content

Commit c1517aa

Browse files
rohan100jaintensorflower-gardener
authored andcommitted
Adding support for int64->bool mapping in MutableDenseHashTable
Change: 149546404
1 parent c5238fb commit c1517aa

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tensorflow/contrib/lookup/lookup_ops_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,24 @@ def testBasic(self):
695695
result = output.eval()
696696
self.assertAllEqual([0, 1, -1], result)
697697

698+
def testBasicBool(self):
699+
with self.test_session():
700+
keys = constant_op.constant([11, 12, 13], dtypes.int64)
701+
values = constant_op.constant([True, True, True], dtypes.bool)
702+
table = lookup.MutableDenseHashTable(
703+
dtypes.int64, dtypes.bool, default_value=False, empty_key=0)
704+
self.assertAllEqual(0, table.size().eval())
705+
706+
table.insert(keys, values).run()
707+
self.assertAllEqual(3, table.size().eval())
708+
709+
input_string = constant_op.constant([11, 12, 15], dtypes.int64)
710+
output = table.lookup(input_string)
711+
self.assertAllEqual([3], output.get_shape())
712+
713+
result = output.eval()
714+
self.assertAllEqual([True, True, False], result)
715+
698716
def testLookupUnknownShape(self):
699717
with self.test_session():
700718
keys = constant_op.constant([11, 12, 13], dtypes.int64)

tensorflow/core/kernels/lookup_table_op.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ REGISTER_KERNEL(int64, float);
934934
REGISTER_KERNEL(int64, double);
935935
REGISTER_KERNEL(string, float);
936936
REGISTER_KERNEL(string, bool);
937+
REGISTER_KERNEL(int64, bool);
937938

938939
#undef REGISTER_KERNEL
939940

0 commit comments

Comments
 (0)