Пример #1
0
  def scatter(self, indices, value, name=None):
    """Scatter the values of a `Tensor` in specific indices of a `TensorArray`.

    Args:
      indices: A `1-D` `Tensor` taking values in `[0, max_value)`.  If
        the `TensorArray` is not dynamic, `max_value=size()`.
      value: (N+1)-D.  Tensor of type `dtype`.  The Tensor to unpack.
      name: A name for the operation (optional).

    Returns:
      A new TensorArray object with flow that ensures the scatter occurs.
      Use this object all for subsequent operations.

    Raises:
      ValueError: if the shape inference fails.
    """
    with ops.name_scope(name, "TensorArrayScatter",
                        [self._handle, value, indices]):
      value = ops.convert_to_tensor(value, name="value")
      if self._infer_shape and context.in_graph_mode():
        self._merge_element_shape(value.shape[1:])
      with self._maybe_colocate_with(value):
        flow_out = gen_data_flow_ops._tensor_array_scatter_v3(
            handle=self._handle,
            indices=indices,
            value=value,
            flow_in=self._flow,
            name=name)
      ta = TensorArray(
          dtype=self._dtype, handle=self._handle, flow=flow_out,
          colocate_with_first_write_call=self._colocate_with_first_write_call)
      ta._infer_shape = self._infer_shape
      ta._element_shape = self._element_shape
      ta._colocate_with = self._colocate_with
      return ta
Пример #2
0
    def scatter(self, indices, value, name=None):
        """Scatter the values of a `Tensor` in specific indices of a `TensorArray`.

    Args:
      indices: A `1-D` `Tensor` taking values in `[0, max_value)`.  If
        the `TensorArray` is not dynamic, `max_value=size()`.
      value: (N+1)-D.  Tensor of type `dtype`.  The Tensor to unpack.
      name: A name for the operation (optional).

    Returns:
      A new TensorArray object with flow that ensures the scatter occurs.
      Use this object all for subsequent operations.

    Raises:
      ValueError: if the shape inference fails.
    """
        with ops.name_scope(name, "TensorArrayScatter", [self._handle, value, indices]):
            value = ops.convert_to_tensor(value, name="value")
            _maybe_set_device(self._handle.op, value)
            with ops.colocate_with(self._handle):
                flow_out = gen_data_flow_ops._tensor_array_scatter_v3(
                    handle=self._handle, indices=indices, value=value, flow_in=self._flow, name=name
                )
            ta = TensorArray(dtype=self._dtype, handle=self._handle, flow=flow_out)
            ta._infer_shape = self._infer_shape
            ta._element_shape = self._element_shape
            if ta._infer_shape:
                val_shape = flow_out.op.inputs[2].get_shape()
                element_shape = tensor_shape.unknown_shape()
                if val_shape.dims is not None:
                    element_shape = tensor_shape.TensorShape(val_shape.dims[1:])
                ta._merge_element_shape(element_shape)
            return ta
Пример #3
0
 def scatter(self, indices, value, name=None):
   """See TensorArray."""
   with ops.name_scope(name, "TensorArrayScatter",
                       [self._handle, value, indices]):
     value = ops.convert_to_tensor(value, name="value")
     if self._infer_shape and context.in_graph_mode():
       self._merge_element_shape(value.shape[1:])
     with self._maybe_colocate_with(value):
       flow_out = gen_data_flow_ops._tensor_array_scatter_v3(
           handle=self._handle,
           indices=indices,
           value=value,
           flow_in=self._flow,
           name=name)
     ta = TensorArray(
         dtype=self._dtype, handle=self._handle, flow=flow_out,
         colocate_with_first_write_call=self._colocate_with_first_write_call)
     ta._infer_shape = self._infer_shape
     ta._element_shape = self._element_shape
     ta._colocate_with = self._colocate_with
     return ta
Пример #4
0
 def scatter(self, indices, value, name=None):
   """See TensorArray."""
   with ops.name_scope(name, "TensorArrayScatter",
                       [self._handle, value, indices]):
     value = ops.convert_to_tensor(value, name="value")
     if self._infer_shape and context.in_graph_mode():
       self._merge_element_shape(value.shape[1:])
     with self._maybe_colocate_with(value):
       flow_out = gen_data_flow_ops._tensor_array_scatter_v3(
           handle=self._handle,
           indices=indices,
           value=value,
           flow_in=self._flow,
           name=name)
     ta = TensorArray(
         dtype=self._dtype, handle=self._handle, flow=flow_out,
         colocate_with_first_write_call=self._colocate_with_first_write_call)
     ta._infer_shape = self._infer_shape
     ta._element_shape = self._element_shape
     ta._colocate_with = self._colocate_with
     return ta
Пример #5
0
    def scatter(self, indices, value, name=None):
        """Scatter the values of a `Tensor` in specific indices of a `TensorArray`.

    Args:
      indices: A `1-D` `Tensor` taking values in `[0, max_value)`.  If
        the `TensorArray` is not dynamic, `max_value=size()`.
      value: (N+1)-D.  Tensor of type `dtype`.  The Tensor to unpack.
      name: A name for the operation (optional).

    Returns:
      A new TensorArray object with flow that ensures the scatter occurs.
      Use this object all for subsequent operations.

    Raises:
      ValueError: if the shape inference fails.
    """
        with ops.name_scope(name, "TensorArrayScatter",
                            [self._handle, value, indices]):
            value = ops.convert_to_tensor(value, name="value")
            _maybe_set_device(self._handle.op, value)
            with ops.colocate_with(self._handle):
                flow_out = gen_data_flow_ops._tensor_array_scatter_v3(
                    handle=self._handle,
                    indices=indices,
                    value=value,
                    flow_in=self._flow,
                    name=name)
            ta = TensorArray(dtype=self._dtype,
                             handle=self._handle,
                             flow=flow_out)
            ta._infer_shape = self._infer_shape
            ta._element_shape = self._element_shape
            if ta._infer_shape:
                val_shape = flow_out.op.inputs[2].get_shape()
                element_shape = tensor_shape.unknown_shape()
                if val_shape.dims is not None:
                    element_shape = tensor_shape.TensorShape(
                        val_shape.dims[1:])
                ta._merge_element_shape(element_shape)
            return ta