(self)
| 1659 | ops.add_to_collection(ops.GraphKeys.SAVEABLE_OBJECTS, saveable) |
| 1660 | |
| 1661 | def _create_resource(self): |
| 1662 | # The table must be shared if checkpointing is requested for multi-worker |
| 1663 | # training to work correctly. Use the node name if no shared_name has been |
| 1664 | # explicitly specified. |
| 1665 | use_node_name_sharing = self._checkpoint and self._shared_name is None |
| 1666 | if self._default_value.get_shape().ndims == 0: |
| 1667 | table_ref = gen_lookup_ops.mutable_hash_table_v2( |
| 1668 | shared_name=self._shared_name, |
| 1669 | use_node_name_sharing=use_node_name_sharing, |
| 1670 | key_dtype=self._key_dtype, |
| 1671 | value_dtype=self._value_dtype, |
| 1672 | name=self._name) |
| 1673 | else: |
| 1674 | table_ref = gen_lookup_ops.mutable_hash_table_of_tensors_v2( |
| 1675 | shared_name=self._shared_name, |
| 1676 | use_node_name_sharing=use_node_name_sharing, |
| 1677 | key_dtype=self._key_dtype, |
| 1678 | value_dtype=self._value_dtype, |
| 1679 | value_shape=self._default_value.get_shape(), |
| 1680 | name=self._name) |
| 1681 | |
| 1682 | if context.executing_eagerly(): |
| 1683 | self._table_name = None |
| 1684 | else: |
| 1685 | self._table_name = table_ref.op.name.split("/")[-1] |
| 1686 | return table_ref |
| 1687 | |
| 1688 | @property |
| 1689 | def name(self): |
no test coverage detected