1 | // This file is MACHINE GENERATED! Do not edit. |
2 | |
3 | #ifndef TENSORFLOW_CC_OPS_IO_OPS_H_ |
4 | #define TENSORFLOW_CC_OPS_IO_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 | |
15 | namespace tensorflow { |
16 | namespace ops { |
17 | |
18 | /// @defgroup io_ops Io Ops |
19 | /// @{ |
20 | |
21 | /// A Reader that outputs fixed-length records from a file. |
22 | /// |
23 | /// Args: |
24 | /// * scope: A Scope object |
25 | /// * record_bytes: Number of bytes in the record. |
26 | /// |
27 | /// Optional attributes (see `Attrs`): |
28 | /// * header_bytes: Number of bytes in the header, defaults to 0. |
29 | /// * footer_bytes: Number of bytes in the footer, defaults to 0. |
30 | /// * hop_bytes: Number of bytes to hop before each read. Default of 0 means using |
31 | /// record_bytes. |
32 | /// * container: If non-empty, this reader is placed in the given container. |
33 | /// Otherwise, a default container is used. |
34 | /// * shared_name: If non-empty, this reader is named in the given bucket |
35 | /// with this shared_name. Otherwise, the node name is used instead. |
36 | /// * encoding: The type of encoding for the file. Currently ZLIB and GZIP |
37 | /// are supported. Defaults to none. |
38 | /// |
39 | /// Returns: |
40 | /// * `Output`: The handle to reference the Reader. |
41 | class FixedLengthRecordReader { |
42 | public: |
43 | /// Optional attribute setters for FixedLengthRecordReader |
44 | struct Attrs { |
45 | /// Number of bytes in the header, defaults to 0. |
46 | /// |
47 | /// Defaults to 0 |
48 | TF_MUST_USE_RESULT Attrs (int64 x) { |
49 | Attrs ret = *this; |
50 | ret.header_bytes_ = x; |
51 | return ret; |
52 | } |
53 | |
54 | /// Number of bytes in the footer, defaults to 0. |
55 | /// |
56 | /// Defaults to 0 |
57 | TF_MUST_USE_RESULT Attrs (int64 x) { |
58 | Attrs ret = *this; |
59 | ret.footer_bytes_ = x; |
60 | return ret; |
61 | } |
62 | |
63 | /// Number of bytes to hop before each read. Default of 0 means using |
64 | /// record_bytes. |
65 | /// |
66 | /// Defaults to 0 |
67 | TF_MUST_USE_RESULT Attrs HopBytes(int64 x) { |
68 | Attrs ret = *this; |
69 | ret.hop_bytes_ = x; |
70 | return ret; |
71 | } |
72 | |
73 | /// If non-empty, this reader is placed in the given container. |
74 | /// Otherwise, a default container is used. |
75 | /// |
76 | /// Defaults to "" |
77 | TF_MUST_USE_RESULT Attrs Container(StringPiece x) { |
78 | Attrs ret = *this; |
79 | ret.container_ = x; |
80 | return ret; |
81 | } |
82 | |
83 | /// If non-empty, this reader is named in the given bucket |
84 | /// with this shared_name. Otherwise, the node name is used instead. |
85 | /// |
86 | /// Defaults to "" |
87 | TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) { |
88 | Attrs ret = *this; |
89 | ret.shared_name_ = x; |
90 | return ret; |
91 | } |
92 | |
93 | /// The type of encoding for the file. Currently ZLIB and GZIP |
94 | /// are supported. Defaults to none. |
95 | /// |
96 | /// Defaults to "" |
97 | TF_MUST_USE_RESULT Attrs Encoding(StringPiece x) { |
98 | Attrs ret = *this; |
99 | ret.encoding_ = x; |
100 | return ret; |
101 | } |
102 | |
103 | int64 = 0; |
104 | int64 = 0; |
105 | int64 hop_bytes_ = 0; |
106 | StringPiece container_ = "" ; |
107 | StringPiece shared_name_ = "" ; |
108 | StringPiece encoding_ = "" ; |
109 | }; |
110 | FixedLengthRecordReader(const ::tensorflow::Scope& scope, int64 record_bytes); |
111 | FixedLengthRecordReader(const ::tensorflow::Scope& scope, int64 record_bytes, |
112 | const FixedLengthRecordReader::Attrs& attrs); |
113 | operator ::tensorflow::Output() const { return reader_handle; } |
114 | operator ::tensorflow::Input() const { return reader_handle; } |
115 | ::tensorflow::Node* node() const { return reader_handle.node(); } |
116 | |
117 | static Attrs (int64 x) { |
118 | return Attrs().HeaderBytes(x); |
119 | } |
120 | static Attrs (int64 x) { |
121 | return Attrs().FooterBytes(x); |
122 | } |
123 | static Attrs HopBytes(int64 x) { |
124 | return Attrs().HopBytes(x); |
125 | } |
126 | static Attrs Container(StringPiece x) { |
127 | return Attrs().Container(x); |
128 | } |
129 | static Attrs SharedName(StringPiece x) { |
130 | return Attrs().SharedName(x); |
131 | } |
132 | static Attrs Encoding(StringPiece x) { |
133 | return Attrs().Encoding(x); |
134 | } |
135 | |
136 | Operation operation; |
137 | ::tensorflow::Output reader_handle; |
138 | }; |
139 | |
140 | /// A Reader that outputs the queued work as both the key and value. |
141 | /// |
142 | /// To use, enqueue strings in a Queue. ReaderRead will take the front |
143 | /// work string and output (work, work). |
144 | /// |
145 | /// Args: |
146 | /// * scope: A Scope object |
147 | /// |
148 | /// Optional attributes (see `Attrs`): |
149 | /// * container: If non-empty, this reader is placed in the given container. |
150 | /// Otherwise, a default container is used. |
151 | /// * shared_name: If non-empty, this reader is named in the given bucket |
152 | /// with this shared_name. Otherwise, the node name is used instead. |
153 | /// |
154 | /// Returns: |
155 | /// * `Output`: The handle to reference the Reader. |
156 | class IdentityReader { |
157 | public: |
158 | /// Optional attribute setters for IdentityReader |
159 | struct Attrs { |
160 | /// If non-empty, this reader is placed in the given container. |
161 | /// Otherwise, a default container is used. |
162 | /// |
163 | /// Defaults to "" |
164 | TF_MUST_USE_RESULT Attrs Container(StringPiece x) { |
165 | Attrs ret = *this; |
166 | ret.container_ = x; |
167 | return ret; |
168 | } |
169 | |
170 | /// If non-empty, this reader is named in the given bucket |
171 | /// with this shared_name. Otherwise, the node name is used instead. |
172 | /// |
173 | /// Defaults to "" |
174 | TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) { |
175 | Attrs ret = *this; |
176 | ret.shared_name_ = x; |
177 | return ret; |
178 | } |
179 | |
180 | StringPiece container_ = "" ; |
181 | StringPiece shared_name_ = "" ; |
182 | }; |
183 | IdentityReader(const ::tensorflow::Scope& scope); |
184 | IdentityReader(const ::tensorflow::Scope& scope, const IdentityReader::Attrs& |
185 | attrs); |
186 | operator ::tensorflow::Output() const { return reader_handle; } |
187 | operator ::tensorflow::Input() const { return reader_handle; } |
188 | ::tensorflow::Node* node() const { return reader_handle.node(); } |
189 | |
190 | static Attrs Container(StringPiece x) { |
191 | return Attrs().Container(x); |
192 | } |
193 | static Attrs SharedName(StringPiece x) { |
194 | return Attrs().SharedName(x); |
195 | } |
196 | |
197 | Operation operation; |
198 | ::tensorflow::Output reader_handle; |
199 | }; |
200 | |
201 | /// A Reader that outputs the records from a LMDB file. |
202 | /// |
203 | /// Args: |
204 | /// * scope: A Scope object |
205 | /// |
206 | /// Optional attributes (see `Attrs`): |
207 | /// * container: If non-empty, this reader is placed in the given container. |
208 | /// Otherwise, a default container is used. |
209 | /// * shared_name: If non-empty, this reader is named in the given bucket |
210 | /// with this shared_name. Otherwise, the node name is used instead. |
211 | /// |
212 | /// Returns: |
213 | /// * `Output`: The handle to reference the Reader. |
214 | class LMDBReader { |
215 | public: |
216 | /// Optional attribute setters for LMDBReader |
217 | struct Attrs { |
218 | /// If non-empty, this reader is placed in the given container. |
219 | /// Otherwise, a default container is used. |
220 | /// |
221 | /// Defaults to "" |
222 | TF_MUST_USE_RESULT Attrs Container(StringPiece x) { |
223 | Attrs ret = *this; |
224 | ret.container_ = x; |
225 | return ret; |
226 | } |
227 | |
228 | /// If non-empty, this reader is named in the given bucket |
229 | /// with this shared_name. Otherwise, the node name is used instead. |
230 | /// |
231 | /// Defaults to "" |
232 | TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) { |
233 | Attrs ret = *this; |
234 | ret.shared_name_ = x; |
235 | return ret; |
236 | } |
237 | |
238 | StringPiece container_ = "" ; |
239 | StringPiece shared_name_ = "" ; |
240 | }; |
241 | LMDBReader(const ::tensorflow::Scope& scope); |
242 | LMDBReader(const ::tensorflow::Scope& scope, const LMDBReader::Attrs& attrs); |
243 | operator ::tensorflow::Output() const { return reader_handle; } |
244 | operator ::tensorflow::Input() const { return reader_handle; } |
245 | ::tensorflow::Node* node() const { return reader_handle.node(); } |
246 | |
247 | static Attrs Container(StringPiece x) { |
248 | return Attrs().Container(x); |
249 | } |
250 | static Attrs SharedName(StringPiece x) { |
251 | return Attrs().SharedName(x); |
252 | } |
253 | |
254 | Operation operation; |
255 | ::tensorflow::Output reader_handle; |
256 | }; |
257 | |
258 | /// Returns the set of files matching one or more glob patterns. |
259 | /// |
260 | /// Note that this routine only supports wildcard characters in the |
261 | /// basename portion of the pattern, not in the directory portion. |
262 | /// Note also that the order of filenames returned is deterministic. |
263 | /// |
264 | /// Args: |
265 | /// * scope: A Scope object |
266 | /// * pattern: Shell wildcard pattern(s). Scalar or vector of type string. |
267 | /// |
268 | /// Returns: |
269 | /// * `Output`: A vector of matching filenames. |
270 | class MatchingFiles { |
271 | public: |
272 | MatchingFiles(const ::tensorflow::Scope& scope, ::tensorflow::Input pattern); |
273 | operator ::tensorflow::Output() const { return filenames; } |
274 | operator ::tensorflow::Input() const { return filenames; } |
275 | ::tensorflow::Node* node() const { return filenames.node(); } |
276 | |
277 | Operation operation; |
278 | ::tensorflow::Output filenames; |
279 | }; |
280 | |
281 | /// V2 format specific: merges the metadata files of sharded checkpoints. The |
282 | /// |
283 | /// result is one logical checkpoint, with one physical metadata file and renamed |
284 | /// data files. |
285 | /// |
286 | /// Intended for "grouping" multiple checkpoints in a sharded checkpoint setup. |
287 | /// |
288 | /// If delete_old_dirs is true, attempts to delete recursively the dirname of each |
289 | /// path in the input checkpoint_prefixes. This is useful when those paths are non |
290 | /// user-facing temporary locations. |
291 | /// |
292 | /// If allow_missing_files is true, merges the checkpoint prefixes as long as |
293 | /// at least one file exists. Otherwise, if no files exist, an error will be thrown. |
294 | /// The default value for allow_missing_files is false. |
295 | /// |
296 | /// Args: |
297 | /// * scope: A Scope object |
298 | /// * checkpoint_prefixes: prefixes of V2 checkpoints to merge. |
299 | /// * destination_prefix: scalar. The desired final prefix. Allowed to be the same |
300 | /// as one of the checkpoint_prefixes. |
301 | /// |
302 | /// Optional attributes (see `Attrs`): |
303 | /// * delete_old_dirs: see above. |
304 | /// * allow_missing_files: see above. |
305 | /// |
306 | /// Returns: |
307 | /// * the created `Operation` |
308 | class MergeV2Checkpoints { |
309 | public: |
310 | /// Optional attribute setters for MergeV2Checkpoints |
311 | struct Attrs { |
312 | /// see above. |
313 | /// |
314 | /// Defaults to true |
315 | TF_MUST_USE_RESULT Attrs DeleteOldDirs(bool x) { |
316 | Attrs ret = *this; |
317 | ret.delete_old_dirs_ = x; |
318 | return ret; |
319 | } |
320 | |
321 | /// see above. |
322 | /// |
323 | /// Defaults to false |
324 | TF_MUST_USE_RESULT Attrs AllowMissingFiles(bool x) { |
325 | Attrs ret = *this; |
326 | ret.allow_missing_files_ = x; |
327 | return ret; |
328 | } |
329 | |
330 | bool delete_old_dirs_ = true; |
331 | bool allow_missing_files_ = false; |
332 | }; |
333 | MergeV2Checkpoints(const ::tensorflow::Scope& scope, ::tensorflow::Input |
334 | checkpoint_prefixes, ::tensorflow::Input destination_prefix); |
335 | MergeV2Checkpoints(const ::tensorflow::Scope& scope, ::tensorflow::Input |
336 | checkpoint_prefixes, ::tensorflow::Input destination_prefix, |
337 | const MergeV2Checkpoints::Attrs& attrs); |
338 | operator ::tensorflow::Operation() const { return operation; } |
339 | |
340 | static Attrs DeleteOldDirs(bool x) { |
341 | return Attrs().DeleteOldDirs(x); |
342 | } |
343 | static Attrs AllowMissingFiles(bool x) { |
344 | return Attrs().AllowMissingFiles(x); |
345 | } |
346 | |
347 | Operation operation; |
348 | }; |
349 | |
350 | /// Reads and outputs the entire contents of the input filename. |
351 | /// |
352 | /// Args: |
353 | /// * scope: A Scope object |
354 | /// |
355 | /// Returns: |
356 | /// * `Output`: The contents tensor. |
357 | class ReadFile { |
358 | public: |
359 | ReadFile(const ::tensorflow::Scope& scope, ::tensorflow::Input filename); |
360 | operator ::tensorflow::Output() const { return contents; } |
361 | operator ::tensorflow::Input() const { return contents; } |
362 | ::tensorflow::Node* node() const { return contents.node(); } |
363 | |
364 | Operation operation; |
365 | ::tensorflow::Output contents; |
366 | }; |
367 | |
368 | /// Returns the number of records this Reader has produced. |
369 | /// |
370 | /// This is the same as the number of ReaderRead executions that have |
371 | /// succeeded. |
372 | /// |
373 | /// Args: |
374 | /// * scope: A Scope object |
375 | /// * reader_handle: Handle to a Reader. |
376 | /// |
377 | /// Returns: |
378 | /// * `Output`: The records_produced tensor. |
379 | class ReaderNumRecordsProduced { |
380 | public: |
381 | ReaderNumRecordsProduced(const ::tensorflow::Scope& scope, ::tensorflow::Input |
382 | reader_handle); |
383 | operator ::tensorflow::Output() const { return records_produced; } |
384 | operator ::tensorflow::Input() const { return records_produced; } |
385 | ::tensorflow::Node* node() const { return records_produced.node(); } |
386 | |
387 | Operation operation; |
388 | ::tensorflow::Output records_produced; |
389 | }; |
390 | |
391 | /// Returns the number of work units this Reader has finished processing. |
392 | /// |
393 | /// Args: |
394 | /// * scope: A Scope object |
395 | /// * reader_handle: Handle to a Reader. |
396 | /// |
397 | /// Returns: |
398 | /// * `Output`: The units_completed tensor. |
399 | class ReaderNumWorkUnitsCompleted { |
400 | public: |
401 | ReaderNumWorkUnitsCompleted(const ::tensorflow::Scope& scope, |
402 | ::tensorflow::Input reader_handle); |
403 | operator ::tensorflow::Output() const { return units_completed; } |
404 | operator ::tensorflow::Input() const { return units_completed; } |
405 | ::tensorflow::Node* node() const { return units_completed.node(); } |
406 | |
407 | Operation operation; |
408 | ::tensorflow::Output units_completed; |
409 | }; |
410 | |
411 | /// Returns up to `num_records` (key, value) pairs produced by a Reader. |
412 | /// |
413 | /// Will dequeue from the input queue if necessary (e.g. when the |
414 | /// Reader needs to start reading from a new file since it has finished |
415 | /// with the previous file). |
416 | /// It may return less than `num_records` even before the last batch. |
417 | /// |
418 | /// Args: |
419 | /// * scope: A Scope object |
420 | /// * reader_handle: Handle to a `Reader`. |
421 | /// * queue_handle: Handle to a `Queue`, with string work items. |
422 | /// * num_records: number of records to read from `Reader`. |
423 | /// |
424 | /// Returns: |
425 | /// * `Output` keys: A 1-D tensor. |
426 | /// * `Output` values: A 1-D tensor. |
427 | class ReaderReadUpTo { |
428 | public: |
429 | ReaderReadUpTo(const ::tensorflow::Scope& scope, ::tensorflow::Input |
430 | reader_handle, ::tensorflow::Input queue_handle, |
431 | ::tensorflow::Input num_records); |
432 | |
433 | Operation operation; |
434 | ::tensorflow::Output keys; |
435 | ::tensorflow::Output values; |
436 | }; |
437 | |
438 | /// Returns the next record (key, value pair) produced by a Reader. |
439 | /// |
440 | /// Will dequeue from the input queue if necessary (e.g. when the |
441 | /// Reader needs to start reading from a new file since it has finished |
442 | /// with the previous file). |
443 | /// |
444 | /// Args: |
445 | /// * scope: A Scope object |
446 | /// * reader_handle: Handle to a Reader. |
447 | /// * queue_handle: Handle to a Queue, with string work items. |
448 | /// |
449 | /// Returns: |
450 | /// * `Output` key: A scalar. |
451 | /// * `Output` value: A scalar. |
452 | class ReaderRead { |
453 | public: |
454 | ReaderRead(const ::tensorflow::Scope& scope, ::tensorflow::Input reader_handle, |
455 | ::tensorflow::Input queue_handle); |
456 | |
457 | Operation operation; |
458 | ::tensorflow::Output key; |
459 | ::tensorflow::Output value; |
460 | }; |
461 | |
462 | /// Restore a Reader to its initial clean state. |
463 | /// |
464 | /// Args: |
465 | /// * scope: A Scope object |
466 | /// * reader_handle: Handle to a Reader. |
467 | /// |
468 | /// Returns: |
469 | /// * the created `Operation` |
470 | class ReaderReset { |
471 | public: |
472 | ReaderReset(const ::tensorflow::Scope& scope, ::tensorflow::Input |
473 | reader_handle); |
474 | operator ::tensorflow::Operation() const { return operation; } |
475 | |
476 | Operation operation; |
477 | }; |
478 | |
479 | /// Restore a reader to a previously saved state. |
480 | /// |
481 | /// Not all Readers support being restored, so this can produce an |
482 | /// Unimplemented error. |
483 | /// |
484 | /// Args: |
485 | /// * scope: A Scope object |
486 | /// * reader_handle: Handle to a Reader. |
487 | /// * state: Result of a ReaderSerializeState of a Reader with type |
488 | /// matching reader_handle. |
489 | /// |
490 | /// Returns: |
491 | /// * the created `Operation` |
492 | class ReaderRestoreState { |
493 | public: |
494 | ReaderRestoreState(const ::tensorflow::Scope& scope, ::tensorflow::Input |
495 | reader_handle, ::tensorflow::Input state); |
496 | operator ::tensorflow::Operation() const { return operation; } |
497 | |
498 | Operation operation; |
499 | }; |
500 | |
501 | /// Produce a string tensor that encodes the state of a Reader. |
502 | /// |
503 | /// Not all Readers support being serialized, so this can produce an |
504 | /// Unimplemented error. |
505 | /// |
506 | /// Args: |
507 | /// * scope: A Scope object |
508 | /// * reader_handle: Handle to a Reader. |
509 | /// |
510 | /// Returns: |
511 | /// * `Output`: The state tensor. |
512 | class ReaderSerializeState { |
513 | public: |
514 | ReaderSerializeState(const ::tensorflow::Scope& scope, ::tensorflow::Input |
515 | reader_handle); |
516 | operator ::tensorflow::Output() const { return state; } |
517 | operator ::tensorflow::Input() const { return state; } |
518 | ::tensorflow::Node* node() const { return state.node(); } |
519 | |
520 | Operation operation; |
521 | ::tensorflow::Output state; |
522 | }; |
523 | |
524 | /// Restores a tensor from checkpoint files. |
525 | /// |
526 | /// Reads a tensor stored in one or several files. If there are several files (for |
527 | /// instance because a tensor was saved as slices), `file_pattern` may contain |
528 | /// wildcard symbols (`*` and `?`) in the filename portion only, not in the |
529 | /// directory portion. |
530 | /// |
531 | /// If a `file_pattern` matches several files, `preferred_shard` can be used to hint |
532 | /// in which file the requested tensor is likely to be found. This op will first |
533 | /// open the file at index `preferred_shard` in the list of matching files and try |
534 | /// to restore tensors from that file. Only if some tensors or tensor slices are |
535 | /// not found in that first file, then the Op opens all the files. Setting |
536 | /// `preferred_shard` to match the value passed as the `shard` input |
537 | /// of a matching `Save` Op may speed up Restore. This attribute only affects |
538 | /// performance, not correctness. The default value -1 means files are processed in |
539 | /// order. |
540 | /// |
541 | /// See also `RestoreSlice`. |
542 | /// |
543 | /// Args: |
544 | /// * scope: A Scope object |
545 | /// * file_pattern: Must have a single element. The pattern of the files from |
546 | /// which we read the tensor. |
547 | /// * tensor_name: Must have a single element. The name of the tensor to be |
548 | /// restored. |
549 | /// * dt: The type of the tensor to be restored. |
550 | /// |
551 | /// Optional attributes (see `Attrs`): |
552 | /// * preferred_shard: Index of file to open first if multiple files match |
553 | /// `file_pattern`. |
554 | /// |
555 | /// Returns: |
556 | /// * `Output`: The restored tensor. |
557 | class Restore { |
558 | public: |
559 | /// Optional attribute setters for Restore |
560 | struct Attrs { |
561 | /// Index of file to open first if multiple files match |
562 | /// `file_pattern`. |
563 | /// |
564 | /// Defaults to -1 |
565 | TF_MUST_USE_RESULT Attrs PreferredShard(int64 x) { |
566 | Attrs ret = *this; |
567 | ret.preferred_shard_ = x; |
568 | return ret; |
569 | } |
570 | |
571 | int64 preferred_shard_ = -1; |
572 | }; |
573 | Restore(const ::tensorflow::Scope& scope, ::tensorflow::Input file_pattern, |
574 | ::tensorflow::Input tensor_name, DataType dt); |
575 | Restore(const ::tensorflow::Scope& scope, ::tensorflow::Input file_pattern, |
576 | ::tensorflow::Input tensor_name, DataType dt, const Restore::Attrs& |
577 | attrs); |
578 | operator ::tensorflow::Output() const { return tensor; } |
579 | operator ::tensorflow::Input() const { return tensor; } |
580 | ::tensorflow::Node* node() const { return tensor.node(); } |
581 | |
582 | static Attrs PreferredShard(int64 x) { |
583 | return Attrs().PreferredShard(x); |
584 | } |
585 | |
586 | Operation operation; |
587 | ::tensorflow::Output tensor; |
588 | }; |
589 | |
590 | /// Restores a tensor from checkpoint files. |
591 | /// |
592 | /// This is like `Restore` except that restored tensor can be listed as filling |
593 | /// only a slice of a larger tensor. `shape_and_slice` specifies the shape of the |
594 | /// larger tensor and the slice that the restored tensor covers. |
595 | /// |
596 | /// The `shape_and_slice` input has the same format as the |
597 | /// elements of the `shapes_and_slices` input of the `SaveSlices` op. |
598 | /// |
599 | /// Args: |
600 | /// * scope: A Scope object |
601 | /// * file_pattern: Must have a single element. The pattern of the files from |
602 | /// which we read the tensor. |
603 | /// * tensor_name: Must have a single element. The name of the tensor to be |
604 | /// restored. |
605 | /// * shape_and_slice: Scalar. The shapes and slice specifications to use when |
606 | /// restoring a tensors. |
607 | /// * dt: The type of the tensor to be restored. |
608 | /// |
609 | /// Optional attributes (see `Attrs`): |
610 | /// * preferred_shard: Index of file to open first if multiple files match |
611 | /// `file_pattern`. See the documentation for `Restore`. |
612 | /// |
613 | /// Returns: |
614 | /// * `Output`: The restored tensor. |
615 | class RestoreSlice { |
616 | public: |
617 | /// Optional attribute setters for RestoreSlice |
618 | struct Attrs { |
619 | /// Index of file to open first if multiple files match |
620 | /// `file_pattern`. See the documentation for `Restore`. |
621 | /// |
622 | /// Defaults to -1 |
623 | TF_MUST_USE_RESULT Attrs PreferredShard(int64 x) { |
624 | Attrs ret = *this; |
625 | ret.preferred_shard_ = x; |
626 | return ret; |
627 | } |
628 | |
629 | int64 preferred_shard_ = -1; |
630 | }; |
631 | RestoreSlice(const ::tensorflow::Scope& scope, ::tensorflow::Input |
632 | file_pattern, ::tensorflow::Input tensor_name, ::tensorflow::Input |
633 | shape_and_slice, DataType dt); |
634 | RestoreSlice(const ::tensorflow::Scope& scope, ::tensorflow::Input |
635 | file_pattern, ::tensorflow::Input tensor_name, ::tensorflow::Input |
636 | shape_and_slice, DataType dt, const RestoreSlice::Attrs& attrs); |
637 | operator ::tensorflow::Output() const { return tensor; } |
638 | operator ::tensorflow::Input() const { return tensor; } |
639 | ::tensorflow::Node* node() const { return tensor.node(); } |
640 | |
641 | static Attrs PreferredShard(int64 x) { |
642 | return Attrs().PreferredShard(x); |
643 | } |
644 | |
645 | Operation operation; |
646 | ::tensorflow::Output tensor; |
647 | }; |
648 | |
649 | /// Restores tensors from a V2 checkpoint. |
650 | /// |
651 | /// For backward compatibility with the V1 format, this Op currently allows |
652 | /// restoring from a V1 checkpoint as well: |
653 | /// - This Op first attempts to find the V2 index file pointed to by "prefix", and |
654 | /// if found proceed to read it as a V2 checkpoint; |
655 | /// - Otherwise the V1 read path is invoked. |
656 | /// Relying on this behavior is not recommended, as the ability to fall back to read |
657 | /// V1 might be deprecated and eventually removed. |
658 | /// |
659 | /// By default, restores the named tensors in full. If the caller wishes to restore |
660 | /// specific slices of stored tensors, "shape_and_slices" should be non-empty |
661 | /// strings and correspondingly well-formed. |
662 | /// |
663 | /// Callers must ensure all the named tensors are indeed stored in the checkpoint. |
664 | /// |
665 | /// Args: |
666 | /// * scope: A Scope object |
667 | /// * prefix: Must have a single element. The prefix of a V2 checkpoint. |
668 | /// * tensor_names: shape {N}. The names of the tensors to be restored. |
669 | /// * shape_and_slices: shape {N}. The slice specs of the tensors to be restored. |
670 | /// Empty strings indicate that they are non-partitioned tensors. |
671 | /// * dtypes: shape {N}. The list of expected dtype for the tensors. Must match |
672 | /// those stored in the checkpoint. |
673 | /// |
674 | /// Returns: |
675 | /// * `OutputList`: shape {N}. The restored tensors, whose shapes are read from the |
676 | /// checkpoint directly. |
677 | class RestoreV2 { |
678 | public: |
679 | RestoreV2(const ::tensorflow::Scope& scope, ::tensorflow::Input prefix, |
680 | ::tensorflow::Input tensor_names, ::tensorflow::Input |
681 | shape_and_slices, const DataTypeSlice& dtypes); |
682 | ::tensorflow::Output operator[](size_t index) const { return tensors[index]; } |
683 | |
684 | |
685 | Operation operation; |
686 | ::tensorflow::OutputList tensors; |
687 | }; |
688 | |
689 | /// Saves the input tensors to disk. |
690 | /// |
691 | /// The size of `tensor_names` must match the number of tensors in `data`. `data[i]` |
692 | /// is written to `filename` with name `tensor_names[i]`. |
693 | /// |
694 | /// See also `SaveSlices`. |
695 | /// |
696 | /// Args: |
697 | /// * scope: A Scope object |
698 | /// * filename: Must have a single element. The name of the file to which we write |
699 | /// the tensor. |
700 | /// * tensor_names: Shape `[N]`. The names of the tensors to be saved. |
701 | /// * data: `N` tensors to save. |
702 | /// |
703 | /// Returns: |
704 | /// * the created `Operation` |
705 | class Save { |
706 | public: |
707 | Save(const ::tensorflow::Scope& scope, ::tensorflow::Input filename, |
708 | ::tensorflow::Input tensor_names, ::tensorflow::InputList data); |
709 | operator ::tensorflow::Operation() const { return operation; } |
710 | |
711 | Operation operation; |
712 | }; |
713 | |
714 | /// Saves input tensors slices to disk. |
715 | /// |
716 | /// This is like `Save` except that tensors can be listed in the saved file as being |
717 | /// a slice of a larger tensor. `shapes_and_slices` specifies the shape of the |
718 | /// larger tensor and the slice that this tensor covers. `shapes_and_slices` must |
719 | /// have as many elements as `tensor_names`. |
720 | /// |
721 | /// Elements of the `shapes_and_slices` input must either be: |
722 | /// |
723 | /// * The empty string, in which case the corresponding tensor is |
724 | /// saved normally. |
725 | /// * A string of the form `dim0 dim1 ... dimN-1 slice-spec` where the |
726 | /// `dimI` are the dimensions of the larger tensor and `slice-spec` |
727 | /// specifies what part is covered by the tensor to save. |
728 | /// |
729 | /// `slice-spec` itself is a `:`-separated list: `slice0:slice1:...:sliceN-1` |
730 | /// where each `sliceI` is either: |
731 | /// |
732 | /// * The string `-` meaning that the slice covers all indices of this dimension |
733 | /// * `start,length` where `start` and `length` are integers. In that |
734 | /// case the slice covers `length` indices starting at `start`. |
735 | /// |
736 | /// See also `Save`. |
737 | /// |
738 | /// Args: |
739 | /// * scope: A Scope object |
740 | /// * filename: Must have a single element. The name of the file to which we write the |
741 | /// tensor. |
742 | /// * tensor_names: Shape `[N]`. The names of the tensors to be saved. |
743 | /// * shapes_and_slices: Shape `[N]`. The shapes and slice specifications to use when |
744 | /// saving the tensors. |
745 | /// * data: `N` tensors to save. |
746 | /// |
747 | /// Returns: |
748 | /// * the created `Operation` |
749 | class SaveSlices { |
750 | public: |
751 | SaveSlices(const ::tensorflow::Scope& scope, ::tensorflow::Input filename, |
752 | ::tensorflow::Input tensor_names, ::tensorflow::Input |
753 | shapes_and_slices, ::tensorflow::InputList data); |
754 | operator ::tensorflow::Operation() const { return operation; } |
755 | |
756 | Operation operation; |
757 | }; |
758 | |
759 | /// Saves tensors in V2 checkpoint format. |
760 | /// |
761 | /// By default, saves the named tensors in full. If the caller wishes to save |
762 | /// specific slices of full tensors, "shape_and_slices" should be non-empty strings |
763 | /// and correspondingly well-formed. |
764 | /// |
765 | /// Args: |
766 | /// * scope: A Scope object |
767 | /// * prefix: Must have a single element. The prefix of the V2 checkpoint to which we |
768 | /// write the tensors. |
769 | /// * tensor_names: shape {N}. The names of the tensors to be saved. |
770 | /// * shape_and_slices: shape {N}. The slice specs of the tensors to be saved. |
771 | /// Empty strings indicate that they are non-partitioned tensors. |
772 | /// * tensors: `N` tensors to save. |
773 | /// |
774 | /// Returns: |
775 | /// * the created `Operation` |
776 | class SaveV2 { |
777 | public: |
778 | SaveV2(const ::tensorflow::Scope& scope, ::tensorflow::Input prefix, |
779 | ::tensorflow::Input tensor_names, ::tensorflow::Input shape_and_slices, |
780 | ::tensorflow::InputList tensors); |
781 | operator ::tensorflow::Operation() const { return operation; } |
782 | |
783 | Operation operation; |
784 | }; |
785 | |
786 | /// Generate a sharded filename. The filename is printf formatted as |
787 | /// |
788 | /// %s-%05d-of-%05d, basename, shard, num_shards. |
789 | /// |
790 | /// Args: |
791 | /// * scope: A Scope object |
792 | /// |
793 | /// Returns: |
794 | /// * `Output`: The filename tensor. |
795 | class ShardedFilename { |
796 | public: |
797 | ShardedFilename(const ::tensorflow::Scope& scope, ::tensorflow::Input basename, |
798 | ::tensorflow::Input shard, ::tensorflow::Input num_shards); |
799 | operator ::tensorflow::Output() const { return filename; } |
800 | operator ::tensorflow::Input() const { return filename; } |
801 | ::tensorflow::Node* node() const { return filename.node(); } |
802 | |
803 | Operation operation; |
804 | ::tensorflow::Output filename; |
805 | }; |
806 | |
807 | /// Generate a glob pattern matching all sharded file names. |
808 | /// |
809 | /// Args: |
810 | /// * scope: A Scope object |
811 | /// |
812 | /// Returns: |
813 | /// * `Output`: The filename tensor. |
814 | class ShardedFilespec { |
815 | public: |
816 | ShardedFilespec(const ::tensorflow::Scope& scope, ::tensorflow::Input basename, |
817 | ::tensorflow::Input num_shards); |
818 | operator ::tensorflow::Output() const { return filename; } |
819 | operator ::tensorflow::Input() const { return filename; } |
820 | ::tensorflow::Node* node() const { return filename.node(); } |
821 | |
822 | Operation operation; |
823 | ::tensorflow::Output filename; |
824 | }; |
825 | |
826 | /// A Reader that outputs the records from a TensorFlow Records file. |
827 | /// |
828 | /// Args: |
829 | /// * scope: A Scope object |
830 | /// |
831 | /// Optional attributes (see `Attrs`): |
832 | /// * container: If non-empty, this reader is placed in the given container. |
833 | /// Otherwise, a default container is used. |
834 | /// * shared_name: If non-empty, this reader is named in the given bucket |
835 | /// with this shared_name. Otherwise, the node name is used instead. |
836 | /// |
837 | /// Returns: |
838 | /// * `Output`: The handle to reference the Reader. |
839 | class TFRecordReader { |
840 | public: |
841 | /// Optional attribute setters for TFRecordReader |
842 | struct Attrs { |
843 | /// If non-empty, this reader is placed in the given container. |
844 | /// Otherwise, a default container is used. |
845 | /// |
846 | /// Defaults to "" |
847 | TF_MUST_USE_RESULT Attrs Container(StringPiece x) { |
848 | Attrs ret = *this; |
849 | ret.container_ = x; |
850 | return ret; |
851 | } |
852 | |
853 | /// If non-empty, this reader is named in the given bucket |
854 | /// with this shared_name. Otherwise, the node name is used instead. |
855 | /// |
856 | /// Defaults to "" |
857 | TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) { |
858 | Attrs ret = *this; |
859 | ret.shared_name_ = x; |
860 | return ret; |
861 | } |
862 | |
863 | /// Defaults to "" |
864 | TF_MUST_USE_RESULT Attrs CompressionType(StringPiece x) { |
865 | Attrs ret = *this; |
866 | ret.compression_type_ = x; |
867 | return ret; |
868 | } |
869 | |
870 | StringPiece container_ = "" ; |
871 | StringPiece shared_name_ = "" ; |
872 | StringPiece compression_type_ = "" ; |
873 | }; |
874 | TFRecordReader(const ::tensorflow::Scope& scope); |
875 | TFRecordReader(const ::tensorflow::Scope& scope, const TFRecordReader::Attrs& |
876 | attrs); |
877 | operator ::tensorflow::Output() const { return reader_handle; } |
878 | operator ::tensorflow::Input() const { return reader_handle; } |
879 | ::tensorflow::Node* node() const { return reader_handle.node(); } |
880 | |
881 | static Attrs Container(StringPiece x) { |
882 | return Attrs().Container(x); |
883 | } |
884 | static Attrs SharedName(StringPiece x) { |
885 | return Attrs().SharedName(x); |
886 | } |
887 | static Attrs CompressionType(StringPiece x) { |
888 | return Attrs().CompressionType(x); |
889 | } |
890 | |
891 | Operation operation; |
892 | ::tensorflow::Output reader_handle; |
893 | }; |
894 | |
895 | /// A Reader that outputs the lines of a file delimited by '\n'. |
896 | /// |
897 | /// Args: |
898 | /// * scope: A Scope object |
899 | /// |
900 | /// Optional attributes (see `Attrs`): |
901 | /// * skip_header_lines: Number of lines to skip from the beginning of every file. |
902 | /// * container: If non-empty, this reader is placed in the given container. |
903 | /// Otherwise, a default container is used. |
904 | /// * shared_name: If non-empty, this reader is named in the given bucket |
905 | /// with this shared_name. Otherwise, the node name is used instead. |
906 | /// |
907 | /// Returns: |
908 | /// * `Output`: The handle to reference the Reader. |
909 | class TextLineReader { |
910 | public: |
911 | /// Optional attribute setters for TextLineReader |
912 | struct Attrs { |
913 | /// Number of lines to skip from the beginning of every file. |
914 | /// |
915 | /// Defaults to 0 |
916 | TF_MUST_USE_RESULT Attrs (int64 x) { |
917 | Attrs ret = *this; |
918 | ret.skip_header_lines_ = x; |
919 | return ret; |
920 | } |
921 | |
922 | /// If non-empty, this reader is placed in the given container. |
923 | /// Otherwise, a default container is used. |
924 | /// |
925 | /// Defaults to "" |
926 | TF_MUST_USE_RESULT Attrs Container(StringPiece x) { |
927 | Attrs ret = *this; |
928 | ret.container_ = x; |
929 | return ret; |
930 | } |
931 | |
932 | /// If non-empty, this reader is named in the given bucket |
933 | /// with this shared_name. Otherwise, the node name is used instead. |
934 | /// |
935 | /// Defaults to "" |
936 | TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) { |
937 | Attrs ret = *this; |
938 | ret.shared_name_ = x; |
939 | return ret; |
940 | } |
941 | |
942 | int64 = 0; |
943 | StringPiece container_ = "" ; |
944 | StringPiece shared_name_ = "" ; |
945 | }; |
946 | TextLineReader(const ::tensorflow::Scope& scope); |
947 | TextLineReader(const ::tensorflow::Scope& scope, const TextLineReader::Attrs& |
948 | attrs); |
949 | operator ::tensorflow::Output() const { return reader_handle; } |
950 | operator ::tensorflow::Input() const { return reader_handle; } |
951 | ::tensorflow::Node* node() const { return reader_handle.node(); } |
952 | |
953 | static Attrs (int64 x) { |
954 | return Attrs().SkipHeaderLines(x); |
955 | } |
956 | static Attrs Container(StringPiece x) { |
957 | return Attrs().Container(x); |
958 | } |
959 | static Attrs SharedName(StringPiece x) { |
960 | return Attrs().SharedName(x); |
961 | } |
962 | |
963 | Operation operation; |
964 | ::tensorflow::Output reader_handle; |
965 | }; |
966 | |
967 | /// A Reader that outputs the entire contents of a file as a value. |
968 | /// |
969 | /// To use, enqueue filenames in a Queue. The output of ReaderRead will |
970 | /// be a filename (key) and the contents of that file (value). |
971 | /// |
972 | /// Args: |
973 | /// * scope: A Scope object |
974 | /// |
975 | /// Optional attributes (see `Attrs`): |
976 | /// * container: If non-empty, this reader is placed in the given container. |
977 | /// Otherwise, a default container is used. |
978 | /// * shared_name: If non-empty, this reader is named in the given bucket |
979 | /// with this shared_name. Otherwise, the node name is used instead. |
980 | /// |
981 | /// Returns: |
982 | /// * `Output`: The handle to reference the Reader. |
983 | class WholeFileReader { |
984 | public: |
985 | /// Optional attribute setters for WholeFileReader |
986 | struct Attrs { |
987 | /// If non-empty, this reader is placed in the given container. |
988 | /// Otherwise, a default container is used. |
989 | /// |
990 | /// Defaults to "" |
991 | TF_MUST_USE_RESULT Attrs Container(StringPiece x) { |
992 | Attrs ret = *this; |
993 | ret.container_ = x; |
994 | return ret; |
995 | } |
996 | |
997 | /// If non-empty, this reader is named in the given bucket |
998 | /// with this shared_name. Otherwise, the node name is used instead. |
999 | /// |
1000 | /// Defaults to "" |
1001 | TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) { |
1002 | Attrs ret = *this; |
1003 | ret.shared_name_ = x; |
1004 | return ret; |
1005 | } |
1006 | |
1007 | StringPiece container_ = "" ; |
1008 | StringPiece shared_name_ = "" ; |
1009 | }; |
1010 | WholeFileReader(const ::tensorflow::Scope& scope); |
1011 | WholeFileReader(const ::tensorflow::Scope& scope, const WholeFileReader::Attrs& |
1012 | attrs); |
1013 | operator ::tensorflow::Output() const { return reader_handle; } |
1014 | operator ::tensorflow::Input() const { return reader_handle; } |
1015 | ::tensorflow::Node* node() const { return reader_handle.node(); } |
1016 | |
1017 | static Attrs Container(StringPiece x) { |
1018 | return Attrs().Container(x); |
1019 | } |
1020 | static Attrs SharedName(StringPiece x) { |
1021 | return Attrs().SharedName(x); |
1022 | } |
1023 | |
1024 | Operation operation; |
1025 | ::tensorflow::Output reader_handle; |
1026 | }; |
1027 | |
1028 | /// Writes `contents` to the file at input `filename`. |
1029 | /// |
1030 | /// Creates the file and recursively creates directory if it does not exist. |
1031 | /// |
1032 | /// Args: |
1033 | /// * scope: A Scope object |
1034 | /// * filename: scalar. The name of the file to which we write the contents. |
1035 | /// * contents: scalar. The content to be written to the output file. |
1036 | /// |
1037 | /// Returns: |
1038 | /// * the created `Operation` |
1039 | class WriteFile { |
1040 | public: |
1041 | WriteFile(const ::tensorflow::Scope& scope, ::tensorflow::Input filename, |
1042 | ::tensorflow::Input contents); |
1043 | operator ::tensorflow::Operation() const { return operation; } |
1044 | |
1045 | Operation operation; |
1046 | }; |
1047 | |
1048 | /// @} |
1049 | |
1050 | } // namespace ops |
1051 | } // namespace tensorflow |
1052 | |
1053 | #endif // TENSORFLOW_CC_OPS_IO_OPS_H_ |
1054 | |