aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/c/c_api_experimental.h
diff options
context:
space:
mode:
authorGravatar Mingsheng Hong <hongm@google.com>2018-05-05 07:10:58 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-05-07 15:42:04 -0700
commit067be1aa75d9065b6cc57ba6316fc17544a9fdf1 (patch)
treecc952cc49d777f7fc1ac828a1c42314aefb8dace /tensorflow/c/c_api_experimental.h
parent150089e6e67e4492f098cdd8f9f2f48dc9f9cc56 (diff)
Part 2 of Swift<->TF sends/recvs: support receiving tensors in TF from
Swift via direct session. The changes are: 1. Added a TF experimental C API for Swift host to enqueue a tensor for sending to TF. Again, the C APIs can be removed once the Fifo-queue based design proves stable later. 2. TFLowerGraph is extended to generate Fifo related nodes for TF to receive tensors. This is similar to the extension for TF to send tensors. 3. TFPartition is extended to support host send (createHostSend()), which does the tensor send via a new protocol method TensorSendableReceivable.sendToDevice(). The main complexity is in sending a scalar, where a new protocol method TensorSendableReceivable.createScalarTensor() is called to first create a tensor out of it, and then send it over to TF. Also removed code for protocol conformance on AccelerableByTensorFlow. Instead have compiler look up that conformance from the SILFunction on sending/receiving tensors. AccelerableByTensorFlow could be removed from the compiler-known protocol list now, but we'll defer that till things can stabilized more (in the past this protocol has been added to and removed from the list at different times). PiperOrigin-RevId: 195539436
Diffstat (limited to 'tensorflow/c/c_api_experimental.h')
-rw-r--r--tensorflow/c/c_api_experimental.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/tensorflow/c/c_api_experimental.h b/tensorflow/c/c_api_experimental.h
index e6757c065f..20bdace40f 100644
--- a/tensorflow/c/c_api_experimental.h
+++ b/tensorflow/c/c_api_experimental.h
@@ -87,8 +87,11 @@ TF_CAPI_EXPORT extern TF_Operation* TF_MakeFileBasedIteratorGetNextWithDatasets(
unsigned char is_mnist, TF_Status* status);
// On success, dequeues a tensor from a TF-managed FifoQueue given by
-// `tensor_id`, associated with `session`. Caller must call TF_DeleteTensor()
-// over the returned tensor. If the queue is empty, this call is blocked.
+// `tensor_id`, associated with `session`. There must be a graph node named
+// "fifo_queue_dequeue_<tensor_id>", to be executed by this API call.
+
+// Caller must call TF_DeleteTensor() over the returned tensor. If the queue is
+// empty, this call is blocked.
//
// Tensors are enqueued via the corresponding TF enqueue op.
// TODO(hongm): Add support for `timeout_ms`.
@@ -96,6 +99,22 @@ TF_CAPI_EXPORT extern TF_Tensor* TF_DequeueNamedTensor(TF_Session* session,
int tensor_id,
TF_Status* status);
+// On success, enqueues `tensor` into a TF-managed FifoQueue given by
+// `tensor_id`, associated with `session`. There must be a graph node named
+// "fifo_queue_enqueue_<tensor_id>", to be executed by this API call. It reads
+// from a placeholder node "arg_tensor_enqueue_<tensor_id>".
+//
+// `tensor` is still owned by the caller. This call will be blocked if the queue
+// has reached its capacity, and will be unblocked when the queued tensors again
+// drop below the capacity due to dequeuing.
+//
+// Tensors are dequeued via the corresponding TF dequeue op.
+// TODO(hongm): Add support for `timeout_ms`.
+TF_CAPI_EXPORT extern void TF_EnqueueNamedTensor(TF_Session* session,
+ int tensor_id,
+ TF_Tensor* tensor,
+ TF_Status* status);
+
#ifdef __cplusplus
} /* end extern "C" */
#endif