1// This file is MACHINE GENERATED! Do not edit.
2
3#ifndef TENSORFLOW_CC_OPS_DATA_FLOW_OPS_H_
4#define TENSORFLOW_CC_OPS_DATA_FLOW_OPS_H_
5
6// This file is MACHINE GENERATED! Do not edit.
7
8#include "tensorflow/cc/framework/ops.h"
9#include "tensorflow/cc/framework/scope.h"
10#include "tensorflow/core/framework/tensor.h"
11#include "tensorflow/core/framework/tensor_shape.h"
12#include "tensorflow/core/framework/types.h"
13#include "tensorflow/core/lib/gtl/array_slice.h"
14
15namespace tensorflow {
16namespace ops {
17
18/// @defgroup data_flow_ops Data Flow Ops
19/// @{
20
21/// Applies a gradient to a given accumulator.
22///
23/// Does not add if local_step is lesser than the accumulator's global_step.
24///
25/// Args:
26/// * scope: A Scope object
27/// * handle: The handle to a accumulator.
28/// * local_step: The local_step value at which the gradient was computed.
29/// * gradient: A tensor of the gradient to be accumulated.
30///
31/// Returns:
32/// * the created `Operation`
33class AccumulatorApplyGradient {
34 public:
35 AccumulatorApplyGradient(const ::tensorflow::Scope& scope, ::tensorflow::Input
36 handle, ::tensorflow::Input local_step,
37 ::tensorflow::Input gradient);
38 operator ::tensorflow::Operation() const { return operation; }
39
40 Operation operation;
41};
42
43/// Returns the number of gradients aggregated in the given accumulators.
44///
45/// Args:
46/// * scope: A Scope object
47/// * handle: The handle to an accumulator.
48///
49/// Returns:
50/// * `Output`: The number of gradients aggregated in the given accumulator.
51class AccumulatorNumAccumulated {
52 public:
53 AccumulatorNumAccumulated(const ::tensorflow::Scope& scope, ::tensorflow::Input
54 handle);
55 operator ::tensorflow::Output() const { return num_accumulated; }
56 operator ::tensorflow::Input() const { return num_accumulated; }
57 ::tensorflow::Node* node() const { return num_accumulated.node(); }
58
59 Operation operation;
60 ::tensorflow::Output num_accumulated;
61};
62
63/// Updates the accumulator with a new value for global_step.
64///
65/// Logs warning if the accumulator's value is already higher than
66/// new_global_step.
67///
68/// Args:
69/// * scope: A Scope object
70/// * handle: The handle to an accumulator.
71/// * new_global_step: The new global_step value to set.
72///
73/// Returns:
74/// * the created `Operation`
75class AccumulatorSetGlobalStep {
76 public:
77 AccumulatorSetGlobalStep(const ::tensorflow::Scope& scope, ::tensorflow::Input
78 handle, ::tensorflow::Input new_global_step);
79 operator ::tensorflow::Operation() const { return operation; }
80
81 Operation operation;
82};
83
84/// Extracts the average gradient in the given ConditionalAccumulator.
85///
86/// The op blocks until sufficient (i.e., more than num_required)
87/// gradients have been accumulated. If the accumulator has already
88/// aggregated more than num_required gradients, it returns the average of
89/// the accumulated gradients. Also automatically increments the recorded
90/// global_step in the accumulator by 1, and resets the aggregate to 0.
91///
92/// Args:
93/// * scope: A Scope object
94/// * handle: The handle to an accumulator.
95/// * num_required: Number of gradients required before we return an aggregate.
96/// * dtype: The data type of accumulated gradients. Needs to correspond to the type
97/// of the accumulator.
98///
99/// Returns:
100/// * `Output`: The average of the accumulated gradients.
101class AccumulatorTakeGradient {
102 public:
103 AccumulatorTakeGradient(const ::tensorflow::Scope& scope, ::tensorflow::Input
104 handle, ::tensorflow::Input num_required, DataType
105 dtype);
106 operator ::tensorflow::Output() const { return average; }
107 operator ::tensorflow::Input() const { return average; }
108 ::tensorflow::Node* node() const { return average.node(); }
109
110 Operation operation;
111 ::tensorflow::Output average;
112};
113
114/// Defines a barrier that persists across different graph executions.
115///
116/// A barrier represents a key-value map, where each key is a string, and
117/// each value is a tuple of tensors.
118///
119/// At runtime, the barrier contains 'complete' and 'incomplete'
120/// elements. A complete element has defined tensors for all components of
121/// its value tuple, and may be accessed using BarrierTakeMany. An
122/// incomplete element has some undefined components in its value tuple,
123/// and may be updated using BarrierInsertMany.
124///
125/// Args:
126/// * scope: A Scope object
127/// * component_types: The type of each component in a value.
128///
129/// Optional attributes (see `Attrs`):
130/// * shapes: The shape of each component in a value. Each shape must be 1 in the
131/// first dimension. The length of this attr must be the same as the length of
132/// component_types.
133/// * capacity: The capacity of the barrier. The default capacity is MAX_INT32,
134/// which is the largest capacity of the underlying queue.
135/// * container: If non-empty, this barrier is placed in the given container.
136/// Otherwise, a default container is used.
137/// * shared_name: If non-empty, this barrier will be shared under the given name
138/// across multiple sessions.
139///
140/// Returns:
141/// * `Output`: The handle to the barrier.
142class Barrier {
143 public:
144 /// Optional attribute setters for Barrier
145 struct Attrs {
146 /// The shape of each component in a value. Each shape must be 1 in the
147 /// first dimension. The length of this attr must be the same as the length of
148 /// component_types.
149 ///
150 /// Defaults to []
151 TF_MUST_USE_RESULT Attrs Shapes(const gtl::ArraySlice<PartialTensorShape>& x) {
152 Attrs ret = *this;
153 ret.shapes_ = x;
154 return ret;
155 }
156
157 /// The capacity of the barrier. The default capacity is MAX_INT32,
158 /// which is the largest capacity of the underlying queue.
159 ///
160 /// Defaults to -1
161 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
162 Attrs ret = *this;
163 ret.capacity_ = x;
164 return ret;
165 }
166
167 /// If non-empty, this barrier is placed in the given container.
168 /// Otherwise, a default container is used.
169 ///
170 /// Defaults to ""
171 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
172 Attrs ret = *this;
173 ret.container_ = x;
174 return ret;
175 }
176
177 /// If non-empty, this barrier will be shared under the given name
178 /// across multiple sessions.
179 ///
180 /// Defaults to ""
181 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
182 Attrs ret = *this;
183 ret.shared_name_ = x;
184 return ret;
185 }
186
187 gtl::ArraySlice<PartialTensorShape> shapes_ = {};
188 int64 capacity_ = -1;
189 StringPiece container_ = "";
190 StringPiece shared_name_ = "";
191 };
192 Barrier(const ::tensorflow::Scope& scope, const DataTypeSlice& component_types);
193 Barrier(const ::tensorflow::Scope& scope, const DataTypeSlice& component_types,
194 const Barrier::Attrs& attrs);
195 operator ::tensorflow::Output() const { return handle; }
196 operator ::tensorflow::Input() const { return handle; }
197 ::tensorflow::Node* node() const { return handle.node(); }
198
199 static Attrs Shapes(const gtl::ArraySlice<PartialTensorShape>& x) {
200 return Attrs().Shapes(x);
201 }
202 static Attrs Capacity(int64 x) {
203 return Attrs().Capacity(x);
204 }
205 static Attrs Container(StringPiece x) {
206 return Attrs().Container(x);
207 }
208 static Attrs SharedName(StringPiece x) {
209 return Attrs().SharedName(x);
210 }
211
212 Operation operation;
213 ::tensorflow::Output handle;
214};
215
216/// Closes the given barrier.
217///
218/// This operation signals that no more new elements will be inserted in the
219/// given barrier. Subsequent InsertMany that try to introduce a new key will fail.
220/// Subsequent InsertMany operations that just add missing components to already
221/// existing elements will continue to succeed. Subsequent TakeMany operations will
222/// continue to succeed if sufficient completed elements remain in the barrier.
223/// Subsequent TakeMany operations that would block will fail immediately.
224///
225/// Args:
226/// * scope: A Scope object
227/// * handle: The handle to a barrier.
228///
229/// Optional attributes (see `Attrs`):
230/// * cancel_pending_enqueues: If true, all pending enqueue requests that are
231/// blocked on the barrier's queue will be canceled. InsertMany will fail, even
232/// if no new key is introduced.
233///
234/// Returns:
235/// * the created `Operation`
236class BarrierClose {
237 public:
238 /// Optional attribute setters for BarrierClose
239 struct Attrs {
240 /// If true, all pending enqueue requests that are
241 /// blocked on the barrier's queue will be canceled. InsertMany will fail, even
242 /// if no new key is introduced.
243 ///
244 /// Defaults to false
245 TF_MUST_USE_RESULT Attrs CancelPendingEnqueues(bool x) {
246 Attrs ret = *this;
247 ret.cancel_pending_enqueues_ = x;
248 return ret;
249 }
250
251 bool cancel_pending_enqueues_ = false;
252 };
253 BarrierClose(const ::tensorflow::Scope& scope, ::tensorflow::Input handle);
254 BarrierClose(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
255 const BarrierClose::Attrs& attrs);
256 operator ::tensorflow::Operation() const { return operation; }
257
258 static Attrs CancelPendingEnqueues(bool x) {
259 return Attrs().CancelPendingEnqueues(x);
260 }
261
262 Operation operation;
263};
264
265/// Computes the number of incomplete elements in the given barrier.
266///
267/// Args:
268/// * scope: A Scope object
269/// * handle: The handle to a barrier.
270///
271/// Returns:
272/// * `Output`: The number of incomplete elements (i.e. those with some of their value
273/// components not set) in the barrier.
274class BarrierIncompleteSize {
275 public:
276 BarrierIncompleteSize(const ::tensorflow::Scope& scope, ::tensorflow::Input
277 handle);
278 operator ::tensorflow::Output() const { return size; }
279 operator ::tensorflow::Input() const { return size; }
280 ::tensorflow::Node* node() const { return size.node(); }
281
282 Operation operation;
283 ::tensorflow::Output size;
284};
285
286/// For each key, assigns the respective value to the specified component.
287///
288/// If a key is not found in the barrier, this operation will create a new
289/// incomplete element. If a key is found in the barrier, and the element
290/// already has a value at component_index, this operation will fail with
291/// INVALID_ARGUMENT, and leave the barrier in an undefined state.
292///
293/// Args:
294/// * scope: A Scope object
295/// * handle: The handle to a barrier.
296/// * keys: A one-dimensional tensor of keys, with length n.
297/// * values: An any-dimensional tensor of values, which are associated with the
298/// respective keys. The 0th dimension must have length n.
299/// * component_index: The component of the barrier elements that is being assigned.
300///
301/// Returns:
302/// * the created `Operation`
303class BarrierInsertMany {
304 public:
305 BarrierInsertMany(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
306 ::tensorflow::Input keys, ::tensorflow::Input values, int64
307 component_index);
308 operator ::tensorflow::Operation() const { return operation; }
309
310 Operation operation;
311};
312
313/// Computes the number of complete elements in the given barrier.
314///
315/// Args:
316/// * scope: A Scope object
317/// * handle: The handle to a barrier.
318///
319/// Returns:
320/// * `Output`: The number of complete elements (i.e. those with all of their value
321/// components set) in the barrier.
322class BarrierReadySize {
323 public:
324 BarrierReadySize(const ::tensorflow::Scope& scope, ::tensorflow::Input handle);
325 operator ::tensorflow::Output() const { return size; }
326 operator ::tensorflow::Input() const { return size; }
327 ::tensorflow::Node* node() const { return size.node(); }
328
329 Operation operation;
330 ::tensorflow::Output size;
331};
332
333/// Takes the given number of completed elements from a barrier.
334///
335/// This operation concatenates completed-element component tensors along
336/// the 0th dimension to make a single component tensor.
337///
338/// Elements come out of the barrier when they are complete, and in the order
339/// in which they were placed into the barrier. The indices output provides
340/// information about the batch in which each element was originally inserted
341/// into the barrier.
342///
343/// Args:
344/// * scope: A Scope object
345/// * handle: The handle to a barrier.
346/// * num_elements: A single-element tensor containing the number of elements to
347/// take.
348/// * component_types: The type of each component in a value.
349///
350/// Optional attributes (see `Attrs`):
351/// * allow_small_batch: Allow to return less than num_elements items if barrier is
352/// already closed.
353/// * timeout_ms: If the queue is empty, this operation will block for up to
354/// timeout_ms milliseconds.
355/// Note: This option is not supported yet.
356///
357/// Returns:
358/// * `Output` indices: A one-dimensional tensor of indices, with length num_elems.
359/// These indices refer to the batch in which the values were placed into the
360/// barrier (starting with MIN_LONG and increasing with each BarrierInsertMany).
361/// * `Output` keys: A one-dimensional tensor of keys, with length num_elements.
362/// * `OutputList` values: One any-dimensional tensor per component in a barrier element. All
363/// values have length num_elements in the 0th dimension.
364class BarrierTakeMany {
365 public:
366 /// Optional attribute setters for BarrierTakeMany
367 struct Attrs {
368 /// Allow to return less than num_elements items if barrier is
369 /// already closed.
370 ///
371 /// Defaults to false
372 TF_MUST_USE_RESULT Attrs AllowSmallBatch(bool x) {
373 Attrs ret = *this;
374 ret.allow_small_batch_ = x;
375 return ret;
376 }
377
378 /// Defaults to false
379 TF_MUST_USE_RESULT Attrs WaitForIncomplete(bool x) {
380 Attrs ret = *this;
381 ret.wait_for_incomplete_ = x;
382 return ret;
383 }
384
385 /// If the queue is empty, this operation will block for up to
386 /// timeout_ms milliseconds.
387 /// Note: This option is not supported yet.
388 ///
389 /// Defaults to -1
390 TF_MUST_USE_RESULT Attrs TimeoutMs(int64 x) {
391 Attrs ret = *this;
392 ret.timeout_ms_ = x;
393 return ret;
394 }
395
396 bool allow_small_batch_ = false;
397 bool wait_for_incomplete_ = false;
398 int64 timeout_ms_ = -1;
399 };
400 BarrierTakeMany(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
401 ::tensorflow::Input num_elements, const DataTypeSlice&
402 component_types);
403 BarrierTakeMany(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
404 ::tensorflow::Input num_elements, const DataTypeSlice&
405 component_types, const BarrierTakeMany::Attrs& attrs);
406
407 static Attrs AllowSmallBatch(bool x) {
408 return Attrs().AllowSmallBatch(x);
409 }
410 static Attrs WaitForIncomplete(bool x) {
411 return Attrs().WaitForIncomplete(x);
412 }
413 static Attrs TimeoutMs(int64 x) {
414 return Attrs().TimeoutMs(x);
415 }
416
417 Operation operation;
418 ::tensorflow::Output indices;
419 ::tensorflow::Output keys;
420 ::tensorflow::OutputList values;
421};
422
423/// A conditional accumulator for aggregating gradients.
424///
425/// The accumulator accepts gradients marked with local_step greater or
426/// equal to the most recent global_step known to the accumulator. The
427/// average can be extracted from the accumulator, provided sufficient
428/// gradients have been accumulated. Extracting the average automatically
429/// resets the aggregate to 0, and increments the global_step recorded by
430/// the accumulator.
431///
432/// Args:
433/// * scope: A Scope object
434/// * dtype: The type of the value being accumulated.
435/// * shape: The shape of the values, can be [], in which case shape is unknown.
436///
437/// Optional attributes (see `Attrs`):
438/// * container: If non-empty, this accumulator is placed in the given container.
439/// Otherwise, a default container is used.
440/// * shared_name: If non-empty, this accumulator will be shared under the
441/// given name across multiple sessions.
442///
443/// Returns:
444/// * `Output`: The handle to the accumulator.
445class ConditionalAccumulator {
446 public:
447 /// Optional attribute setters for ConditionalAccumulator
448 struct Attrs {
449 /// If non-empty, this accumulator is placed in the given container.
450 /// Otherwise, a default container is used.
451 ///
452 /// Defaults to ""
453 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
454 Attrs ret = *this;
455 ret.container_ = x;
456 return ret;
457 }
458
459 /// If non-empty, this accumulator will be shared under the
460 /// given name across multiple sessions.
461 ///
462 /// Defaults to ""
463 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
464 Attrs ret = *this;
465 ret.shared_name_ = x;
466 return ret;
467 }
468
469 /// Defaults to "MEAN"
470 TF_MUST_USE_RESULT Attrs ReductionType(StringPiece x) {
471 Attrs ret = *this;
472 ret.reduction_type_ = x;
473 return ret;
474 }
475
476 StringPiece container_ = "";
477 StringPiece shared_name_ = "";
478 StringPiece reduction_type_ = "MEAN";
479 };
480 ConditionalAccumulator(const ::tensorflow::Scope& scope, DataType dtype,
481 PartialTensorShape shape);
482 ConditionalAccumulator(const ::tensorflow::Scope& scope, DataType dtype,
483 PartialTensorShape shape, const
484 ConditionalAccumulator::Attrs& attrs);
485 operator ::tensorflow::Output() const { return handle; }
486 operator ::tensorflow::Input() const { return handle; }
487 ::tensorflow::Node* node() const { return handle.node(); }
488
489 static Attrs Container(StringPiece x) {
490 return Attrs().Container(x);
491 }
492 static Attrs SharedName(StringPiece x) {
493 return Attrs().SharedName(x);
494 }
495 static Attrs ReductionType(StringPiece x) {
496 return Attrs().ReductionType(x);
497 }
498
499 Operation operation;
500 ::tensorflow::Output handle;
501};
502
503/// Delete the tensor specified by its handle in the session.
504///
505/// Args:
506/// * scope: A Scope object
507/// * handle: The handle for a tensor stored in the session state.
508///
509/// Returns:
510/// * the created `Operation`
511class DeleteSessionTensor {
512 public:
513 DeleteSessionTensor(const ::tensorflow::Scope& scope, ::tensorflow::Input
514 handle);
515 operator ::tensorflow::Operation() const { return operation; }
516
517 Operation operation;
518};
519
520/// Partitions `data` into `num_partitions` tensors using indices from `partitions`.
521///
522/// For each index tuple `js` of size `partitions.ndim`, the slice `data[js, ...]`
523/// becomes part of `outputs[partitions[js]]`. The slices with `partitions[js] = i`
524/// are placed in `outputs[i]` in lexicographic order of `js`, and the first
525/// dimension of `outputs[i]` is the number of entries in `partitions` equal to `i`.
526/// In detail,
527///
528/// ```python
529/// outputs[i].shape = [sum(partitions == i)] + data.shape[partitions.ndim:]
530///
531/// outputs[i] = pack([data[js, ...] for js if partitions[js] == i])
532/// ```
533///
534/// `data.shape` must start with `partitions.shape`.
535///
536/// For example:
537///
538/// ```python
539/// # Scalar partitions.
540/// partitions = 1
541/// num_partitions = 2
542/// data = [10, 20]
543/// outputs[0] = [] # Empty with shape [0, 2]
544/// outputs[1] = [[10, 20]]
545///
546/// # Vector partitions.
547/// partitions = [0, 0, 1, 1, 0]
548/// num_partitions = 2
549/// data = [10, 20, 30, 40, 50]
550/// outputs[0] = [10, 20, 50]
551/// outputs[1] = [30, 40]
552/// ```
553///
554/// See `dynamic_stitch` for an example on how to merge partitions back.
555///
556/// <div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;">
557/// <img style="width:100%" src="https://www.tensorflow.org/images/DynamicPartition.png" alt>
558/// </div>
559///
560/// Args:
561/// * scope: A Scope object
562/// * partitions: Any shape. Indices in the range `[0, num_partitions)`.
563/// * num_partitions: The number of partitions to output.
564///
565/// Returns:
566/// * `OutputList`: The outputs tensor.
567class DynamicPartition {
568 public:
569 DynamicPartition(const ::tensorflow::Scope& scope, ::tensorflow::Input data,
570 ::tensorflow::Input partitions, int64 num_partitions);
571 ::tensorflow::Output operator[](size_t index) const { return outputs[index]; }
572
573
574 Operation operation;
575 ::tensorflow::OutputList outputs;
576};
577
578/// Interleave the values from the `data` tensors into a single tensor.
579///
580/// Builds a merged tensor such that
581///
582/// ```python
583/// merged[indices[m][i, ..., j], ...] = data[m][i, ..., j, ...]
584/// ```
585///
586/// For example, if each `indices[m]` is scalar or vector, we have
587///
588/// ```python
589/// # Scalar indices:
590/// merged[indices[m], ...] = data[m][...]
591///
592/// # Vector indices:
593/// merged[indices[m][i], ...] = data[m][i, ...]
594/// ```
595///
596/// Each `data[i].shape` must start with the corresponding `indices[i].shape`,
597/// and the rest of `data[i].shape` must be constant w.r.t. `i`. That is, we
598/// must have `data[i].shape = indices[i].shape + constant`. In terms of this
599/// `constant`, the output shape is
600///
601/// merged.shape = [max(indices)] + constant
602///
603/// Values are merged in order, so if an index appears in both `indices[m][i]` and
604/// `indices[n][j]` for `(m,i) < (n,j)` the slice `data[n][j]` will appear in the
605/// merged result. If you do not need this guarantee, ParallelDynamicStitch might
606/// perform better on some devices.
607///
608/// For example:
609///
610/// ```python
611/// indices[0] = 6
612/// indices[1] = [4, 1]
613/// indices[2] = [[5, 2], [0, 3]]
614/// data[0] = [61, 62]
615/// data[1] = [[41, 42], [11, 12]]
616/// data[2] = [[[51, 52], [21, 22]], [[1, 2], [31, 32]]]
617/// merged = [[1, 2], [11, 12], [21, 22], [31, 32], [41, 42],
618/// [51, 52], [61, 62]]
619/// ```
620///
621/// This method can be used to merge partitions created by `dynamic_partition`
622/// as illustrated on the following example:
623///
624/// ```python
625/// # Apply function (increments x_i) on elements for which a certain condition
626/// # apply (x_i != -1 in this example).
627/// x=tf.constant([0.1, -1., 5.2, 4.3, -1., 7.4])
628/// condition_mask=tf.not_equal(x,tf.constant(-1.))
629/// partitioned_data = tf.dynamic_partition(
630/// x, tf.cast(condition_mask, tf.int32) , 2)
631/// partitioned_data[1] = partitioned_data[1] + 1.0
632/// condition_indices = tf.dynamic_partition(
633/// tf.range(tf.shape(x)[0]), tf.cast(condition_mask, tf.int32) , 2)
634/// x = tf.dynamic_stitch(condition_indices, partitioned_data)
635/// # Here x=[1.1, -1., 6.2, 5.3, -1, 8.4], the -1. values remain
636/// # unchanged.
637/// ```
638///
639/// <div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;">
640/// <img style="width:100%" src="https://www.tensorflow.org/images/DynamicStitch.png" alt>
641/// </div>
642///
643/// Args:
644/// * scope: A Scope object
645///
646/// Returns:
647/// * `Output`: The merged tensor.
648class DynamicStitch {
649 public:
650 DynamicStitch(const ::tensorflow::Scope& scope, ::tensorflow::InputList
651 indices, ::tensorflow::InputList data);
652 operator ::tensorflow::Output() const { return merged; }
653 operator ::tensorflow::Input() const { return merged; }
654 ::tensorflow::Node* node() const { return merged.node(); }
655
656 Operation operation;
657 ::tensorflow::Output merged;
658};
659
660/// A queue that produces elements in first-in first-out order.
661///
662/// Args:
663/// * scope: A Scope object
664/// * component_types: The type of each component in a value.
665///
666/// Optional attributes (see `Attrs`):
667/// * shapes: The shape of each component in a value. The length of this attr must
668/// be either 0 or the same as the length of component_types. If the length of
669/// this attr is 0, the shapes of queue elements are not constrained, and
670/// only one element may be dequeued at a time.
671/// * capacity: The upper bound on the number of elements in this queue.
672/// Negative numbers mean no limit.
673/// * container: If non-empty, this queue is placed in the given container.
674/// Otherwise, a default container is used.
675/// * shared_name: If non-empty, this queue will be shared under the given name
676/// across multiple sessions.
677///
678/// Returns:
679/// * `Output`: The handle to the queue.
680class FIFOQueue {
681 public:
682 /// Optional attribute setters for FIFOQueue
683 struct Attrs {
684 /// The shape of each component in a value. The length of this attr must
685 /// be either 0 or the same as the length of component_types. If the length of
686 /// this attr is 0, the shapes of queue elements are not constrained, and
687 /// only one element may be dequeued at a time.
688 ///
689 /// Defaults to []
690 TF_MUST_USE_RESULT Attrs Shapes(const gtl::ArraySlice<PartialTensorShape>& x) {
691 Attrs ret = *this;
692 ret.shapes_ = x;
693 return ret;
694 }
695
696 /// The upper bound on the number of elements in this queue.
697 /// Negative numbers mean no limit.
698 ///
699 /// Defaults to -1
700 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
701 Attrs ret = *this;
702 ret.capacity_ = x;
703 return ret;
704 }
705
706 /// If non-empty, this queue is placed in the given container.
707 /// Otherwise, a default container is used.
708 ///
709 /// Defaults to ""
710 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
711 Attrs ret = *this;
712 ret.container_ = x;
713 return ret;
714 }
715
716 /// If non-empty, this queue will be shared under the given name
717 /// across multiple sessions.
718 ///
719 /// Defaults to ""
720 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
721 Attrs ret = *this;
722 ret.shared_name_ = x;
723 return ret;
724 }
725
726 gtl::ArraySlice<PartialTensorShape> shapes_ = {};
727 int64 capacity_ = -1;
728 StringPiece container_ = "";
729 StringPiece shared_name_ = "";
730 };
731 FIFOQueue(const ::tensorflow::Scope& scope, const DataTypeSlice&
732 component_types);
733 FIFOQueue(const ::tensorflow::Scope& scope, const DataTypeSlice&
734 component_types, const FIFOQueue::Attrs& attrs);
735 operator ::tensorflow::Output() const { return handle; }
736 operator ::tensorflow::Input() const { return handle; }
737 ::tensorflow::Node* node() const { return handle.node(); }
738
739 static Attrs Shapes(const gtl::ArraySlice<PartialTensorShape>& x) {
740 return Attrs().Shapes(x);
741 }
742 static Attrs Capacity(int64 x) {
743 return Attrs().Capacity(x);
744 }
745 static Attrs Container(StringPiece x) {
746 return Attrs().Container(x);
747 }
748 static Attrs SharedName(StringPiece x) {
749 return Attrs().SharedName(x);
750 }
751
752 Operation operation;
753 ::tensorflow::Output handle;
754};
755
756/// Store the input tensor in the state of the current session.
757///
758/// Args:
759/// * scope: A Scope object
760/// * value: The tensor to be stored.
761///
762/// Returns:
763/// * `Output`: The handle for the tensor stored in the session state, represented
764/// as a string.
765class GetSessionHandle {
766 public:
767 GetSessionHandle(const ::tensorflow::Scope& scope, ::tensorflow::Input value);
768 operator ::tensorflow::Output() const { return handle; }
769 operator ::tensorflow::Input() const { return handle; }
770 ::tensorflow::Node* node() const { return handle.node(); }
771
772 Operation operation;
773 ::tensorflow::Output handle;
774};
775
776/// Store the input tensor in the state of the current session.
777///
778/// Args:
779/// * scope: A Scope object
780/// * value: The tensor to be stored.
781///
782/// Returns:
783/// * `Output`: The handle for the tensor stored in the session state, represented
784/// as a ResourceHandle object.
785class GetSessionHandleV2 {
786 public:
787 GetSessionHandleV2(const ::tensorflow::Scope& scope, ::tensorflow::Input value);
788 operator ::tensorflow::Output() const { return handle; }
789 operator ::tensorflow::Input() const { return handle; }
790 ::tensorflow::Node* node() const { return handle.node(); }
791
792 Operation operation;
793 ::tensorflow::Output handle;
794};
795
796/// Get the value of the tensor specified by its handle.
797///
798/// Args:
799/// * scope: A Scope object
800/// * handle: The handle for a tensor stored in the session state.
801/// * dtype: The type of the output value.
802///
803/// Returns:
804/// * `Output`: The tensor for the given handle.
805class GetSessionTensor {
806 public:
807 GetSessionTensor(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
808 DataType dtype);
809 operator ::tensorflow::Output() const { return value; }
810 operator ::tensorflow::Input() const { return value; }
811 ::tensorflow::Node* node() const { return value.node(); }
812
813 Operation operation;
814 ::tensorflow::Output value;
815};
816
817/// Op removes all elements in the underlying container.
818///
819/// Args:
820/// * scope: A Scope object
821///
822/// Returns:
823/// * the created `Operation`
824class MapClear {
825 public:
826 /// Optional attribute setters for MapClear
827 struct Attrs {
828 /// Defaults to 0
829 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
830 Attrs ret = *this;
831 ret.capacity_ = x;
832 return ret;
833 }
834
835 /// Defaults to 0
836 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
837 Attrs ret = *this;
838 ret.memory_limit_ = x;
839 return ret;
840 }
841
842 /// Defaults to ""
843 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
844 Attrs ret = *this;
845 ret.container_ = x;
846 return ret;
847 }
848
849 /// Defaults to ""
850 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
851 Attrs ret = *this;
852 ret.shared_name_ = x;
853 return ret;
854 }
855
856 int64 capacity_ = 0;
857 int64 memory_limit_ = 0;
858 StringPiece container_ = "";
859 StringPiece shared_name_ = "";
860 };
861 MapClear(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes);
862 MapClear(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes, const
863 MapClear::Attrs& attrs);
864 operator ::tensorflow::Operation() const { return operation; }
865
866 static Attrs Capacity(int64 x) {
867 return Attrs().Capacity(x);
868 }
869 static Attrs MemoryLimit(int64 x) {
870 return Attrs().MemoryLimit(x);
871 }
872 static Attrs Container(StringPiece x) {
873 return Attrs().Container(x);
874 }
875 static Attrs SharedName(StringPiece x) {
876 return Attrs().SharedName(x);
877 }
878
879 Operation operation;
880};
881
882/// Op returns the number of incomplete elements in the underlying container.
883///
884/// Args:
885/// * scope: A Scope object
886///
887/// Returns:
888/// * `Output`: The size tensor.
889class MapIncompleteSize {
890 public:
891 /// Optional attribute setters for MapIncompleteSize
892 struct Attrs {
893 /// Defaults to 0
894 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
895 Attrs ret = *this;
896 ret.capacity_ = x;
897 return ret;
898 }
899
900 /// Defaults to 0
901 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
902 Attrs ret = *this;
903 ret.memory_limit_ = x;
904 return ret;
905 }
906
907 /// Defaults to ""
908 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
909 Attrs ret = *this;
910 ret.container_ = x;
911 return ret;
912 }
913
914 /// Defaults to ""
915 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
916 Attrs ret = *this;
917 ret.shared_name_ = x;
918 return ret;
919 }
920
921 int64 capacity_ = 0;
922 int64 memory_limit_ = 0;
923 StringPiece container_ = "";
924 StringPiece shared_name_ = "";
925 };
926 MapIncompleteSize(const ::tensorflow::Scope& scope, const DataTypeSlice&
927 dtypes);
928 MapIncompleteSize(const ::tensorflow::Scope& scope, const DataTypeSlice&
929 dtypes, const MapIncompleteSize::Attrs& attrs);
930 operator ::tensorflow::Output() const { return size; }
931 operator ::tensorflow::Input() const { return size; }
932 ::tensorflow::Node* node() const { return size.node(); }
933
934 static Attrs Capacity(int64 x) {
935 return Attrs().Capacity(x);
936 }
937 static Attrs MemoryLimit(int64 x) {
938 return Attrs().MemoryLimit(x);
939 }
940 static Attrs Container(StringPiece x) {
941 return Attrs().Container(x);
942 }
943 static Attrs SharedName(StringPiece x) {
944 return Attrs().SharedName(x);
945 }
946
947 Operation operation;
948 ::tensorflow::Output size;
949};
950
951/// Op peeks at the values at the specified key. If the
952///
953/// underlying container does not contain this key
954/// this op will block until it does.
955///
956/// Args:
957/// * scope: A Scope object
958///
959/// Returns:
960/// * `OutputList`: The values tensor.
961class MapPeek {
962 public:
963 /// Optional attribute setters for MapPeek
964 struct Attrs {
965 /// Defaults to 0
966 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
967 Attrs ret = *this;
968 ret.capacity_ = x;
969 return ret;
970 }
971
972 /// Defaults to 0
973 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
974 Attrs ret = *this;
975 ret.memory_limit_ = x;
976 return ret;
977 }
978
979 /// Defaults to ""
980 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
981 Attrs ret = *this;
982 ret.container_ = x;
983 return ret;
984 }
985
986 /// Defaults to ""
987 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
988 Attrs ret = *this;
989 ret.shared_name_ = x;
990 return ret;
991 }
992
993 int64 capacity_ = 0;
994 int64 memory_limit_ = 0;
995 StringPiece container_ = "";
996 StringPiece shared_name_ = "";
997 };
998 MapPeek(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
999 ::tensorflow::Input indices, const DataTypeSlice& dtypes);
1000 MapPeek(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
1001 ::tensorflow::Input indices, const DataTypeSlice& dtypes, const
1002 MapPeek::Attrs& attrs);
1003 ::tensorflow::Output operator[](size_t index) const { return values[index]; }
1004
1005
1006 static Attrs Capacity(int64 x) {
1007 return Attrs().Capacity(x);
1008 }
1009 static Attrs MemoryLimit(int64 x) {
1010 return Attrs().MemoryLimit(x);
1011 }
1012 static Attrs Container(StringPiece x) {
1013 return Attrs().Container(x);
1014 }
1015 static Attrs SharedName(StringPiece x) {
1016 return Attrs().SharedName(x);
1017 }
1018
1019 Operation operation;
1020 ::tensorflow::OutputList values;
1021};
1022
1023/// Op returns the number of elements in the underlying container.
1024///
1025/// Args:
1026/// * scope: A Scope object
1027///
1028/// Returns:
1029/// * `Output`: The size tensor.
1030class MapSize {
1031 public:
1032 /// Optional attribute setters for MapSize
1033 struct Attrs {
1034 /// Defaults to 0
1035 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1036 Attrs ret = *this;
1037 ret.capacity_ = x;
1038 return ret;
1039 }
1040
1041 /// Defaults to 0
1042 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
1043 Attrs ret = *this;
1044 ret.memory_limit_ = x;
1045 return ret;
1046 }
1047
1048 /// Defaults to ""
1049 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1050 Attrs ret = *this;
1051 ret.container_ = x;
1052 return ret;
1053 }
1054
1055 /// Defaults to ""
1056 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1057 Attrs ret = *this;
1058 ret.shared_name_ = x;
1059 return ret;
1060 }
1061
1062 int64 capacity_ = 0;
1063 int64 memory_limit_ = 0;
1064 StringPiece container_ = "";
1065 StringPiece shared_name_ = "";
1066 };
1067 MapSize(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes);
1068 MapSize(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes, const
1069 MapSize::Attrs& attrs);
1070 operator ::tensorflow::Output() const { return size; }
1071 operator ::tensorflow::Input() const { return size; }
1072 ::tensorflow::Node* node() const { return size.node(); }
1073
1074 static Attrs Capacity(int64 x) {
1075 return Attrs().Capacity(x);
1076 }
1077 static Attrs MemoryLimit(int64 x) {
1078 return Attrs().MemoryLimit(x);
1079 }
1080 static Attrs Container(StringPiece x) {
1081 return Attrs().Container(x);
1082 }
1083 static Attrs SharedName(StringPiece x) {
1084 return Attrs().SharedName(x);
1085 }
1086
1087 Operation operation;
1088 ::tensorflow::Output size;
1089};
1090
1091/// Stage (key, values) in the underlying container which behaves like a hashtable.
1092///
1093/// Args:
1094/// * scope: A Scope object
1095/// * key: int64
1096/// * values: a list of tensors
1097/// dtypes A list of data types that inserted values should adhere to.
1098///
1099/// Optional attributes (see `Attrs`):
1100/// * capacity: Maximum number of elements in the Staging Area. If > 0, inserts
1101/// on the container will block when the capacity is reached.
1102/// * container: If non-empty, this queue is placed in the given container. Otherwise,
1103/// a default container is used.
1104/// * shared_name: It is necessary to match this name to the matching Unstage Op.
1105///
1106/// Returns:
1107/// * the created `Operation`
1108class MapStage {
1109 public:
1110 /// Optional attribute setters for MapStage
1111 struct Attrs {
1112 /// Maximum number of elements in the Staging Area. If > 0, inserts
1113 /// on the container will block when the capacity is reached.
1114 ///
1115 /// Defaults to 0
1116 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1117 Attrs ret = *this;
1118 ret.capacity_ = x;
1119 return ret;
1120 }
1121
1122 /// Defaults to 0
1123 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
1124 Attrs ret = *this;
1125 ret.memory_limit_ = x;
1126 return ret;
1127 }
1128
1129 /// If non-empty, this queue is placed in the given container. Otherwise,
1130 /// a default container is used.
1131 ///
1132 /// Defaults to ""
1133 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1134 Attrs ret = *this;
1135 ret.container_ = x;
1136 return ret;
1137 }
1138
1139 /// It is necessary to match this name to the matching Unstage Op.
1140 ///
1141 /// Defaults to ""
1142 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1143 Attrs ret = *this;
1144 ret.shared_name_ = x;
1145 return ret;
1146 }
1147
1148 int64 capacity_ = 0;
1149 int64 memory_limit_ = 0;
1150 StringPiece container_ = "";
1151 StringPiece shared_name_ = "";
1152 };
1153 MapStage(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
1154 ::tensorflow::Input indices, ::tensorflow::InputList values, const
1155 DataTypeSlice& dtypes);
1156 MapStage(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
1157 ::tensorflow::Input indices, ::tensorflow::InputList values, const
1158 DataTypeSlice& dtypes, const MapStage::Attrs& attrs);
1159 operator ::tensorflow::Operation() const { return operation; }
1160
1161 static Attrs Capacity(int64 x) {
1162 return Attrs().Capacity(x);
1163 }
1164 static Attrs MemoryLimit(int64 x) {
1165 return Attrs().MemoryLimit(x);
1166 }
1167 static Attrs Container(StringPiece x) {
1168 return Attrs().Container(x);
1169 }
1170 static Attrs SharedName(StringPiece x) {
1171 return Attrs().SharedName(x);
1172 }
1173
1174 Operation operation;
1175};
1176
1177/// Op removes and returns the values associated with the key
1178///
1179/// from the underlying container. If the underlying container
1180/// does not contain this key, the op will block until it does.
1181///
1182/// Args:
1183/// * scope: A Scope object
1184///
1185/// Returns:
1186/// * `OutputList`: The values tensor.
1187class MapUnstage {
1188 public:
1189 /// Optional attribute setters for MapUnstage
1190 struct Attrs {
1191 /// Defaults to 0
1192 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1193 Attrs ret = *this;
1194 ret.capacity_ = x;
1195 return ret;
1196 }
1197
1198 /// Defaults to 0
1199 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
1200 Attrs ret = *this;
1201 ret.memory_limit_ = x;
1202 return ret;
1203 }
1204
1205 /// Defaults to ""
1206 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1207 Attrs ret = *this;
1208 ret.container_ = x;
1209 return ret;
1210 }
1211
1212 /// Defaults to ""
1213 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1214 Attrs ret = *this;
1215 ret.shared_name_ = x;
1216 return ret;
1217 }
1218
1219 int64 capacity_ = 0;
1220 int64 memory_limit_ = 0;
1221 StringPiece container_ = "";
1222 StringPiece shared_name_ = "";
1223 };
1224 MapUnstage(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
1225 ::tensorflow::Input indices, const DataTypeSlice& dtypes);
1226 MapUnstage(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
1227 ::tensorflow::Input indices, const DataTypeSlice& dtypes, const
1228 MapUnstage::Attrs& attrs);
1229 ::tensorflow::Output operator[](size_t index) const { return values[index]; }
1230
1231
1232 static Attrs Capacity(int64 x) {
1233 return Attrs().Capacity(x);
1234 }
1235 static Attrs MemoryLimit(int64 x) {
1236 return Attrs().MemoryLimit(x);
1237 }
1238 static Attrs Container(StringPiece x) {
1239 return Attrs().Container(x);
1240 }
1241 static Attrs SharedName(StringPiece x) {
1242 return Attrs().SharedName(x);
1243 }
1244
1245 Operation operation;
1246 ::tensorflow::OutputList values;
1247};
1248
1249/// Op removes and returns a random (key, value)
1250///
1251/// from the underlying container. If the underlying container
1252/// does not contain elements, the op will block until it does.
1253///
1254/// Args:
1255/// * scope: A Scope object
1256///
1257/// Returns:
1258/// * `Output` key
1259/// * `OutputList` values
1260class MapUnstageNoKey {
1261 public:
1262 /// Optional attribute setters for MapUnstageNoKey
1263 struct Attrs {
1264 /// Defaults to 0
1265 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1266 Attrs ret = *this;
1267 ret.capacity_ = x;
1268 return ret;
1269 }
1270
1271 /// Defaults to 0
1272 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
1273 Attrs ret = *this;
1274 ret.memory_limit_ = x;
1275 return ret;
1276 }
1277
1278 /// Defaults to ""
1279 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1280 Attrs ret = *this;
1281 ret.container_ = x;
1282 return ret;
1283 }
1284
1285 /// Defaults to ""
1286 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1287 Attrs ret = *this;
1288 ret.shared_name_ = x;
1289 return ret;
1290 }
1291
1292 int64 capacity_ = 0;
1293 int64 memory_limit_ = 0;
1294 StringPiece container_ = "";
1295 StringPiece shared_name_ = "";
1296 };
1297 MapUnstageNoKey(const ::tensorflow::Scope& scope, ::tensorflow::Input indices,
1298 const DataTypeSlice& dtypes);
1299 MapUnstageNoKey(const ::tensorflow::Scope& scope, ::tensorflow::Input indices,
1300 const DataTypeSlice& dtypes, const MapUnstageNoKey::Attrs&
1301 attrs);
1302
1303 static Attrs Capacity(int64 x) {
1304 return Attrs().Capacity(x);
1305 }
1306 static Attrs MemoryLimit(int64 x) {
1307 return Attrs().MemoryLimit(x);
1308 }
1309 static Attrs Container(StringPiece x) {
1310 return Attrs().Container(x);
1311 }
1312 static Attrs SharedName(StringPiece x) {
1313 return Attrs().SharedName(x);
1314 }
1315
1316 Operation operation;
1317 ::tensorflow::Output key;
1318 ::tensorflow::OutputList values;
1319};
1320
1321/// Op removes all elements in the underlying container.
1322///
1323/// Args:
1324/// * scope: A Scope object
1325///
1326/// Returns:
1327/// * the created `Operation`
1328class OrderedMapClear {
1329 public:
1330 /// Optional attribute setters for OrderedMapClear
1331 struct Attrs {
1332 /// Defaults to 0
1333 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1334 Attrs ret = *this;
1335 ret.capacity_ = x;
1336 return ret;
1337 }
1338
1339 /// Defaults to 0
1340 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
1341 Attrs ret = *this;
1342 ret.memory_limit_ = x;
1343 return ret;
1344 }
1345
1346 /// Defaults to ""
1347 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1348 Attrs ret = *this;
1349 ret.container_ = x;
1350 return ret;
1351 }
1352
1353 /// Defaults to ""
1354 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1355 Attrs ret = *this;
1356 ret.shared_name_ = x;
1357 return ret;
1358 }
1359
1360 int64 capacity_ = 0;
1361 int64 memory_limit_ = 0;
1362 StringPiece container_ = "";
1363 StringPiece shared_name_ = "";
1364 };
1365 OrderedMapClear(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes);
1366 OrderedMapClear(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes,
1367 const OrderedMapClear::Attrs& attrs);
1368 operator ::tensorflow::Operation() const { return operation; }
1369
1370 static Attrs Capacity(int64 x) {
1371 return Attrs().Capacity(x);
1372 }
1373 static Attrs MemoryLimit(int64 x) {
1374 return Attrs().MemoryLimit(x);
1375 }
1376 static Attrs Container(StringPiece x) {
1377 return Attrs().Container(x);
1378 }
1379 static Attrs SharedName(StringPiece x) {
1380 return Attrs().SharedName(x);
1381 }
1382
1383 Operation operation;
1384};
1385
1386/// Op returns the number of incomplete elements in the underlying container.
1387///
1388/// Args:
1389/// * scope: A Scope object
1390///
1391/// Returns:
1392/// * `Output`: The size tensor.
1393class OrderedMapIncompleteSize {
1394 public:
1395 /// Optional attribute setters for OrderedMapIncompleteSize
1396 struct Attrs {
1397 /// Defaults to 0
1398 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1399 Attrs ret = *this;
1400 ret.capacity_ = x;
1401 return ret;
1402 }
1403
1404 /// Defaults to 0
1405 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
1406 Attrs ret = *this;
1407 ret.memory_limit_ = x;
1408 return ret;
1409 }
1410
1411 /// Defaults to ""
1412 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1413 Attrs ret = *this;
1414 ret.container_ = x;
1415 return ret;
1416 }
1417
1418 /// Defaults to ""
1419 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1420 Attrs ret = *this;
1421 ret.shared_name_ = x;
1422 return ret;
1423 }
1424
1425 int64 capacity_ = 0;
1426 int64 memory_limit_ = 0;
1427 StringPiece container_ = "";
1428 StringPiece shared_name_ = "";
1429 };
1430 OrderedMapIncompleteSize(const ::tensorflow::Scope& scope, const DataTypeSlice&
1431 dtypes);
1432 OrderedMapIncompleteSize(const ::tensorflow::Scope& scope, const DataTypeSlice&
1433 dtypes, const OrderedMapIncompleteSize::Attrs& attrs);
1434 operator ::tensorflow::Output() const { return size; }
1435 operator ::tensorflow::Input() const { return size; }
1436 ::tensorflow::Node* node() const { return size.node(); }
1437
1438 static Attrs Capacity(int64 x) {
1439 return Attrs().Capacity(x);
1440 }
1441 static Attrs MemoryLimit(int64 x) {
1442 return Attrs().MemoryLimit(x);
1443 }
1444 static Attrs Container(StringPiece x) {
1445 return Attrs().Container(x);
1446 }
1447 static Attrs SharedName(StringPiece x) {
1448 return Attrs().SharedName(x);
1449 }
1450
1451 Operation operation;
1452 ::tensorflow::Output size;
1453};
1454
1455/// Op peeks at the values at the specified key. If the
1456///
1457/// underlying container does not contain this key
1458/// this op will block until it does. This Op is optimized for
1459/// performance.
1460///
1461/// Args:
1462/// * scope: A Scope object
1463///
1464/// Returns:
1465/// * `OutputList`: The values tensor.
1466class OrderedMapPeek {
1467 public:
1468 /// Optional attribute setters for OrderedMapPeek
1469 struct Attrs {
1470 /// Defaults to 0
1471 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1472 Attrs ret = *this;
1473 ret.capacity_ = x;
1474 return ret;
1475 }
1476
1477 /// Defaults to 0
1478 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
1479 Attrs ret = *this;
1480 ret.memory_limit_ = x;
1481 return ret;
1482 }
1483
1484 /// Defaults to ""
1485 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1486 Attrs ret = *this;
1487 ret.container_ = x;
1488 return ret;
1489 }
1490
1491 /// Defaults to ""
1492 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1493 Attrs ret = *this;
1494 ret.shared_name_ = x;
1495 return ret;
1496 }
1497
1498 int64 capacity_ = 0;
1499 int64 memory_limit_ = 0;
1500 StringPiece container_ = "";
1501 StringPiece shared_name_ = "";
1502 };
1503 OrderedMapPeek(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
1504 ::tensorflow::Input indices, const DataTypeSlice& dtypes);
1505 OrderedMapPeek(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
1506 ::tensorflow::Input indices, const DataTypeSlice& dtypes, const
1507 OrderedMapPeek::Attrs& attrs);
1508 ::tensorflow::Output operator[](size_t index) const { return values[index]; }
1509
1510
1511 static Attrs Capacity(int64 x) {
1512 return Attrs().Capacity(x);
1513 }
1514 static Attrs MemoryLimit(int64 x) {
1515 return Attrs().MemoryLimit(x);
1516 }
1517 static Attrs Container(StringPiece x) {
1518 return Attrs().Container(x);
1519 }
1520 static Attrs SharedName(StringPiece x) {
1521 return Attrs().SharedName(x);
1522 }
1523
1524 Operation operation;
1525 ::tensorflow::OutputList values;
1526};
1527
1528/// Op returns the number of elements in the underlying container.
1529///
1530/// Args:
1531/// * scope: A Scope object
1532///
1533/// Returns:
1534/// * `Output`: The size tensor.
1535class OrderedMapSize {
1536 public:
1537 /// Optional attribute setters for OrderedMapSize
1538 struct Attrs {
1539 /// Defaults to 0
1540 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1541 Attrs ret = *this;
1542 ret.capacity_ = x;
1543 return ret;
1544 }
1545
1546 /// Defaults to 0
1547 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
1548 Attrs ret = *this;
1549 ret.memory_limit_ = x;
1550 return ret;
1551 }
1552
1553 /// Defaults to ""
1554 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1555 Attrs ret = *this;
1556 ret.container_ = x;
1557 return ret;
1558 }
1559
1560 /// Defaults to ""
1561 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1562 Attrs ret = *this;
1563 ret.shared_name_ = x;
1564 return ret;
1565 }
1566
1567 int64 capacity_ = 0;
1568 int64 memory_limit_ = 0;
1569 StringPiece container_ = "";
1570 StringPiece shared_name_ = "";
1571 };
1572 OrderedMapSize(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes);
1573 OrderedMapSize(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes,
1574 const OrderedMapSize::Attrs& attrs);
1575 operator ::tensorflow::Output() const { return size; }
1576 operator ::tensorflow::Input() const { return size; }
1577 ::tensorflow::Node* node() const { return size.node(); }
1578
1579 static Attrs Capacity(int64 x) {
1580 return Attrs().Capacity(x);
1581 }
1582 static Attrs MemoryLimit(int64 x) {
1583 return Attrs().MemoryLimit(x);
1584 }
1585 static Attrs Container(StringPiece x) {
1586 return Attrs().Container(x);
1587 }
1588 static Attrs SharedName(StringPiece x) {
1589 return Attrs().SharedName(x);
1590 }
1591
1592 Operation operation;
1593 ::tensorflow::Output size;
1594};
1595
1596/// Stage (key, values) in the underlying container which behaves like a ordered
1597///
1598/// associative container. Elements are ordered by key.
1599///
1600/// Args:
1601/// * scope: A Scope object
1602/// * key: int64
1603/// * values: a list of tensors
1604/// dtypes A list of data types that inserted values should adhere to.
1605///
1606/// Optional attributes (see `Attrs`):
1607/// * capacity: Maximum number of elements in the Staging Area. If > 0, inserts
1608/// on the container will block when the capacity is reached.
1609/// * container: If non-empty, this queue is placed in the given container. Otherwise,
1610/// a default container is used.
1611/// * shared_name: It is necessary to match this name to the matching Unstage Op.
1612///
1613/// Returns:
1614/// * the created `Operation`
1615class OrderedMapStage {
1616 public:
1617 /// Optional attribute setters for OrderedMapStage
1618 struct Attrs {
1619 /// Maximum number of elements in the Staging Area. If > 0, inserts
1620 /// on the container will block when the capacity is reached.
1621 ///
1622 /// Defaults to 0
1623 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1624 Attrs ret = *this;
1625 ret.capacity_ = x;
1626 return ret;
1627 }
1628
1629 /// Defaults to 0
1630 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
1631 Attrs ret = *this;
1632 ret.memory_limit_ = x;
1633 return ret;
1634 }
1635
1636 /// If non-empty, this queue is placed in the given container. Otherwise,
1637 /// a default container is used.
1638 ///
1639 /// Defaults to ""
1640 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1641 Attrs ret = *this;
1642 ret.container_ = x;
1643 return ret;
1644 }
1645
1646 /// It is necessary to match this name to the matching Unstage Op.
1647 ///
1648 /// Defaults to ""
1649 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1650 Attrs ret = *this;
1651 ret.shared_name_ = x;
1652 return ret;
1653 }
1654
1655 int64 capacity_ = 0;
1656 int64 memory_limit_ = 0;
1657 StringPiece container_ = "";
1658 StringPiece shared_name_ = "";
1659 };
1660 OrderedMapStage(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
1661 ::tensorflow::Input indices, ::tensorflow::InputList values,
1662 const DataTypeSlice& dtypes);
1663 OrderedMapStage(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
1664 ::tensorflow::Input indices, ::tensorflow::InputList values,
1665 const DataTypeSlice& dtypes, const OrderedMapStage::Attrs&
1666 attrs);
1667 operator ::tensorflow::Operation() const { return operation; }
1668
1669 static Attrs Capacity(int64 x) {
1670 return Attrs().Capacity(x);
1671 }
1672 static Attrs MemoryLimit(int64 x) {
1673 return Attrs().MemoryLimit(x);
1674 }
1675 static Attrs Container(StringPiece x) {
1676 return Attrs().Container(x);
1677 }
1678 static Attrs SharedName(StringPiece x) {
1679 return Attrs().SharedName(x);
1680 }
1681
1682 Operation operation;
1683};
1684
1685/// Op removes and returns the values associated with the key
1686///
1687/// from the underlying container. If the underlying container
1688/// does not contain this key, the op will block until it does.
1689///
1690/// Args:
1691/// * scope: A Scope object
1692///
1693/// Returns:
1694/// * `OutputList`: The values tensor.
1695class OrderedMapUnstage {
1696 public:
1697 /// Optional attribute setters for OrderedMapUnstage
1698 struct Attrs {
1699 /// Defaults to 0
1700 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1701 Attrs ret = *this;
1702 ret.capacity_ = x;
1703 return ret;
1704 }
1705
1706 /// Defaults to 0
1707 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
1708 Attrs ret = *this;
1709 ret.memory_limit_ = x;
1710 return ret;
1711 }
1712
1713 /// Defaults to ""
1714 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1715 Attrs ret = *this;
1716 ret.container_ = x;
1717 return ret;
1718 }
1719
1720 /// Defaults to ""
1721 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1722 Attrs ret = *this;
1723 ret.shared_name_ = x;
1724 return ret;
1725 }
1726
1727 int64 capacity_ = 0;
1728 int64 memory_limit_ = 0;
1729 StringPiece container_ = "";
1730 StringPiece shared_name_ = "";
1731 };
1732 OrderedMapUnstage(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
1733 ::tensorflow::Input indices, const DataTypeSlice& dtypes);
1734 OrderedMapUnstage(const ::tensorflow::Scope& scope, ::tensorflow::Input key,
1735 ::tensorflow::Input indices, const DataTypeSlice& dtypes,
1736 const OrderedMapUnstage::Attrs& attrs);
1737 ::tensorflow::Output operator[](size_t index) const { return values[index]; }
1738
1739
1740 static Attrs Capacity(int64 x) {
1741 return Attrs().Capacity(x);
1742 }
1743 static Attrs MemoryLimit(int64 x) {
1744 return Attrs().MemoryLimit(x);
1745 }
1746 static Attrs Container(StringPiece x) {
1747 return Attrs().Container(x);
1748 }
1749 static Attrs SharedName(StringPiece x) {
1750 return Attrs().SharedName(x);
1751 }
1752
1753 Operation operation;
1754 ::tensorflow::OutputList values;
1755};
1756
1757/// Op removes and returns the (key, value) element with the smallest
1758///
1759/// key from the underlying container. If the underlying container
1760/// does not contain elements, the op will block until it does.
1761///
1762/// Args:
1763/// * scope: A Scope object
1764///
1765/// Returns:
1766/// * `Output` key
1767/// * `OutputList` values
1768class OrderedMapUnstageNoKey {
1769 public:
1770 /// Optional attribute setters for OrderedMapUnstageNoKey
1771 struct Attrs {
1772 /// Defaults to 0
1773 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1774 Attrs ret = *this;
1775 ret.capacity_ = x;
1776 return ret;
1777 }
1778
1779 /// Defaults to 0
1780 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
1781 Attrs ret = *this;
1782 ret.memory_limit_ = x;
1783 return ret;
1784 }
1785
1786 /// Defaults to ""
1787 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1788 Attrs ret = *this;
1789 ret.container_ = x;
1790 return ret;
1791 }
1792
1793 /// Defaults to ""
1794 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1795 Attrs ret = *this;
1796 ret.shared_name_ = x;
1797 return ret;
1798 }
1799
1800 int64 capacity_ = 0;
1801 int64 memory_limit_ = 0;
1802 StringPiece container_ = "";
1803 StringPiece shared_name_ = "";
1804 };
1805 OrderedMapUnstageNoKey(const ::tensorflow::Scope& scope, ::tensorflow::Input
1806 indices, const DataTypeSlice& dtypes);
1807 OrderedMapUnstageNoKey(const ::tensorflow::Scope& scope, ::tensorflow::Input
1808 indices, const DataTypeSlice& dtypes, const
1809 OrderedMapUnstageNoKey::Attrs& attrs);
1810
1811 static Attrs Capacity(int64 x) {
1812 return Attrs().Capacity(x);
1813 }
1814 static Attrs MemoryLimit(int64 x) {
1815 return Attrs().MemoryLimit(x);
1816 }
1817 static Attrs Container(StringPiece x) {
1818 return Attrs().Container(x);
1819 }
1820 static Attrs SharedName(StringPiece x) {
1821 return Attrs().SharedName(x);
1822 }
1823
1824 Operation operation;
1825 ::tensorflow::Output key;
1826 ::tensorflow::OutputList values;
1827};
1828
1829/// A queue that produces elements in first-in first-out order.
1830///
1831/// Variable-size shapes are allowed by setting the corresponding shape dimensions
1832/// to 0 in the shape attr. In this case DequeueMany will pad up to the maximum
1833/// size of any given element in the minibatch. See below for details.
1834///
1835/// Args:
1836/// * scope: A Scope object
1837/// * component_types: The type of each component in a value.
1838///
1839/// Optional attributes (see `Attrs`):
1840/// * shapes: The shape of each component in a value. The length of this attr must
1841/// be either 0 or the same as the length of component_types.
1842/// Shapes of fixed rank but variable size are allowed by setting
1843/// any shape dimension to -1. In this case, the inputs' shape may vary along
1844/// the given dimension, and DequeueMany will pad the given dimension with
1845/// zeros up to the maximum shape of all elements in the given batch.
1846/// If the length of this attr is 0, different queue elements may have
1847/// different ranks and shapes, but only one element may be dequeued at a time.
1848/// * capacity: The upper bound on the number of elements in this queue.
1849/// Negative numbers mean no limit.
1850/// * container: If non-empty, this queue is placed in the given container.
1851/// Otherwise, a default container is used.
1852/// * shared_name: If non-empty, this queue will be shared under the given name
1853/// across multiple sessions.
1854///
1855/// Returns:
1856/// * `Output`: The handle to the queue.
1857class PaddingFIFOQueue {
1858 public:
1859 /// Optional attribute setters for PaddingFIFOQueue
1860 struct Attrs {
1861 /// The shape of each component in a value. The length of this attr must
1862 /// be either 0 or the same as the length of component_types.
1863 /// Shapes of fixed rank but variable size are allowed by setting
1864 /// any shape dimension to -1. In this case, the inputs' shape may vary along
1865 /// the given dimension, and DequeueMany will pad the given dimension with
1866 /// zeros up to the maximum shape of all elements in the given batch.
1867 /// If the length of this attr is 0, different queue elements may have
1868 /// different ranks and shapes, but only one element may be dequeued at a time.
1869 ///
1870 /// Defaults to []
1871 TF_MUST_USE_RESULT Attrs Shapes(const gtl::ArraySlice<PartialTensorShape>& x) {
1872 Attrs ret = *this;
1873 ret.shapes_ = x;
1874 return ret;
1875 }
1876
1877 /// The upper bound on the number of elements in this queue.
1878 /// Negative numbers mean no limit.
1879 ///
1880 /// Defaults to -1
1881 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
1882 Attrs ret = *this;
1883 ret.capacity_ = x;
1884 return ret;
1885 }
1886
1887 /// If non-empty, this queue is placed in the given container.
1888 /// Otherwise, a default container is used.
1889 ///
1890 /// Defaults to ""
1891 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1892 Attrs ret = *this;
1893 ret.container_ = x;
1894 return ret;
1895 }
1896
1897 /// If non-empty, this queue will be shared under the given name
1898 /// across multiple sessions.
1899 ///
1900 /// Defaults to ""
1901 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1902 Attrs ret = *this;
1903 ret.shared_name_ = x;
1904 return ret;
1905 }
1906
1907 gtl::ArraySlice<PartialTensorShape> shapes_ = {};
1908 int64 capacity_ = -1;
1909 StringPiece container_ = "";
1910 StringPiece shared_name_ = "";
1911 };
1912 PaddingFIFOQueue(const ::tensorflow::Scope& scope, const DataTypeSlice&
1913 component_types);
1914 PaddingFIFOQueue(const ::tensorflow::Scope& scope, const DataTypeSlice&
1915 component_types, const PaddingFIFOQueue::Attrs& attrs);
1916 operator ::tensorflow::Output() const { return handle; }
1917 operator ::tensorflow::Input() const { return handle; }
1918 ::tensorflow::Node* node() const { return handle.node(); }
1919
1920 static Attrs Shapes(const gtl::ArraySlice<PartialTensorShape>& x) {
1921 return Attrs().Shapes(x);
1922 }
1923 static Attrs Capacity(int64 x) {
1924 return Attrs().Capacity(x);
1925 }
1926 static Attrs Container(StringPiece x) {
1927 return Attrs().Container(x);
1928 }
1929 static Attrs SharedName(StringPiece x) {
1930 return Attrs().SharedName(x);
1931 }
1932
1933 Operation operation;
1934 ::tensorflow::Output handle;
1935};
1936
1937/// Interleave the values from the `data` tensors into a single tensor.
1938///
1939/// Builds a merged tensor such that
1940///
1941/// ```python
1942/// merged[indices[m][i, ..., j], ...] = data[m][i, ..., j, ...]
1943/// ```
1944///
1945/// For example, if each `indices[m]` is scalar or vector, we have
1946///
1947/// ```python
1948/// # Scalar indices:
1949/// merged[indices[m], ...] = data[m][...]
1950///
1951/// # Vector indices:
1952/// merged[indices[m][i], ...] = data[m][i, ...]
1953/// ```
1954///
1955/// Each `data[i].shape` must start with the corresponding `indices[i].shape`,
1956/// and the rest of `data[i].shape` must be constant w.r.t. `i`. That is, we
1957/// must have `data[i].shape = indices[i].shape + constant`. In terms of this
1958/// `constant`, the output shape is
1959///
1960/// merged.shape = [max(indices)] + constant
1961///
1962/// Values may be merged in parallel, so if an index appears in both `indices[m][i]`
1963/// and `indices[n][j]`, the result may be invalid. This differs from the normal
1964/// DynamicStitch operator that defines the behavior in that case.
1965///
1966/// For example:
1967///
1968/// ```python
1969/// indices[0] = 6
1970/// indices[1] = [4, 1]
1971/// indices[2] = [[5, 2], [0, 3]]
1972/// data[0] = [61, 62]
1973/// data[1] = [[41, 42], [11, 12]]
1974/// data[2] = [[[51, 52], [21, 22]], [[1, 2], [31, 32]]]
1975/// merged = [[1, 2], [11, 12], [21, 22], [31, 32], [41, 42],
1976/// [51, 52], [61, 62]]
1977/// ```
1978///
1979/// This method can be used to merge partitions created by `dynamic_partition`
1980/// as illustrated on the following example:
1981///
1982/// ```python
1983/// # Apply function (increments x_i) on elements for which a certain condition
1984/// # apply (x_i != -1 in this example).
1985/// x=tf.constant([0.1, -1., 5.2, 4.3, -1., 7.4])
1986/// condition_mask=tf.not_equal(x,tf.constant(-1.))
1987/// partitioned_data = tf.dynamic_partition(
1988/// x, tf.cast(condition_mask, tf.int32) , 2)
1989/// partitioned_data[1] = partitioned_data[1] + 1.0
1990/// condition_indices = tf.dynamic_partition(
1991/// tf.range(tf.shape(x)[0]), tf.cast(condition_mask, tf.int32) , 2)
1992/// x = tf.dynamic_stitch(condition_indices, partitioned_data)
1993/// # Here x=[1.1, -1., 6.2, 5.3, -1, 8.4], the -1. values remain
1994/// # unchanged.
1995/// ```
1996///
1997/// <div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;">
1998/// <img style="width:100%" src="https://www.tensorflow.org/images/DynamicStitch.png" alt>
1999/// </div>
2000///
2001/// Args:
2002/// * scope: A Scope object
2003///
2004/// Returns:
2005/// * `Output`: The merged tensor.
2006class ParallelDynamicStitch {
2007 public:
2008 ParallelDynamicStitch(const ::tensorflow::Scope& scope, ::tensorflow::InputList
2009 indices, ::tensorflow::InputList data);
2010 operator ::tensorflow::Output() const { return merged; }
2011 operator ::tensorflow::Input() const { return merged; }
2012 ::tensorflow::Node* node() const { return merged.node(); }
2013
2014 Operation operation;
2015 ::tensorflow::Output merged;
2016};
2017
2018/// A queue that produces elements sorted by the first component value.
2019///
2020/// Note that the PriorityQueue requires the first component of any element
2021/// to be a scalar int64, in addition to the other elements declared by
2022/// component_types. Therefore calls to Enqueue and EnqueueMany (resp. Dequeue
2023/// and DequeueMany) on a PriorityQueue will all require (resp. output) one extra
2024/// entry in their input (resp. output) lists.
2025///
2026/// Args:
2027/// * scope: A Scope object
2028/// * shapes: The shape of each component in a value. The length of this attr must
2029/// be either 0 or the same as the length of component_types. If the length of
2030/// this attr is 0, the shapes of queue elements are not constrained, and
2031/// only one element may be dequeued at a time.
2032///
2033/// Optional attributes (see `Attrs`):
2034/// * component_types: The type of each component in a value.
2035/// * capacity: The upper bound on the number of elements in this queue.
2036/// Negative numbers mean no limit.
2037/// * container: If non-empty, this queue is placed in the given container.
2038/// Otherwise, a default container is used.
2039/// * shared_name: If non-empty, this queue will be shared under the given name
2040/// across multiple sessions.
2041///
2042/// Returns:
2043/// * `Output`: The handle to the queue.
2044class PriorityQueue {
2045 public:
2046 /// Optional attribute setters for PriorityQueue
2047 struct Attrs {
2048 /// The type of each component in a value.
2049 ///
2050 /// Defaults to []
2051 TF_MUST_USE_RESULT Attrs ComponentTypes(const DataTypeSlice& x) {
2052 Attrs ret = *this;
2053 ret.component_types_ = x;
2054 return ret;
2055 }
2056
2057 /// The upper bound on the number of elements in this queue.
2058 /// Negative numbers mean no limit.
2059 ///
2060 /// Defaults to -1
2061 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
2062 Attrs ret = *this;
2063 ret.capacity_ = x;
2064 return ret;
2065 }
2066
2067 /// If non-empty, this queue is placed in the given container.
2068 /// Otherwise, a default container is used.
2069 ///
2070 /// Defaults to ""
2071 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
2072 Attrs ret = *this;
2073 ret.container_ = x;
2074 return ret;
2075 }
2076
2077 /// If non-empty, this queue will be shared under the given name
2078 /// across multiple sessions.
2079 ///
2080 /// Defaults to ""
2081 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
2082 Attrs ret = *this;
2083 ret.shared_name_ = x;
2084 return ret;
2085 }
2086
2087 DataTypeSlice component_types_ = {};
2088 int64 capacity_ = -1;
2089 StringPiece container_ = "";
2090 StringPiece shared_name_ = "";
2091 };
2092 PriorityQueue(const ::tensorflow::Scope& scope, const
2093 gtl::ArraySlice<PartialTensorShape>& shapes);
2094 PriorityQueue(const ::tensorflow::Scope& scope, const
2095 gtl::ArraySlice<PartialTensorShape>& shapes, const
2096 PriorityQueue::Attrs& attrs);
2097 operator ::tensorflow::Output() const { return handle; }
2098 operator ::tensorflow::Input() const { return handle; }
2099 ::tensorflow::Node* node() const { return handle.node(); }
2100
2101 static Attrs ComponentTypes(const DataTypeSlice& x) {
2102 return Attrs().ComponentTypes(x);
2103 }
2104 static Attrs Capacity(int64 x) {
2105 return Attrs().Capacity(x);
2106 }
2107 static Attrs Container(StringPiece x) {
2108 return Attrs().Container(x);
2109 }
2110 static Attrs SharedName(StringPiece x) {
2111 return Attrs().SharedName(x);
2112 }
2113
2114 Operation operation;
2115 ::tensorflow::Output handle;
2116};
2117
2118/// Closes the given queue.
2119///
2120/// This operation signals that no more elements will be enqueued in the
2121/// given queue. Subsequent Enqueue(Many) operations will fail.
2122/// Subsequent Dequeue(Many) operations will continue to succeed if
2123/// sufficient elements remain in the queue. Subsequent Dequeue(Many)
2124/// operations that would block will fail immediately.
2125///
2126/// Args:
2127/// * scope: A Scope object
2128/// * handle: The handle to a queue.
2129///
2130/// Optional attributes (see `Attrs`):
2131/// * cancel_pending_enqueues: If true, all pending enqueue requests that are
2132/// blocked on the given queue will be canceled.
2133///
2134/// Returns:
2135/// * the created `Operation`
2136class QueueClose {
2137 public:
2138 /// Optional attribute setters for QueueClose
2139 struct Attrs {
2140 /// If true, all pending enqueue requests that are
2141 /// blocked on the given queue will be canceled.
2142 ///
2143 /// Defaults to false
2144 TF_MUST_USE_RESULT Attrs CancelPendingEnqueues(bool x) {
2145 Attrs ret = *this;
2146 ret.cancel_pending_enqueues_ = x;
2147 return ret;
2148 }
2149
2150 bool cancel_pending_enqueues_ = false;
2151 };
2152 QueueClose(const ::tensorflow::Scope& scope, ::tensorflow::Input handle);
2153 QueueClose(const ::tensorflow::Scope& scope, ::tensorflow::Input handle, const
2154 QueueClose::Attrs& attrs);
2155 operator ::tensorflow::Operation() const { return operation; }
2156
2157 static Attrs CancelPendingEnqueues(bool x) {
2158 return Attrs().CancelPendingEnqueues(x);
2159 }
2160
2161 Operation operation;
2162};
2163
2164/// Dequeues `n` tuples of one or more tensors from the given queue.
2165///
2166/// If the queue is closed and there are fewer than `n` elements, then an
2167/// OutOfRange error is returned.
2168///
2169/// This operation concatenates queue-element component tensors along the
2170/// 0th dimension to make a single component tensor. All of the components
2171/// in the dequeued tuple will have size `n` in the 0th dimension.
2172///
2173/// This operation has `k` outputs, where `k` is the number of components in
2174/// the tuples stored in the given queue, and output `i` is the ith
2175/// component of the dequeued tuple.
2176///
2177/// N.B. If the queue is empty, this operation will block until `n` elements
2178/// have been dequeued (or 'timeout_ms' elapses, if specified).
2179///
2180/// Args:
2181/// * scope: A Scope object
2182/// * handle: The handle to a queue.
2183/// * n: The number of tuples to dequeue.
2184/// * component_types: The type of each component in a tuple.
2185///
2186/// Optional attributes (see `Attrs`):
2187/// * timeout_ms: If the queue has fewer than n elements, this operation
2188/// will block for up to timeout_ms milliseconds.
2189/// Note: This option is not supported yet.
2190///
2191/// Returns:
2192/// * `OutputList`: One or more tensors that were dequeued as a tuple.
2193class QueueDequeueMany {
2194 public:
2195 /// Optional attribute setters for QueueDequeueMany
2196 struct Attrs {
2197 /// If the queue has fewer than n elements, this operation
2198 /// will block for up to timeout_ms milliseconds.
2199 /// Note: This option is not supported yet.
2200 ///
2201 /// Defaults to -1
2202 TF_MUST_USE_RESULT Attrs TimeoutMs(int64 x) {
2203 Attrs ret = *this;
2204 ret.timeout_ms_ = x;
2205 return ret;
2206 }
2207
2208 int64 timeout_ms_ = -1;
2209 };
2210 QueueDequeueMany(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
2211 ::tensorflow::Input n, const DataTypeSlice& component_types);
2212 QueueDequeueMany(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
2213 ::tensorflow::Input n, const DataTypeSlice& component_types,
2214 const QueueDequeueMany::Attrs& attrs);
2215 ::tensorflow::Output operator[](size_t index) const { return components[index]; }
2216
2217
2218 static Attrs TimeoutMs(int64 x) {
2219 return Attrs().TimeoutMs(x);
2220 }
2221
2222 Operation operation;
2223 ::tensorflow::OutputList components;
2224};
2225
2226/// Dequeues `n` tuples of one or more tensors from the given queue.
2227///
2228/// This operation is not supported by all queues. If a queue does not support
2229/// DequeueUpTo, then an Unimplemented error is returned.
2230///
2231/// If the queue is closed and there are more than 0 but less than `n`
2232/// elements remaining, then instead of returning an OutOfRange error like
2233/// QueueDequeueMany, less than `n` elements are returned immediately. If
2234/// the queue is closed and there are 0 elements left in the queue, then
2235/// an OutOfRange error is returned just like in QueueDequeueMany.
2236/// Otherwise the behavior is identical to QueueDequeueMany:
2237///
2238/// This operation concatenates queue-element component tensors along the
2239/// 0th dimension to make a single component tensor. All of the components
2240/// in the dequeued tuple will have size n in the 0th dimension.
2241///
2242/// This operation has `k` outputs, where `k` is the number of components in
2243/// the tuples stored in the given queue, and output `i` is the ith
2244/// component of the dequeued tuple.
2245///
2246/// Args:
2247/// * scope: A Scope object
2248/// * handle: The handle to a queue.
2249/// * n: The number of tuples to dequeue.
2250/// * component_types: The type of each component in a tuple.
2251///
2252/// Optional attributes (see `Attrs`):
2253/// * timeout_ms: If the queue has fewer than n elements, this operation
2254/// will block for up to timeout_ms milliseconds.
2255/// Note: This option is not supported yet.
2256///
2257/// Returns:
2258/// * `OutputList`: One or more tensors that were dequeued as a tuple.
2259class QueueDequeueUpTo {
2260 public:
2261 /// Optional attribute setters for QueueDequeueUpTo
2262 struct Attrs {
2263 /// If the queue has fewer than n elements, this operation
2264 /// will block for up to timeout_ms milliseconds.
2265 /// Note: This option is not supported yet.
2266 ///
2267 /// Defaults to -1
2268 TF_MUST_USE_RESULT Attrs TimeoutMs(int64 x) {
2269 Attrs ret = *this;
2270 ret.timeout_ms_ = x;
2271 return ret;
2272 }
2273
2274 int64 timeout_ms_ = -1;
2275 };
2276 QueueDequeueUpTo(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
2277 ::tensorflow::Input n, const DataTypeSlice& component_types);
2278 QueueDequeueUpTo(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
2279 ::tensorflow::Input n, const DataTypeSlice& component_types,
2280 const QueueDequeueUpTo::Attrs& attrs);
2281 ::tensorflow::Output operator[](size_t index) const { return components[index]; }
2282
2283
2284 static Attrs TimeoutMs(int64 x) {
2285 return Attrs().TimeoutMs(x);
2286 }
2287
2288 Operation operation;
2289 ::tensorflow::OutputList components;
2290};
2291
2292/// Dequeues a tuple of one or more tensors from the given queue.
2293///
2294/// This operation has k outputs, where k is the number of components
2295/// in the tuples stored in the given queue, and output i is the ith
2296/// component of the dequeued tuple.
2297///
2298/// N.B. If the queue is empty, this operation will block until an element
2299/// has been dequeued (or 'timeout_ms' elapses, if specified).
2300///
2301/// Args:
2302/// * scope: A Scope object
2303/// * handle: The handle to a queue.
2304/// * component_types: The type of each component in a tuple.
2305///
2306/// Optional attributes (see `Attrs`):
2307/// * timeout_ms: If the queue is empty, this operation will block for up to
2308/// timeout_ms milliseconds.
2309/// Note: This option is not supported yet.
2310///
2311/// Returns:
2312/// * `OutputList`: One or more tensors that were dequeued as a tuple.
2313class QueueDequeue {
2314 public:
2315 /// Optional attribute setters for QueueDequeue
2316 struct Attrs {
2317 /// If the queue is empty, this operation will block for up to
2318 /// timeout_ms milliseconds.
2319 /// Note: This option is not supported yet.
2320 ///
2321 /// Defaults to -1
2322 TF_MUST_USE_RESULT Attrs TimeoutMs(int64 x) {
2323 Attrs ret = *this;
2324 ret.timeout_ms_ = x;
2325 return ret;
2326 }
2327
2328 int64 timeout_ms_ = -1;
2329 };
2330 QueueDequeue(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
2331 const DataTypeSlice& component_types);
2332 QueueDequeue(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
2333 const DataTypeSlice& component_types, const QueueDequeue::Attrs&
2334 attrs);
2335 ::tensorflow::Output operator[](size_t index) const { return components[index]; }
2336
2337
2338 static Attrs TimeoutMs(int64 x) {
2339 return Attrs().TimeoutMs(x);
2340 }
2341
2342 Operation operation;
2343 ::tensorflow::OutputList components;
2344};
2345
2346/// Enqueues zero or more tuples of one or more tensors in the given queue.
2347///
2348/// This operation slices each component tensor along the 0th dimension to
2349/// make multiple queue elements. All of the tuple components must have the
2350/// same size in the 0th dimension.
2351///
2352/// The components input has k elements, which correspond to the components of
2353/// tuples stored in the given queue.
2354///
2355/// N.B. If the queue is full, this operation will block until the given
2356/// elements have been enqueued (or 'timeout_ms' elapses, if specified).
2357///
2358/// Args:
2359/// * scope: A Scope object
2360/// * handle: The handle to a queue.
2361/// * components: One or more tensors from which the enqueued tensors should
2362/// be taken.
2363///
2364/// Optional attributes (see `Attrs`):
2365/// * timeout_ms: If the queue is too full, this operation will block for up
2366/// to timeout_ms milliseconds.
2367/// Note: This option is not supported yet.
2368///
2369/// Returns:
2370/// * the created `Operation`
2371class QueueEnqueueMany {
2372 public:
2373 /// Optional attribute setters for QueueEnqueueMany
2374 struct Attrs {
2375 /// If the queue is too full, this operation will block for up
2376 /// to timeout_ms milliseconds.
2377 /// Note: This option is not supported yet.
2378 ///
2379 /// Defaults to -1
2380 TF_MUST_USE_RESULT Attrs TimeoutMs(int64 x) {
2381 Attrs ret = *this;
2382 ret.timeout_ms_ = x;
2383 return ret;
2384 }
2385
2386 int64 timeout_ms_ = -1;
2387 };
2388 QueueEnqueueMany(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
2389 ::tensorflow::InputList components);
2390 QueueEnqueueMany(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
2391 ::tensorflow::InputList components, const
2392 QueueEnqueueMany::Attrs& attrs);
2393 operator ::tensorflow::Operation() const { return operation; }
2394
2395 static Attrs TimeoutMs(int64 x) {
2396 return Attrs().TimeoutMs(x);
2397 }
2398
2399 Operation operation;
2400};
2401
2402/// Enqueues a tuple of one or more tensors in the given queue.
2403///
2404/// The components input has k elements, which correspond to the components of
2405/// tuples stored in the given queue.
2406///
2407/// N.B. If the queue is full, this operation will block until the given
2408/// element has been enqueued (or 'timeout_ms' elapses, if specified).
2409///
2410/// Args:
2411/// * scope: A Scope object
2412/// * handle: The handle to a queue.
2413/// * components: One or more tensors from which the enqueued tensors should be taken.
2414///
2415/// Optional attributes (see `Attrs`):
2416/// * timeout_ms: If the queue is full, this operation will block for up to
2417/// timeout_ms milliseconds.
2418/// Note: This option is not supported yet.
2419///
2420/// Returns:
2421/// * the created `Operation`
2422class QueueEnqueue {
2423 public:
2424 /// Optional attribute setters for QueueEnqueue
2425 struct Attrs {
2426 /// If the queue is full, this operation will block for up to
2427 /// timeout_ms milliseconds.
2428 /// Note: This option is not supported yet.
2429 ///
2430 /// Defaults to -1
2431 TF_MUST_USE_RESULT Attrs TimeoutMs(int64 x) {
2432 Attrs ret = *this;
2433 ret.timeout_ms_ = x;
2434 return ret;
2435 }
2436
2437 int64 timeout_ms_ = -1;
2438 };
2439 QueueEnqueue(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
2440 ::tensorflow::InputList components);
2441 QueueEnqueue(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
2442 ::tensorflow::InputList components, const QueueEnqueue::Attrs&
2443 attrs);
2444 operator ::tensorflow::Operation() const { return operation; }
2445
2446 static Attrs TimeoutMs(int64 x) {
2447 return Attrs().TimeoutMs(x);
2448 }
2449
2450 Operation operation;
2451};
2452
2453/// Returns true if queue is closed.
2454///
2455/// This operation returns true if the queue is closed and false if the queue
2456/// is open.
2457///
2458/// Args:
2459/// * scope: A Scope object
2460/// * handle: The handle to a queue.
2461///
2462/// Returns:
2463/// * `Output`: The is_closed tensor.
2464class QueueIsClosed {
2465 public:
2466 QueueIsClosed(const ::tensorflow::Scope& scope, ::tensorflow::Input handle);
2467 operator ::tensorflow::Output() const { return is_closed; }
2468 operator ::tensorflow::Input() const { return is_closed; }
2469 ::tensorflow::Node* node() const { return is_closed.node(); }
2470
2471 Operation operation;
2472 ::tensorflow::Output is_closed;
2473};
2474
2475/// Returns true if queue is closed.
2476///
2477/// This operation returns true if the queue is closed and false if the queue
2478/// is open.
2479///
2480/// Args:
2481/// * scope: A Scope object
2482/// * handle: The handle to a queue.
2483///
2484/// Returns:
2485/// * `Output`: The is_closed tensor.
2486class QueueIsClosedV2 {
2487 public:
2488 QueueIsClosedV2(const ::tensorflow::Scope& scope, ::tensorflow::Input handle);
2489 operator ::tensorflow::Output() const { return is_closed; }
2490 operator ::tensorflow::Input() const { return is_closed; }
2491 ::tensorflow::Node* node() const { return is_closed.node(); }
2492
2493 Operation operation;
2494 ::tensorflow::Output is_closed;
2495};
2496
2497/// Computes the number of elements in the given queue.
2498///
2499/// Args:
2500/// * scope: A Scope object
2501/// * handle: The handle to a queue.
2502///
2503/// Returns:
2504/// * `Output`: The number of elements in the given queue.
2505class QueueSize {
2506 public:
2507 QueueSize(const ::tensorflow::Scope& scope, ::tensorflow::Input handle);
2508 operator ::tensorflow::Output() const { return size; }
2509 operator ::tensorflow::Input() const { return size; }
2510 ::tensorflow::Node* node() const { return size.node(); }
2511
2512 Operation operation;
2513 ::tensorflow::Output size;
2514};
2515
2516/// A queue that randomizes the order of elements.
2517///
2518/// Args:
2519/// * scope: A Scope object
2520/// * component_types: The type of each component in a value.
2521///
2522/// Optional attributes (see `Attrs`):
2523/// * shapes: The shape of each component in a value. The length of this attr must
2524/// be either 0 or the same as the length of component_types. If the length of
2525/// this attr is 0, the shapes of queue elements are not constrained, and
2526/// only one element may be dequeued at a time.
2527/// * capacity: The upper bound on the number of elements in this queue.
2528/// Negative numbers mean no limit.
2529/// * min_after_dequeue: Dequeue will block unless there would be this
2530/// many elements after the dequeue or the queue is closed. This
2531/// ensures a minimum level of mixing of elements.
2532/// * seed: If either seed or seed2 is set to be non-zero, the random number
2533/// generator is seeded by the given seed. Otherwise, a random seed is used.
2534/// * seed2: A second seed to avoid seed collision.
2535/// * container: If non-empty, this queue is placed in the given container.
2536/// Otherwise, a default container is used.
2537/// * shared_name: If non-empty, this queue will be shared under the given name
2538/// across multiple sessions.
2539///
2540/// Returns:
2541/// * `Output`: The handle to the queue.
2542class RandomShuffleQueue {
2543 public:
2544 /// Optional attribute setters for RandomShuffleQueue
2545 struct Attrs {
2546 /// The shape of each component in a value. The length of this attr must
2547 /// be either 0 or the same as the length of component_types. If the length of
2548 /// this attr is 0, the shapes of queue elements are not constrained, and
2549 /// only one element may be dequeued at a time.
2550 ///
2551 /// Defaults to []
2552 TF_MUST_USE_RESULT Attrs Shapes(const gtl::ArraySlice<PartialTensorShape>& x) {
2553 Attrs ret = *this;
2554 ret.shapes_ = x;
2555 return ret;
2556 }
2557
2558 /// The upper bound on the number of elements in this queue.
2559 /// Negative numbers mean no limit.
2560 ///
2561 /// Defaults to -1
2562 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
2563 Attrs ret = *this;
2564 ret.capacity_ = x;
2565 return ret;
2566 }
2567
2568 /// Dequeue will block unless there would be this
2569 /// many elements after the dequeue or the queue is closed. This
2570 /// ensures a minimum level of mixing of elements.
2571 ///
2572 /// Defaults to 0
2573 TF_MUST_USE_RESULT Attrs MinAfterDequeue(int64 x) {
2574 Attrs ret = *this;
2575 ret.min_after_dequeue_ = x;
2576 return ret;
2577 }
2578
2579 /// If either seed or seed2 is set to be non-zero, the random number
2580 /// generator is seeded by the given seed. Otherwise, a random seed is used.
2581 ///
2582 /// Defaults to 0
2583 TF_MUST_USE_RESULT Attrs Seed(int64 x) {
2584 Attrs ret = *this;
2585 ret.seed_ = x;
2586 return ret;
2587 }
2588
2589 /// A second seed to avoid seed collision.
2590 ///
2591 /// Defaults to 0
2592 TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
2593 Attrs ret = *this;
2594 ret.seed2_ = x;
2595 return ret;
2596 }
2597
2598 /// If non-empty, this queue is placed in the given container.
2599 /// Otherwise, a default container is used.
2600 ///
2601 /// Defaults to ""
2602 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
2603 Attrs ret = *this;
2604 ret.container_ = x;
2605 return ret;
2606 }
2607
2608 /// If non-empty, this queue will be shared under the given name
2609 /// across multiple sessions.
2610 ///
2611 /// Defaults to ""
2612 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
2613 Attrs ret = *this;
2614 ret.shared_name_ = x;
2615 return ret;
2616 }
2617
2618 gtl::ArraySlice<PartialTensorShape> shapes_ = {};
2619 int64 capacity_ = -1;
2620 int64 min_after_dequeue_ = 0;
2621 int64 seed_ = 0;
2622 int64 seed2_ = 0;
2623 StringPiece container_ = "";
2624 StringPiece shared_name_ = "";
2625 };
2626 RandomShuffleQueue(const ::tensorflow::Scope& scope, const DataTypeSlice&
2627 component_types);
2628 RandomShuffleQueue(const ::tensorflow::Scope& scope, const DataTypeSlice&
2629 component_types, const RandomShuffleQueue::Attrs& attrs);
2630 operator ::tensorflow::Output() const { return handle; }
2631 operator ::tensorflow::Input() const { return handle; }
2632 ::tensorflow::Node* node() const { return handle.node(); }
2633
2634 static Attrs Shapes(const gtl::ArraySlice<PartialTensorShape>& x) {
2635 return Attrs().Shapes(x);
2636 }
2637 static Attrs Capacity(int64 x) {
2638 return Attrs().Capacity(x);
2639 }
2640 static Attrs MinAfterDequeue(int64 x) {
2641 return Attrs().MinAfterDequeue(x);
2642 }
2643 static Attrs Seed(int64 x) {
2644 return Attrs().Seed(x);
2645 }
2646 static Attrs Seed2(int64 x) {
2647 return Attrs().Seed2(x);
2648 }
2649 static Attrs Container(StringPiece x) {
2650 return Attrs().Container(x);
2651 }
2652 static Attrs SharedName(StringPiece x) {
2653 return Attrs().SharedName(x);
2654 }
2655
2656 Operation operation;
2657 ::tensorflow::Output handle;
2658};
2659
2660/// Emits randomized records.
2661///
2662/// Args:
2663/// * scope: A Scope object
2664/// * file_pattern: Glob pattern for the data files.
2665///
2666/// Optional attributes (see `Attrs`):
2667/// * file_random_seed: Random seeds used to produce randomized records.
2668/// * file_shuffle_shift_ratio: Shifts the list of files after the list is randomly
2669/// shuffled.
2670/// * file_buffer_size: The randomization shuffling buffer.
2671/// * file_parallelism: How many sstables are opened and concurrently iterated over.
2672/// * batch_size: The batch size.
2673/// * compression_type: The type of compression for the file. Currently ZLIB and
2674/// GZIP are supported. Defaults to none.
2675///
2676/// Returns:
2677/// * `Output`: A tensor of shape [batch_size].
2678class RecordInput {
2679 public:
2680 /// Optional attribute setters for RecordInput
2681 struct Attrs {
2682 /// Random seeds used to produce randomized records.
2683 ///
2684 /// Defaults to 301
2685 TF_MUST_USE_RESULT Attrs FileRandomSeed(int64 x) {
2686 Attrs ret = *this;
2687 ret.file_random_seed_ = x;
2688 return ret;
2689 }
2690
2691 /// Shifts the list of files after the list is randomly
2692 /// shuffled.
2693 ///
2694 /// Defaults to 0
2695 TF_MUST_USE_RESULT Attrs FileShuffleShiftRatio(float x) {
2696 Attrs ret = *this;
2697 ret.file_shuffle_shift_ratio_ = x;
2698 return ret;
2699 }
2700
2701 /// The randomization shuffling buffer.
2702 ///
2703 /// Defaults to 10000
2704 TF_MUST_USE_RESULT Attrs FileBufferSize(int64 x) {
2705 Attrs ret = *this;
2706 ret.file_buffer_size_ = x;
2707 return ret;
2708 }
2709
2710 /// How many sstables are opened and concurrently iterated over.
2711 ///
2712 /// Defaults to 16
2713 TF_MUST_USE_RESULT Attrs FileParallelism(int64 x) {
2714 Attrs ret = *this;
2715 ret.file_parallelism_ = x;
2716 return ret;
2717 }
2718
2719 /// The batch size.
2720 ///
2721 /// Defaults to 32
2722 TF_MUST_USE_RESULT Attrs BatchSize(int64 x) {
2723 Attrs ret = *this;
2724 ret.batch_size_ = x;
2725 return ret;
2726 }
2727
2728 /// The type of compression for the file. Currently ZLIB and
2729 /// GZIP are supported. Defaults to none.
2730 ///
2731 /// Defaults to ""
2732 TF_MUST_USE_RESULT Attrs CompressionType(StringPiece x) {
2733 Attrs ret = *this;
2734 ret.compression_type_ = x;
2735 return ret;
2736 }
2737
2738 int64 file_random_seed_ = 301;
2739 float file_shuffle_shift_ratio_ = 0.0f;
2740 int64 file_buffer_size_ = 10000;
2741 int64 file_parallelism_ = 16;
2742 int64 batch_size_ = 32;
2743 StringPiece compression_type_ = "";
2744 };
2745 RecordInput(const ::tensorflow::Scope& scope, StringPiece file_pattern);
2746 RecordInput(const ::tensorflow::Scope& scope, StringPiece file_pattern, const
2747 RecordInput::Attrs& attrs);
2748 operator ::tensorflow::Output() const { return records; }
2749 operator ::tensorflow::Input() const { return records; }
2750 ::tensorflow::Node* node() const { return records.node(); }
2751
2752 static Attrs FileRandomSeed(int64 x) {
2753 return Attrs().FileRandomSeed(x);
2754 }
2755 static Attrs FileShuffleShiftRatio(float x) {
2756 return Attrs().FileShuffleShiftRatio(x);
2757 }
2758 static Attrs FileBufferSize(int64 x) {
2759 return Attrs().FileBufferSize(x);
2760 }
2761 static Attrs FileParallelism(int64 x) {
2762 return Attrs().FileParallelism(x);
2763 }
2764 static Attrs BatchSize(int64 x) {
2765 return Attrs().BatchSize(x);
2766 }
2767 static Attrs CompressionType(StringPiece x) {
2768 return Attrs().CompressionType(x);
2769 }
2770
2771 Operation operation;
2772 ::tensorflow::Output records;
2773};
2774
2775/// Applies a sparse gradient to a given accumulator.
2776///
2777/// Does not add if local_step is smaller than the accumulator's
2778/// global_step.
2779///
2780/// Args:
2781/// * scope: A Scope object
2782/// * handle: The handle to a accumulator.
2783/// * local_step: The local_step value at which the sparse gradient was computed.
2784/// * gradient_indices: Indices of the sparse gradient to be accumulated. Must be a
2785/// vector.
2786/// * gradient_values: Values are the non-zero slices of the gradient, and must have
2787/// the same first dimension as indices, i.e., the nnz represented by indices and
2788/// values must be consistent.
2789/// * gradient_shape: Shape of the sparse gradient to be accumulated.
2790/// * has_known_shape: Boolean indicating whether gradient_shape is unknown, in which
2791/// case the input is ignored during validation.
2792///
2793/// Returns:
2794/// * the created `Operation`
2795class SparseAccumulatorApplyGradient {
2796 public:
2797 SparseAccumulatorApplyGradient(const ::tensorflow::Scope& scope,
2798 ::tensorflow::Input handle, ::tensorflow::Input
2799 local_step, ::tensorflow::Input
2800 gradient_indices, ::tensorflow::Input
2801 gradient_values, ::tensorflow::Input
2802 gradient_shape, bool has_known_shape);
2803 operator ::tensorflow::Operation() const { return operation; }
2804
2805 Operation operation;
2806};
2807
2808/// Extracts the average sparse gradient in a SparseConditionalAccumulator.
2809///
2810/// The op will blocks until sufficient (i.e., more than num_required)
2811/// gradients have been accumulated. If the accumulator has already
2812/// aggregated more than num_required gradients, it will return its
2813/// average of the accumulated gradients. Also automatically increments
2814/// the recorded global_step in the accumulator by 1, and resets the
2815/// aggregate to 0.
2816///
2817/// Args:
2818/// * scope: A Scope object
2819/// * handle: The handle to a SparseConditionalAccumulator.
2820/// * num_required: Number of gradients required before we return an aggregate.
2821/// * dtype: The data type of accumulated gradients. Needs to correspond to the type
2822/// of the accumulator.
2823///
2824/// Returns:
2825/// * `Output` indices: Indices of the average of the accumulated sparse gradients.
2826/// * `Output` values: Values of the average of the accumulated sparse gradients.
2827/// * `Output` shape: Shape of the average of the accumulated sparse gradients.
2828class SparseAccumulatorTakeGradient {
2829 public:
2830 SparseAccumulatorTakeGradient(const ::tensorflow::Scope& scope,
2831 ::tensorflow::Input handle, ::tensorflow::Input
2832 num_required, DataType dtype);
2833
2834 Operation operation;
2835 ::tensorflow::Output indices;
2836 ::tensorflow::Output values;
2837 ::tensorflow::Output shape;
2838};
2839
2840/// A conditional accumulator for aggregating sparse gradients.
2841///
2842/// The accumulator accepts gradients marked with local_step greater or
2843/// equal to the most recent global_step known to the accumulator. The
2844/// average can be extracted from the accumulator, provided sufficient
2845/// gradients have been accumulated. Extracting the average automatically
2846/// resets the aggregate to 0, and increments the global_step recorded by
2847/// the accumulator.
2848///
2849/// Args:
2850/// * scope: A Scope object
2851/// * dtype: The type of the value being accumulated.
2852/// * shape: The shape of the values.
2853///
2854/// Optional attributes (see `Attrs`):
2855/// * container: If non-empty, this accumulator is placed in the given container.
2856/// Otherwise, a default container is used.
2857/// * shared_name: If non-empty, this accumulator will be shared under the given name
2858/// across multiple sessions.
2859///
2860/// Returns:
2861/// * `Output`: The handle to the accumulator.
2862class SparseConditionalAccumulator {
2863 public:
2864 /// Optional attribute setters for SparseConditionalAccumulator
2865 struct Attrs {
2866 /// If non-empty, this accumulator is placed in the given container.
2867 /// Otherwise, a default container is used.
2868 ///
2869 /// Defaults to ""
2870 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
2871 Attrs ret = *this;
2872 ret.container_ = x;
2873 return ret;
2874 }
2875
2876 /// If non-empty, this accumulator will be shared under the given name
2877 /// across multiple sessions.
2878 ///
2879 /// Defaults to ""
2880 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
2881 Attrs ret = *this;
2882 ret.shared_name_ = x;
2883 return ret;
2884 }
2885
2886 /// Defaults to "MEAN"
2887 TF_MUST_USE_RESULT Attrs ReductionType(StringPiece x) {
2888 Attrs ret = *this;
2889 ret.reduction_type_ = x;
2890 return ret;
2891 }
2892
2893 StringPiece container_ = "";
2894 StringPiece shared_name_ = "";
2895 StringPiece reduction_type_ = "MEAN";
2896 };
2897 SparseConditionalAccumulator(const ::tensorflow::Scope& scope, DataType dtype,
2898 PartialTensorShape shape);
2899 SparseConditionalAccumulator(const ::tensorflow::Scope& scope, DataType dtype,
2900 PartialTensorShape shape, const
2901 SparseConditionalAccumulator::Attrs& attrs);
2902 operator ::tensorflow::Output() const { return handle; }
2903 operator ::tensorflow::Input() const { return handle; }
2904 ::tensorflow::Node* node() const { return handle.node(); }
2905
2906 static Attrs Container(StringPiece x) {
2907 return Attrs().Container(x);
2908 }
2909 static Attrs SharedName(StringPiece x) {
2910 return Attrs().SharedName(x);
2911 }
2912 static Attrs ReductionType(StringPiece x) {
2913 return Attrs().ReductionType(x);
2914 }
2915
2916 Operation operation;
2917 ::tensorflow::Output handle;
2918};
2919
2920/// Stage values similar to a lightweight Enqueue.
2921///
2922/// The basic functionality of this Op is similar to a queue with many
2923/// fewer capabilities and options. This Op is optimized for performance.
2924///
2925/// Args:
2926/// * scope: A Scope object
2927/// * values: a list of tensors
2928/// dtypes A list of data types that inserted values should adhere to.
2929///
2930/// Optional attributes (see `Attrs`):
2931/// * capacity: Maximum number of elements in the Staging Area. If > 0, inserts
2932/// on the container will block when the capacity is reached.
2933/// * memory_limit: The maximum number of bytes allowed for Tensors in the Staging Area.
2934/// If > 0, inserts will block until sufficient space is available.
2935/// * container: If non-empty, this queue is placed in the given container. Otherwise,
2936/// a default container is used.
2937/// * shared_name: It is necessary to match this name to the matching Unstage Op.
2938///
2939/// Returns:
2940/// * the created `Operation`
2941class Stage {
2942 public:
2943 /// Optional attribute setters for Stage
2944 struct Attrs {
2945 /// Maximum number of elements in the Staging Area. If > 0, inserts
2946 /// on the container will block when the capacity is reached.
2947 ///
2948 /// Defaults to 0
2949 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
2950 Attrs ret = *this;
2951 ret.capacity_ = x;
2952 return ret;
2953 }
2954
2955 /// The maximum number of bytes allowed for Tensors in the Staging Area.
2956 /// If > 0, inserts will block until sufficient space is available.
2957 ///
2958 /// Defaults to 0
2959 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
2960 Attrs ret = *this;
2961 ret.memory_limit_ = x;
2962 return ret;
2963 }
2964
2965 /// If non-empty, this queue is placed in the given container. Otherwise,
2966 /// a default container is used.
2967 ///
2968 /// Defaults to ""
2969 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
2970 Attrs ret = *this;
2971 ret.container_ = x;
2972 return ret;
2973 }
2974
2975 /// It is necessary to match this name to the matching Unstage Op.
2976 ///
2977 /// Defaults to ""
2978 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
2979 Attrs ret = *this;
2980 ret.shared_name_ = x;
2981 return ret;
2982 }
2983
2984 int64 capacity_ = 0;
2985 int64 memory_limit_ = 0;
2986 StringPiece container_ = "";
2987 StringPiece shared_name_ = "";
2988 };
2989 Stage(const ::tensorflow::Scope& scope, ::tensorflow::InputList values);
2990 Stage(const ::tensorflow::Scope& scope, ::tensorflow::InputList values, const
2991 Stage::Attrs& attrs);
2992 operator ::tensorflow::Operation() const { return operation; }
2993
2994 static Attrs Capacity(int64 x) {
2995 return Attrs().Capacity(x);
2996 }
2997 static Attrs MemoryLimit(int64 x) {
2998 return Attrs().MemoryLimit(x);
2999 }
3000 static Attrs Container(StringPiece x) {
3001 return Attrs().Container(x);
3002 }
3003 static Attrs SharedName(StringPiece x) {
3004 return Attrs().SharedName(x);
3005 }
3006
3007 Operation operation;
3008};
3009
3010/// Op removes all elements in the underlying container.
3011///
3012/// Args:
3013/// * scope: A Scope object
3014///
3015/// Returns:
3016/// * the created `Operation`
3017class StageClear {
3018 public:
3019 /// Optional attribute setters for StageClear
3020 struct Attrs {
3021 /// Defaults to 0
3022 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
3023 Attrs ret = *this;
3024 ret.capacity_ = x;
3025 return ret;
3026 }
3027
3028 /// Defaults to 0
3029 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
3030 Attrs ret = *this;
3031 ret.memory_limit_ = x;
3032 return ret;
3033 }
3034
3035 /// Defaults to ""
3036 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
3037 Attrs ret = *this;
3038 ret.container_ = x;
3039 return ret;
3040 }
3041
3042 /// Defaults to ""
3043 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
3044 Attrs ret = *this;
3045 ret.shared_name_ = x;
3046 return ret;
3047 }
3048
3049 int64 capacity_ = 0;
3050 int64 memory_limit_ = 0;
3051 StringPiece container_ = "";
3052 StringPiece shared_name_ = "";
3053 };
3054 StageClear(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes);
3055 StageClear(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes, const
3056 StageClear::Attrs& attrs);
3057 operator ::tensorflow::Operation() const { return operation; }
3058
3059 static Attrs Capacity(int64 x) {
3060 return Attrs().Capacity(x);
3061 }
3062 static Attrs MemoryLimit(int64 x) {
3063 return Attrs().MemoryLimit(x);
3064 }
3065 static Attrs Container(StringPiece x) {
3066 return Attrs().Container(x);
3067 }
3068 static Attrs SharedName(StringPiece x) {
3069 return Attrs().SharedName(x);
3070 }
3071
3072 Operation operation;
3073};
3074
3075/// Op peeks at the values at the specified index. If the
3076///
3077/// underlying container does not contain sufficient elements
3078/// this op will block until it does. This Op is optimized for
3079/// performance.
3080///
3081/// Args:
3082/// * scope: A Scope object
3083///
3084/// Returns:
3085/// * `OutputList`: The values tensor.
3086class StagePeek {
3087 public:
3088 /// Optional attribute setters for StagePeek
3089 struct Attrs {
3090 /// Defaults to 0
3091 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
3092 Attrs ret = *this;
3093 ret.capacity_ = x;
3094 return ret;
3095 }
3096
3097 /// Defaults to 0
3098 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
3099 Attrs ret = *this;
3100 ret.memory_limit_ = x;
3101 return ret;
3102 }
3103
3104 /// Defaults to ""
3105 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
3106 Attrs ret = *this;
3107 ret.container_ = x;
3108 return ret;
3109 }
3110
3111 /// Defaults to ""
3112 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
3113 Attrs ret = *this;
3114 ret.shared_name_ = x;
3115 return ret;
3116 }
3117
3118 int64 capacity_ = 0;
3119 int64 memory_limit_ = 0;
3120 StringPiece container_ = "";
3121 StringPiece shared_name_ = "";
3122 };
3123 StagePeek(const ::tensorflow::Scope& scope, ::tensorflow::Input index, const
3124 DataTypeSlice& dtypes);
3125 StagePeek(const ::tensorflow::Scope& scope, ::tensorflow::Input index, const
3126 DataTypeSlice& dtypes, const StagePeek::Attrs& attrs);
3127 ::tensorflow::Output operator[](size_t index) const { return values[index]; }
3128
3129
3130 static Attrs Capacity(int64 x) {
3131 return Attrs().Capacity(x);
3132 }
3133 static Attrs MemoryLimit(int64 x) {
3134 return Attrs().MemoryLimit(x);
3135 }
3136 static Attrs Container(StringPiece x) {
3137 return Attrs().Container(x);
3138 }
3139 static Attrs SharedName(StringPiece x) {
3140 return Attrs().SharedName(x);
3141 }
3142
3143 Operation operation;
3144 ::tensorflow::OutputList values;
3145};
3146
3147/// Op returns the number of elements in the underlying container.
3148///
3149/// Args:
3150/// * scope: A Scope object
3151///
3152/// Returns:
3153/// * `Output`: The size tensor.
3154class StageSize {
3155 public:
3156 /// Optional attribute setters for StageSize
3157 struct Attrs {
3158 /// Defaults to 0
3159 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
3160 Attrs ret = *this;
3161 ret.capacity_ = x;
3162 return ret;
3163 }
3164
3165 /// Defaults to 0
3166 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
3167 Attrs ret = *this;
3168 ret.memory_limit_ = x;
3169 return ret;
3170 }
3171
3172 /// Defaults to ""
3173 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
3174 Attrs ret = *this;
3175 ret.container_ = x;
3176 return ret;
3177 }
3178
3179 /// Defaults to ""
3180 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
3181 Attrs ret = *this;
3182 ret.shared_name_ = x;
3183 return ret;
3184 }
3185
3186 int64 capacity_ = 0;
3187 int64 memory_limit_ = 0;
3188 StringPiece container_ = "";
3189 StringPiece shared_name_ = "";
3190 };
3191 StageSize(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes);
3192 StageSize(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes, const
3193 StageSize::Attrs& attrs);
3194 operator ::tensorflow::Output() const { return size; }
3195 operator ::tensorflow::Input() const { return size; }
3196 ::tensorflow::Node* node() const { return size.node(); }
3197
3198 static Attrs Capacity(int64 x) {
3199 return Attrs().Capacity(x);
3200 }
3201 static Attrs MemoryLimit(int64 x) {
3202 return Attrs().MemoryLimit(x);
3203 }
3204 static Attrs Container(StringPiece x) {
3205 return Attrs().Container(x);
3206 }
3207 static Attrs SharedName(StringPiece x) {
3208 return Attrs().SharedName(x);
3209 }
3210
3211 Operation operation;
3212 ::tensorflow::Output size;
3213};
3214
3215/// Delete the TensorArray from its resource container.
3216///
3217/// This enables the user to close and release the resource in the middle
3218/// of a step/run.
3219///
3220/// Args:
3221/// * scope: A Scope object
3222/// * handle: The handle to a TensorArray (output of TensorArray or TensorArrayGrad).
3223///
3224/// Returns:
3225/// * the created `Operation`
3226class TensorArrayClose {
3227 public:
3228 TensorArrayClose(const ::tensorflow::Scope& scope, ::tensorflow::Input handle);
3229 operator ::tensorflow::Operation() const { return operation; }
3230
3231 Operation operation;
3232};
3233
3234/// Concat the elements from the TensorArray into value `value`.
3235///
3236/// Takes `T` elements of shapes
3237///
3238/// ```
3239/// (n0 x d0 x d1 x ...), (n1 x d0 x d1 x ...), ..., (n(T-1) x d0 x d1 x ...)
3240/// ```
3241///
3242/// and concatenates them into a Tensor of shape:
3243///
3244/// ```(n0 + n1 + ... + n(T-1) x d0 x d1 x ...)```
3245///
3246/// All elements must have the same shape (excepting the first dimension).
3247///
3248/// Args:
3249/// * scope: A Scope object
3250/// * handle: The handle to a TensorArray.
3251/// * flow_in: A float scalar that enforces proper chaining of operations.
3252/// * dtype: The type of the elem that is returned.
3253///
3254/// Optional attributes (see `Attrs`):
3255/// * element_shape_except0: The expected shape of an element, if known,
3256/// excluding the first dimension. Used to validate the shapes of
3257/// TensorArray elements. If this shape is not fully specified, concatenating
3258/// zero-size TensorArrays is an error.
3259///
3260/// Returns:
3261/// * `Output` value: All of the elements in the TensorArray, concatenated along the first
3262/// axis.
3263/// * `Output` lengths: A vector of the row sizes of the original T elements in the
3264/// value output. In the example above, this would be the values:
3265/// `(n1, n2, ..., n(T-1))`.
3266class TensorArrayConcat {
3267 public:
3268 /// Optional attribute setters for TensorArrayConcat
3269 struct Attrs {
3270 /// The expected shape of an element, if known,
3271 /// excluding the first dimension. Used to validate the shapes of
3272 /// TensorArray elements. If this shape is not fully specified, concatenating
3273 /// zero-size TensorArrays is an error.
3274 ///
3275 /// Defaults to <unknown>
3276 TF_MUST_USE_RESULT Attrs ElementShapeExcept0(PartialTensorShape x) {
3277 Attrs ret = *this;
3278 ret.element_shape_except0_ = x;
3279 return ret;
3280 }
3281
3282 PartialTensorShape element_shape_except0_ = ::tensorflow::PartialTensorShape() /* unknown */;
3283 };
3284 TensorArrayConcat(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
3285 ::tensorflow::Input flow_in, DataType dtype);
3286 TensorArrayConcat(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
3287 ::tensorflow::Input flow_in, DataType dtype, const
3288 TensorArrayConcat::Attrs& attrs);
3289
3290 static Attrs ElementShapeExcept0(PartialTensorShape x) {
3291 return Attrs().ElementShapeExcept0(x);
3292 }
3293
3294 Operation operation;
3295 ::tensorflow::Output value;
3296 ::tensorflow::Output lengths;
3297};
3298
3299/// Gather specific elements from the TensorArray into output `value`.
3300///
3301/// All elements selected by `indices` must have the same shape.
3302///
3303/// Args:
3304/// * scope: A Scope object
3305/// * handle: The handle to a TensorArray.
3306/// * indices: The locations in the TensorArray from which to read tensor elements.
3307/// * flow_in: A float scalar that enforces proper chaining of operations.
3308/// * dtype: The type of the elem that is returned.
3309///
3310/// Optional attributes (see `Attrs`):
3311/// * element_shape: The expected shape of an element, if known. Used to
3312/// validate the shapes of TensorArray elements. If this shape is not
3313/// fully specified, gathering zero-size TensorArrays is an error.
3314///
3315/// Returns:
3316/// * `Output`: All of the elements in the TensorArray, concatenated along a new
3317/// axis (the new dimension 0).
3318class TensorArrayGather {
3319 public:
3320 /// Optional attribute setters for TensorArrayGather
3321 struct Attrs {
3322 /// The expected shape of an element, if known. Used to
3323 /// validate the shapes of TensorArray elements. If this shape is not
3324 /// fully specified, gathering zero-size TensorArrays is an error.
3325 ///
3326 /// Defaults to <unknown>
3327 TF_MUST_USE_RESULT Attrs ElementShape(PartialTensorShape x) {
3328 Attrs ret = *this;
3329 ret.element_shape_ = x;
3330 return ret;
3331 }
3332
3333 PartialTensorShape element_shape_ = ::tensorflow::PartialTensorShape() /* unknown */;
3334 };
3335 TensorArrayGather(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
3336 ::tensorflow::Input indices, ::tensorflow::Input flow_in,
3337 DataType dtype);
3338 TensorArrayGather(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
3339 ::tensorflow::Input indices, ::tensorflow::Input flow_in,
3340 DataType dtype, const TensorArrayGather::Attrs& attrs);
3341 operator ::tensorflow::Output() const { return value; }
3342 operator ::tensorflow::Input() const { return value; }
3343 ::tensorflow::Node* node() const { return value.node(); }
3344
3345 static Attrs ElementShape(PartialTensorShape x) {
3346 return Attrs().ElementShape(x);
3347 }
3348
3349 Operation operation;
3350 ::tensorflow::Output value;
3351};
3352
3353/// Creates a TensorArray for storing the gradients of values in the given handle.
3354///
3355/// If the given TensorArray gradient already exists, returns a reference to it.
3356///
3357/// Locks the size of the original TensorArray by disabling its dynamic size flag.
3358///
3359/// **A note about the input flow_in:**
3360///
3361/// The handle flow_in forces the execution of the gradient lookup to occur
3362/// only after certain other operations have occurred. For example, when
3363/// the forward TensorArray is dynamically sized, writes to this TensorArray
3364/// may resize the object. The gradient TensorArray is statically sized based
3365/// on the size of the forward TensorArray when this operation executes.
3366/// Furthermore, the size of the forward TensorArray is frozen by this call.
3367/// As a result, the flow is used to ensure that the call to generate the gradient
3368/// TensorArray only happens after all writes are executed.
3369///
3370/// In the case of dynamically sized TensorArrays, gradient computation should
3371/// only be performed on read operations that have themselves been chained via
3372/// flow to occur only after all writes have executed. That way the final size
3373/// of the forward TensorArray is known when this operation is called.
3374///
3375/// **A note about the source attribute:**
3376///
3377/// TensorArray gradient calls use an accumulator TensorArray object. If
3378/// multiple gradients are calculated and run in the same session, the multiple
3379/// gradient nodes may accidentally flow through the same accumulator TensorArray.
3380/// This double counts and generally breaks the TensorArray gradient flow.
3381///
3382/// The solution is to identify which gradient call this particular
3383/// TensorArray gradient is being called in. This is performed by identifying
3384/// a unique string (e.g. "gradients", "gradients_1", ...) from the input
3385/// gradient Tensor's name. This string is used as a suffix when creating
3386/// the TensorArray gradient object here (the attribute `source`).
3387///
3388/// The attribute `source` is added as a suffix to the forward TensorArray's
3389/// name when performing the creation / lookup, so that each separate gradient
3390/// calculation gets its own TensorArray accumulator.
3391///
3392/// Args:
3393/// * scope: A Scope object
3394/// * handle: The handle to the forward TensorArray.
3395/// * flow_in: A float scalar that enforces proper chaining of operations.
3396/// * source: The gradient source string, used to decide which gradient TensorArray
3397/// to return.
3398///
3399/// Returns:
3400/// * `Output` grad_handle
3401/// * `Output` flow_out
3402class TensorArrayGrad {
3403 public:
3404 TensorArrayGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
3405 ::tensorflow::Input flow_in, StringPiece source);
3406
3407 Operation operation;
3408 ::tensorflow::Output grad_handle;
3409 ::tensorflow::Output flow_out;
3410};
3411
3412/// Creates a TensorArray for storing multiple gradients of values in the given handle.
3413///
3414/// Similar to TensorArrayGradV3. However it creates an accumulator with an
3415/// expanded shape compared to the input TensorArray whose gradient is being
3416/// computed. This enables multiple gradients for the same TensorArray to be
3417/// calculated using the same accumulator.
3418///
3419/// Args:
3420/// * scope: A Scope object
3421/// * handle: The handle to the forward TensorArray.
3422/// * flow_in: A float scalar that enforces proper chaining of operations.
3423/// * shape_to_prepend: An int32 vector representing a shape. Elements in the gradient accumulator will
3424/// have shape which is this shape_to_prepend value concatenated with shape of the
3425/// elements in the TensorArray corresponding to the input handle.
3426/// * source: The gradient source string, used to decide which gradient TensorArray
3427/// to return.
3428///
3429/// Returns:
3430/// * `Output` grad_handle
3431/// * `Output` flow_out
3432class TensorArrayGradWithShape {
3433 public:
3434 TensorArrayGradWithShape(const ::tensorflow::Scope& scope, ::tensorflow::Input
3435 handle, ::tensorflow::Input flow_in,
3436 ::tensorflow::Input shape_to_prepend, StringPiece
3437 source);
3438
3439 Operation operation;
3440 ::tensorflow::Output grad_handle;
3441 ::tensorflow::Output flow_out;
3442};
3443
3444/// Read an element from the TensorArray into output `value`.
3445///
3446/// Args:
3447/// * scope: A Scope object
3448/// * handle: The handle to a TensorArray.
3449/// * flow_in: A float scalar that enforces proper chaining of operations.
3450/// * dtype: The type of the elem that is returned.
3451///
3452/// Returns:
3453/// * `Output`: The tensor that is read from the TensorArray.
3454class TensorArrayRead {
3455 public:
3456 TensorArrayRead(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
3457 ::tensorflow::Input index, ::tensorflow::Input flow_in,
3458 DataType dtype);
3459 operator ::tensorflow::Output() const { return value; }
3460 operator ::tensorflow::Input() const { return value; }
3461 ::tensorflow::Node* node() const { return value.node(); }
3462
3463 Operation operation;
3464 ::tensorflow::Output value;
3465};
3466
3467/// Scatter the data from the input value into specific TensorArray elements.
3468///
3469/// `indices` must be a vector, its length must match the first dim of `value`.
3470///
3471/// Args:
3472/// * scope: A Scope object
3473/// * handle: The handle to a TensorArray.
3474/// * indices: The locations at which to write the tensor elements.
3475/// * value: The concatenated tensor to write to the TensorArray.
3476/// * flow_in: A float scalar that enforces proper chaining of operations.
3477///
3478/// Returns:
3479/// * `Output`: A float scalar that enforces proper chaining of operations.
3480class TensorArrayScatter {
3481 public:
3482 TensorArrayScatter(const ::tensorflow::Scope& scope, ::tensorflow::Input
3483 handle, ::tensorflow::Input indices, ::tensorflow::Input
3484 value, ::tensorflow::Input flow_in);
3485 operator ::tensorflow::Output() const { return flow_out; }
3486 operator ::tensorflow::Input() const { return flow_out; }
3487 ::tensorflow::Node* node() const { return flow_out.node(); }
3488
3489 Operation operation;
3490 ::tensorflow::Output flow_out;
3491};
3492
3493/// Get the current size of the TensorArray.
3494///
3495/// Args:
3496/// * scope: A Scope object
3497/// * handle: The handle to a TensorArray (output of TensorArray or TensorArrayGrad).
3498/// * flow_in: A float scalar that enforces proper chaining of operations.
3499///
3500/// Returns:
3501/// * `Output`: The current size of the TensorArray.
3502class TensorArraySize {
3503 public:
3504 TensorArraySize(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
3505 ::tensorflow::Input flow_in);
3506 operator ::tensorflow::Output() const { return size; }
3507 operator ::tensorflow::Input() const { return size; }
3508 ::tensorflow::Node* node() const { return size.node(); }
3509
3510 Operation operation;
3511 ::tensorflow::Output size;
3512};
3513
3514/// Split the data from the input value into TensorArray elements.
3515///
3516/// Assuming that `lengths` takes on values
3517///
3518/// ```(n0, n1, ..., n(T-1))```
3519///
3520/// and that `value` has shape
3521///
3522/// ```(n0 + n1 + ... + n(T-1) x d0 x d1 x ...)```,
3523///
3524/// this splits values into a TensorArray with T tensors.
3525///
3526/// TensorArray index t will be the subtensor of values with starting position
3527///
3528/// ```(n0 + n1 + ... + n(t-1), 0, 0, ...)```
3529///
3530/// and having size
3531///
3532/// ```nt x d0 x d1 x ...```
3533///
3534/// Args:
3535/// * scope: A Scope object
3536/// * handle: The handle to a TensorArray.
3537/// * value: The concatenated tensor to write to the TensorArray.
3538/// * lengths: The vector of lengths, how to split the rows of value into the
3539/// TensorArray.
3540/// * flow_in: A float scalar that enforces proper chaining of operations.
3541///
3542/// Returns:
3543/// * `Output`: A float scalar that enforces proper chaining of operations.
3544class TensorArraySplit {
3545 public:
3546 TensorArraySplit(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
3547 ::tensorflow::Input value, ::tensorflow::Input lengths,
3548 ::tensorflow::Input flow_in);
3549 operator ::tensorflow::Output() const { return flow_out; }
3550 operator ::tensorflow::Input() const { return flow_out; }
3551 ::tensorflow::Node* node() const { return flow_out.node(); }
3552
3553 Operation operation;
3554 ::tensorflow::Output flow_out;
3555};
3556
3557/// An array of Tensors of given size.
3558///
3559/// Write data via Write and read via Read or Pack.
3560///
3561/// Args:
3562/// * scope: A Scope object
3563/// * size: The size of the array.
3564/// * dtype: The type of the elements on the tensor_array.
3565///
3566/// Optional attributes (see `Attrs`):
3567/// * element_shape: The expected shape of an element, if known. Used to
3568/// validate the shapes of TensorArray elements. If this shape is not
3569/// fully specified, gathering zero-size TensorArrays is an error.
3570/// * dynamic_size: A boolean that determines whether writes to the TensorArray
3571/// are allowed to grow the size. By default, this is not allowed.
3572/// * clear_after_read: If true (default), Tensors in the TensorArray are cleared
3573/// after being read. This disables multiple read semantics but allows early
3574/// release of memory.
3575/// * identical_element_shapes: If true (default is false), then all
3576/// elements in the TensorArray will be expected to have identical shapes.
3577/// This allows certain behaviors, like dynamically checking for
3578/// consistent shapes on write, and being able to fill in properly
3579/// shaped zero tensors on stack -- even if the element_shape attribute
3580/// is not fully defined.
3581/// * tensor_array_name: Overrides the name used for the temporary tensor_array
3582/// resource. Default value is the name of the 'TensorArray' op (which
3583/// is guaranteed unique).
3584///
3585/// Returns:
3586/// * `Output` handle: The handle to the TensorArray.
3587/// * `Output` flow: A scalar used to control gradient flow.
3588class TensorArray {
3589 public:
3590 /// Optional attribute setters for TensorArray
3591 struct Attrs {
3592 /// The expected shape of an element, if known. Used to
3593 /// validate the shapes of TensorArray elements. If this shape is not
3594 /// fully specified, gathering zero-size TensorArrays is an error.
3595 ///
3596 /// Defaults to <unknown>
3597 TF_MUST_USE_RESULT Attrs ElementShape(PartialTensorShape x) {
3598 Attrs ret = *this;
3599 ret.element_shape_ = x;
3600 return ret;
3601 }
3602
3603 /// A boolean that determines whether writes to the TensorArray
3604 /// are allowed to grow the size. By default, this is not allowed.
3605 ///
3606 /// Defaults to false
3607 TF_MUST_USE_RESULT Attrs DynamicSize(bool x) {
3608 Attrs ret = *this;
3609 ret.dynamic_size_ = x;
3610 return ret;
3611 }
3612
3613 /// If true (default), Tensors in the TensorArray are cleared
3614 /// after being read. This disables multiple read semantics but allows early
3615 /// release of memory.
3616 ///
3617 /// Defaults to true
3618 TF_MUST_USE_RESULT Attrs ClearAfterRead(bool x) {
3619 Attrs ret = *this;
3620 ret.clear_after_read_ = x;
3621 return ret;
3622 }
3623
3624 /// If true (default is false), then all
3625 /// elements in the TensorArray will be expected to have identical shapes.
3626 /// This allows certain behaviors, like dynamically checking for
3627 /// consistent shapes on write, and being able to fill in properly
3628 /// shaped zero tensors on stack -- even if the element_shape attribute
3629 /// is not fully defined.
3630 ///
3631 /// Defaults to false
3632 TF_MUST_USE_RESULT Attrs IdenticalElementShapes(bool x) {
3633 Attrs ret = *this;
3634 ret.identical_element_shapes_ = x;
3635 return ret;
3636 }
3637
3638 /// Overrides the name used for the temporary tensor_array
3639 /// resource. Default value is the name of the 'TensorArray' op (which
3640 /// is guaranteed unique).
3641 ///
3642 /// Defaults to ""
3643 TF_MUST_USE_RESULT Attrs TensorArrayName(StringPiece x) {
3644 Attrs ret = *this;
3645 ret.tensor_array_name_ = x;
3646 return ret;
3647 }
3648
3649 PartialTensorShape element_shape_ = ::tensorflow::PartialTensorShape() /* unknown */;
3650 bool dynamic_size_ = false;
3651 bool clear_after_read_ = true;
3652 bool identical_element_shapes_ = false;
3653 StringPiece tensor_array_name_ = "";
3654 };
3655 TensorArray(const ::tensorflow::Scope& scope, ::tensorflow::Input size,
3656 DataType dtype);
3657 TensorArray(const ::tensorflow::Scope& scope, ::tensorflow::Input size,
3658 DataType dtype, const TensorArray::Attrs& attrs);
3659
3660 static Attrs ElementShape(PartialTensorShape x) {
3661 return Attrs().ElementShape(x);
3662 }
3663 static Attrs DynamicSize(bool x) {
3664 return Attrs().DynamicSize(x);
3665 }
3666 static Attrs ClearAfterRead(bool x) {
3667 return Attrs().ClearAfterRead(x);
3668 }
3669 static Attrs IdenticalElementShapes(bool x) {
3670 return Attrs().IdenticalElementShapes(x);
3671 }
3672 static Attrs TensorArrayName(StringPiece x) {
3673 return Attrs().TensorArrayName(x);
3674 }
3675
3676 Operation operation;
3677 ::tensorflow::Output handle;
3678 ::tensorflow::Output flow;
3679};
3680
3681/// Push an element onto the tensor_array.
3682///
3683/// Args:
3684/// * scope: A Scope object
3685/// * handle: The handle to a TensorArray.
3686/// * index: The position to write to inside the TensorArray.
3687/// * value: The tensor to write to the TensorArray.
3688/// * flow_in: A float scalar that enforces proper chaining of operations.
3689///
3690/// Returns:
3691/// * `Output`: A float scalar that enforces proper chaining of operations.
3692class TensorArrayWrite {
3693 public:
3694 TensorArrayWrite(const ::tensorflow::Scope& scope, ::tensorflow::Input handle,
3695 ::tensorflow::Input index, ::tensorflow::Input value,
3696 ::tensorflow::Input flow_in);
3697 operator ::tensorflow::Output() const { return flow_out; }
3698 operator ::tensorflow::Input() const { return flow_out; }
3699 ::tensorflow::Node* node() const { return flow_out.node(); }
3700
3701 Operation operation;
3702 ::tensorflow::Output flow_out;
3703};
3704
3705/// Op is similar to a lightweight Dequeue.
3706///
3707/// The basic functionality is similar to dequeue with many fewer
3708/// capabilities and options. This Op is optimized for performance.
3709///
3710/// Args:
3711/// * scope: A Scope object
3712///
3713/// Returns:
3714/// * `OutputList`: The values tensor.
3715class Unstage {
3716 public:
3717 /// Optional attribute setters for Unstage
3718 struct Attrs {
3719 /// Defaults to 0
3720 TF_MUST_USE_RESULT Attrs Capacity(int64 x) {
3721 Attrs ret = *this;
3722 ret.capacity_ = x;
3723 return ret;
3724 }
3725
3726 /// Defaults to 0
3727 TF_MUST_USE_RESULT Attrs MemoryLimit(int64 x) {
3728 Attrs ret = *this;
3729 ret.memory_limit_ = x;
3730 return ret;
3731 }
3732
3733 /// Defaults to ""
3734 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
3735 Attrs ret = *this;
3736 ret.container_ = x;
3737 return ret;
3738 }
3739
3740 /// Defaults to ""
3741 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
3742 Attrs ret = *this;
3743 ret.shared_name_ = x;
3744 return ret;
3745 }
3746
3747 int64 capacity_ = 0;
3748 int64 memory_limit_ = 0;
3749 StringPiece container_ = "";
3750 StringPiece shared_name_ = "";
3751 };
3752 Unstage(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes);
3753 Unstage(const ::tensorflow::Scope& scope, const DataTypeSlice& dtypes, const
3754 Unstage::Attrs& attrs);
3755 ::tensorflow::Output operator[](size_t index) const { return values[index]; }
3756
3757
3758 static Attrs Capacity(int64 x) {
3759 return Attrs().Capacity(x);
3760 }
3761 static Attrs MemoryLimit(int64 x) {
3762 return Attrs().MemoryLimit(x);
3763 }
3764 static Attrs Container(StringPiece x) {
3765 return Attrs().Container(x);
3766 }
3767 static Attrs SharedName(StringPiece x) {
3768 return Attrs().SharedName(x);
3769 }
3770
3771 Operation operation;
3772 ::tensorflow::OutputList values;
3773};
3774
3775/// @}
3776
3777} // namespace ops
3778} // namespace tensorflow
3779
3780#endif // TENSORFLOW_CC_OPS_DATA_FLOW_OPS_H_
3781