A generic mutable hash table implementation using tensors as backing store.

Data can be inserted by calling the insert method and removed by calling the remove method. It does not support initialization via the init method.

It uses "open addressing" with quadratic reprobing to resolve collisions. Compared to MutableHashTable the insert, remove and lookup operations in a DenseHashTable are typically faster, but memory usage can be higher. However, DenseHashTable does not require additional memory for temporary tensors created during checkpointing and restore operations.

Example usage:

table = tf.lookup.experimental.DenseHashTable(
keys = tf.constant(['a', 'b', 'c'])
values = tf.constant([0, 1, 2], dtype=tf.int64)
table.insert(keys, values)
table.lookup(tf.constant(['a', 'b', 'c','d'])).numpy()
array([ 0,  1, -1, -1])

key_dtype the type of the key tensors.
value_dtype the type of the value tensors.
default_value The value to use if a key is missing in the table.
empty_key the key to use to represent empty buckets internally. Must not be used in insert, remove or lookup operations.