예제 #1
0
    def enqueue(self, vals, name=None):
        """Enqueues one element to this queue.

    If the queue is full when this operation executes, it will block
    until the element has been enqueued.

    Args:
      vals: The tuple of `Tensor` objects to be enqueued.
      name: A name for the operation (optional).

    Returns:
      The operation that enqueues a new tuple of tensors to the queue.
    """
        if name is None:
            name = "%s_enqueue" % self._name
        ret = gen_data_flow_ops._queue_enqueue(self._queue_ref,
                                               vals,
                                               name=name)

        # NOTE(mrry): Not using a shape function because we need access to
        # the Queue object.
        for val, shape in zip(ret.inputs[1:], self._shapes):
            val.get_shape().assert_is_compatible_with(shape)

        return ret
예제 #2
0
  def enqueue(self, vals, name=None):
    """Enqueues one element to this queue.

    If the queue is full when this operation executes, it will block
    until the element has been enqueued.

    Args:
      vals: The tuple of `Tensor` objects to be enqueued.
      name: A name for the operation (optional).

    Returns:
      The operation that enqueues a new tuple of tensors to the queue.
    """
    if not isinstance(vals, (list, tuple)):
      vals = [vals]

    with ops.op_scope(vals, name, "%s_enqueue" % self._name) as scope:
      vals = self._check_enqueue_dtypes(vals)

      # NOTE(mrry): Not using a shape function because we need access to
      # the `QueueBase` object.
      for val, shape in zip(vals, self._shapes):
        val.get_shape().assert_is_compatible_with(shape)

      return gen_data_flow_ops._queue_enqueue(self._queue_ref, vals, name=scope)
예제 #3
0
  def enqueue(self, vals, name=None):
    """Enqueues one element to this queue.

    If the queue is full when this operation executes, it will block
    until the element has been enqueued.

    At runtime, this operation may raise an error if the queue is
    [closed](#QueueBase.close) before or during its execution. If the
    queue is closed before this operation runs,
    `tf.errors.AbortedError` will be raised. If this operation is
    blocked, and either (i) the queue is closed by a close operation
    with `cancel_pending_enqueues=True`, or (ii) the session is
    [closed](../../api_docs/python/client.md#Session.close),
    `tf.errors.CancelledError` will be raised.

    Args:
      vals: A tensor, a list or tuple of tensors, or a dictionary containing
        the values to enqueue.
      name: A name for the operation (optional).

    Returns:
      The operation that enqueues a new tuple of tensors to the queue.
    """
    with ops.op_scope(self._scope_vals(vals), name,
                      "%s_enqueue" % self._name) as scope:
      vals = self._check_enqueue_dtypes(vals)

      # NOTE(mrry): Not using a shape function because we need access to
      # the `QueueBase` object.
      for val, shape in zip(vals, self._shapes):
        val.get_shape().assert_is_compatible_with(shape)

      return gen_data_flow_ops._queue_enqueue(self._queue_ref, vals, name=scope)
예제 #4
0
    def enqueue(self, vals, name=None):
        """Enqueues one element to this queue.

    If the queue is full when this operation executes, it will block
    until the element has been enqueued.

    At runtime, this operation may raise an error if the queue is
    [closed](#QueueBase.close) before or during its execution. If the
    queue is closed before this operation runs,
    `tf.errors.AbortedError` will be raised. If this operation is
    blocked, and either (i) the queue is closed by a close operation
    with `cancel_pending_enqueues=True`, or (ii) the session is
    [closed](../../api_docs/python/client.md#Session.close),
    `tf.errors.CancelledError` will be raised.

    Args:
      vals: A tensor, a list or tuple of tensors, or a dictionary containing
        the values to enqueue.
      name: A name for the operation (optional).

    Returns:
      The operation that enqueues a new tuple of tensors to the queue.
    """
        with ops.name_scope(name, "%s_enqueue" % self._name,
                            self._scope_vals(vals)) as scope:
            vals = self._check_enqueue_dtypes(vals)

            # NOTE(mrry): Not using a shape function because we need access to
            # the `QueueBase` object.
            for val, shape in zip(vals, self._shapes):
                val.get_shape().assert_is_compatible_with(shape)

            return gen_data_flow_ops._queue_enqueue(self._queue_ref,
                                                    vals,
                                                    name=scope)
예제 #5
0
    def enqueue(self, vals, name=None):
        """Enqueues one element to this queue.

    If the queue is full when this operation executes, it will block
    until the element has been enqueued.

    Args:
      vals: The tuple of `Tensor` objects to be enqueued.
      name: A name for the operation (optional).

    Returns:
      The operation that enqueues a new tuple of tensors to the queue.
    """
        if name is None:
            name = "%s_enqueue" % self._name
        ret = gen_data_flow_ops._queue_enqueue(self._queue_ref, vals, name=name)

        # NOTE(mrry): Not using a shape function because we need access to
        # the Queue object.
        for val, shape in zip(ret.inputs[1:], self._shapes):
            val.get_shape().assert_is_compatible_with(shape)

        return ret