Ejemplo n.º 1
0
  def insert(self, keys, values, name=None):
    """Associates `keys` with `values`.

    Args:
      keys: Keys to insert. Can be a tensor of any shape. Must match the
        table's key type.
      values: Values to be associated with keys. Must be a tensor of the same
        shape as `keys` and match the table's value type.
      name: A name for the operation (optional).

    Returns:
      The created Operation.

    Raises:
      TypeError: when `keys` or `values` doesn't match the table data
        types.
    """
    with ops.name_scope(name, "%s_lookup_table_insert" % self._name,
                        [self._table_ref, keys, values]) as name:
      keys = ops.convert_to_tensor(keys, dtype=self._key_dtype, name="keys")
      values = ops.convert_to_tensor(
          values, dtype=self._value_dtype, name="values")
      with ops.colocate_with(self._table_ref):
        op = gen_lookup_ops.lookup_table_insert_v2(
            self._table_ref, keys, values, name=name)
      return op
Ejemplo n.º 2
0
  def insert(self, keys, values, name=None):
    """Associates `keys` with `values`.

    Args:
      keys: Keys to insert. Can be a tensor of any shape. Must match the
        table's key type.
      values: Values to be associated with keys. Must be a tensor of the same
        shape as `keys` and match the table's value type.
      name: A name for the operation (optional).

    Returns:
      The created Operation.

    Raises:
      TypeError: when `keys` or `values` doesn't match the table data
        types.
    """
    with ops.name_scope(name, "%s_lookup_table_insert" % self.name,
                        [self.resource_handle, keys, values]) as name:
      keys = ops.convert_to_tensor(keys, self._key_dtype, name="keys")
      values = ops.convert_to_tensor(values, self._value_dtype, name="values")
      with ops.colocate_with(self.resource_handle):
        # pylint: disable=protected-access
        op = gen_lookup_ops.lookup_table_insert_v2(
            self.resource_handle, keys, values, name=name)
    return op
Ejemplo n.º 3
0
  def insert(self, keys, values, name=None):
    """Associates `keys` with `values`.

    Args:
      keys: Keys to insert. Can be a tensor of any shape. Must match the
        table's key type.
      values: Values to be associated with keys. Must be a tensor of the same
        shape as `keys` and match the table's value type.
      name: A name for the operation (optional).

    Returns:
      The created Operation.

    Raises:
      TypeError: when `keys` or `values` doesn't match the table data
        types.
    """
    # pylint: disable=protected-access
    lookup_ops._check_table_dtypes(self, keys.dtype, values.dtype)
    # pylint: enable=protected-access
    with ops.name_scope(name, "%s_lookup_table_insert" % self._name,
                        [self._table_ref, keys, values]) as name:
      with ops.colocate_with(self._table_ref):
        op = gen_lookup_ops.lookup_table_insert_v2(
            self._table_ref, keys, values, name=name)
      return op
Ejemplo n.º 4
0
    def insert(self, keys, values, name=None):
        """Associates `keys` with `values`.

    Args:
      keys: Keys to insert. Can be a tensor of any shape. Must match the
        table's key type.
      values: Values to be associated with keys. Must be a tensor of the same
        shape as `keys` and match the table's value type.
      name: A name for the operation (optional).

    Returns:
      The created Operation.

    Raises:
      TypeError: when `keys` or `values` doesn't match the table data
        types.
    """
        # pylint: disable=protected-access
        lookup_ops._check_table_dtypes(self, keys.dtype, values.dtype)
        # pylint: enable=protected-access
        with ops.name_scope(name, "%s_lookup_table_insert" % self._name,
                            [self._table_ref, keys, values]) as name:
            with ops.colocate_with(self._table_ref):
                op = gen_lookup_ops.lookup_table_insert_v2(self._table_ref,
                                                           keys,
                                                           values,
                                                           name=name)
            return op
Ejemplo n.º 5
0
 def insert(self, keys, values):
     return gen_lookup_ops.lookup_table_insert_v2(self.table_ref, keys,
                                                  values)
Ejemplo n.º 6
0
 def insert(self, keys, values):
   return gen_lookup_ops.lookup_table_insert_v2(self.table_ref, keys, values)