1// This file is MACHINE GENERATED! Do not edit.
2
3#ifndef TENSORFLOW_CC_OPS_LOOKUP_OPS_H_
4#define TENSORFLOW_CC_OPS_LOOKUP_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 lookup_ops Lookup Ops
19/// @{
20
21/// Creates a non-initialized hash table.
22///
23/// This op creates a hash table, specifying the type of its keys and values.
24/// Before using the table you will have to initialize it. After initialization the
25/// table will be immutable.
26///
27/// Args:
28/// * scope: A Scope object
29/// * key_dtype: Type of the table keys.
30/// * value_dtype: Type of the table values.
31///
32/// Optional attributes (see `Attrs`):
33/// * container: If non-empty, this table is placed in the given container.
34/// Otherwise, a default container is used.
35/// * shared_name: If non-empty, this table is shared under the given name across
36/// multiple sessions.
37/// * use_node_name_sharing: If true and shared_name is empty, the table is shared
38/// using the node name.
39///
40/// Returns:
41/// * `Output`: Handle to a table.
42class HashTable {
43 public:
44 /// Optional attribute setters for HashTable
45 struct Attrs {
46 /// If non-empty, this table is placed in the given container.
47 /// Otherwise, a default container is used.
48 ///
49 /// Defaults to ""
50 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
51 Attrs ret = *this;
52 ret.container_ = x;
53 return ret;
54 }
55
56 /// If non-empty, this table is shared under the given name across
57 /// multiple sessions.
58 ///
59 /// Defaults to ""
60 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
61 Attrs ret = *this;
62 ret.shared_name_ = x;
63 return ret;
64 }
65
66 /// If true and shared_name is empty, the table is shared
67 /// using the node name.
68 ///
69 /// Defaults to false
70 TF_MUST_USE_RESULT Attrs UseNodeNameSharing(bool x) {
71 Attrs ret = *this;
72 ret.use_node_name_sharing_ = x;
73 return ret;
74 }
75
76 StringPiece container_ = "";
77 StringPiece shared_name_ = "";
78 bool use_node_name_sharing_ = false;
79 };
80 HashTable(const ::tensorflow::Scope& scope, DataType key_dtype, DataType
81 value_dtype);
82 HashTable(const ::tensorflow::Scope& scope, DataType key_dtype, DataType
83 value_dtype, const HashTable::Attrs& attrs);
84 operator ::tensorflow::Output() const { return table_handle; }
85 operator ::tensorflow::Input() const { return table_handle; }
86 ::tensorflow::Node* node() const { return table_handle.node(); }
87
88 static Attrs Container(StringPiece x) {
89 return Attrs().Container(x);
90 }
91 static Attrs SharedName(StringPiece x) {
92 return Attrs().SharedName(x);
93 }
94 static Attrs UseNodeNameSharing(bool x) {
95 return Attrs().UseNodeNameSharing(x);
96 }
97
98 Operation operation;
99 ::tensorflow::Output table_handle;
100};
101
102/// Initializes a table from a text file.
103///
104/// It inserts one key-value pair into the table for each line of the file.
105/// The key and value is extracted from the whole line content, elements from the
106/// split line based on `delimiter` or the line number (starting from zero).
107/// Where to extract the key and value from a line is specified by `key_index` and
108/// `value_index`.
109///
110/// - A value of -1 means use the line number(starting from zero), expects `int64`.
111/// - A value of -2 means use the whole line content, expects `string`.
112/// - A value >= 0 means use the index (starting at zero) of the split line based
113/// on `delimiter`.
114///
115/// Args:
116/// * scope: A Scope object
117/// * table_handle: Handle to a table which will be initialized.
118/// * filename: Filename of a vocabulary text file.
119/// * key_index: Column index in a line to get the table `key` values from.
120/// * value_index: Column index that represents information of a line to get the table
121/// `value` values from.
122///
123/// Optional attributes (see `Attrs`):
124/// * vocab_size: Number of elements of the file, use -1 if unknown.
125/// * delimiter: Delimiter to separate fields in a line.
126///
127/// Returns:
128/// * the created `Operation`
129class InitializeTableFromTextFile {
130 public:
131 /// Optional attribute setters for InitializeTableFromTextFile
132 struct Attrs {
133 /// Number of elements of the file, use -1 if unknown.
134 ///
135 /// Defaults to -1
136 TF_MUST_USE_RESULT Attrs VocabSize(int64 x) {
137 Attrs ret = *this;
138 ret.vocab_size_ = x;
139 return ret;
140 }
141
142 /// Delimiter to separate fields in a line.
143 ///
144 /// Defaults to "\t"
145 TF_MUST_USE_RESULT Attrs Delimiter(StringPiece x) {
146 Attrs ret = *this;
147 ret.delimiter_ = x;
148 return ret;
149 }
150
151 /// Defaults to 0
152 TF_MUST_USE_RESULT Attrs Offset(int64 x) {
153 Attrs ret = *this;
154 ret.offset_ = x;
155 return ret;
156 }
157
158 int64 vocab_size_ = -1;
159 StringPiece delimiter_ = "\t";
160 int64 offset_ = 0;
161 };
162 InitializeTableFromTextFile(const ::tensorflow::Scope& scope,
163 ::tensorflow::Input table_handle,
164 ::tensorflow::Input filename, int64 key_index,
165 int64 value_index);
166 InitializeTableFromTextFile(const ::tensorflow::Scope& scope,
167 ::tensorflow::Input table_handle,
168 ::tensorflow::Input filename, int64 key_index,
169 int64 value_index, const
170 InitializeTableFromTextFile::Attrs& attrs);
171 operator ::tensorflow::Operation() const { return operation; }
172
173 static Attrs VocabSize(int64 x) {
174 return Attrs().VocabSize(x);
175 }
176 static Attrs Delimiter(StringPiece x) {
177 return Attrs().Delimiter(x);
178 }
179 static Attrs Offset(int64 x) {
180 return Attrs().Offset(x);
181 }
182
183 Operation operation;
184};
185
186/// Table initializer that takes two tensors for keys and values respectively.
187///
188/// Args:
189/// * scope: A Scope object
190/// * table_handle: Handle to a table which will be initialized.
191/// * keys: Keys of type Tkey.
192/// * values: Values of type Tval.
193///
194/// Returns:
195/// * the created `Operation`
196class InitializeTable {
197 public:
198 InitializeTable(const ::tensorflow::Scope& scope, ::tensorflow::Input
199 table_handle, ::tensorflow::Input keys, ::tensorflow::Input
200 values);
201 operator ::tensorflow::Operation() const { return operation; }
202
203 Operation operation;
204};
205
206/// Outputs all keys and values in the table.
207///
208/// Args:
209/// * scope: A Scope object
210/// * table_handle: Handle to the table.
211///
212/// Returns:
213/// * `Output` keys: Vector of all keys present in the table.
214/// * `Output` values: Tensor of all values in the table. Indexed in parallel with `keys`.
215class LookupTableExport {
216 public:
217 LookupTableExport(const ::tensorflow::Scope& scope, ::tensorflow::Input
218 table_handle, DataType Tkeys, DataType Tvalues);
219
220 Operation operation;
221 ::tensorflow::Output keys;
222 ::tensorflow::Output values;
223};
224
225/// Looks up keys in a table, outputs the corresponding values.
226///
227/// The tensor `keys` must of the same type as the keys of the table.
228/// The output `values` is of the type of the table values.
229///
230/// The scalar `default_value` is the value output for keys not present in the
231/// table. It must also be of the same type as the table values.
232///
233/// Args:
234/// * scope: A Scope object
235/// * table_handle: Handle to the table.
236/// * keys: Any shape. Keys to look up.
237///
238/// Returns:
239/// * `Output`: Same shape as `keys`. Values found in the table, or `default_values`
240/// for missing keys.
241class LookupTableFind {
242 public:
243 LookupTableFind(const ::tensorflow::Scope& scope, ::tensorflow::Input
244 table_handle, ::tensorflow::Input keys, ::tensorflow::Input
245 default_value);
246 operator ::tensorflow::Output() const { return values; }
247 operator ::tensorflow::Input() const { return values; }
248 ::tensorflow::Node* node() const { return values.node(); }
249
250 Operation operation;
251 ::tensorflow::Output values;
252};
253
254/// Replaces the contents of the table with the specified keys and values.
255///
256/// The tensor `keys` must be of the same type as the keys of the table.
257/// The tensor `values` must be of the type of the table values.
258///
259/// Args:
260/// * scope: A Scope object
261/// * table_handle: Handle to the table.
262/// * keys: Any shape. Keys to look up.
263/// * values: Values to associate with keys.
264///
265/// Returns:
266/// * the created `Operation`
267class LookupTableImport {
268 public:
269 LookupTableImport(const ::tensorflow::Scope& scope, ::tensorflow::Input
270 table_handle, ::tensorflow::Input keys, ::tensorflow::Input
271 values);
272 operator ::tensorflow::Operation() const { return operation; }
273
274 Operation operation;
275};
276
277/// Updates the table to associates keys with values.
278///
279/// The tensor `keys` must be of the same type as the keys of the table.
280/// The tensor `values` must be of the type of the table values.
281///
282/// Args:
283/// * scope: A Scope object
284/// * table_handle: Handle to the table.
285/// * keys: Any shape. Keys to look up.
286/// * values: Values to associate with keys.
287///
288/// Returns:
289/// * the created `Operation`
290class LookupTableInsert {
291 public:
292 LookupTableInsert(const ::tensorflow::Scope& scope, ::tensorflow::Input
293 table_handle, ::tensorflow::Input keys, ::tensorflow::Input
294 values);
295 operator ::tensorflow::Operation() const { return operation; }
296
297 Operation operation;
298};
299
300/// Computes the number of elements in the given table.
301///
302/// Args:
303/// * scope: A Scope object
304/// * table_handle: Handle to the table.
305///
306/// Returns:
307/// * `Output`: Scalar that contains number of elements in the table.
308class LookupTableSize {
309 public:
310 LookupTableSize(const ::tensorflow::Scope& scope, ::tensorflow::Input
311 table_handle);
312 operator ::tensorflow::Output() const { return size; }
313 operator ::tensorflow::Input() const { return size; }
314 ::tensorflow::Node* node() const { return size.node(); }
315
316 Operation operation;
317 ::tensorflow::Output size;
318};
319
320/// Creates an empty hash table that uses tensors as the backing store.
321///
322/// It uses "open addressing" with quadratic reprobing to resolve
323/// collisions.
324///
325/// This op creates a mutable hash table, specifying the type of its keys and
326/// values. Each value must be a scalar. Data can be inserted into the table using
327/// the insert operations. It does not support the initialization operation.
328///
329/// Args:
330/// * scope: A Scope object
331/// * empty_key: The key used to represent empty key buckets internally. Must not
332/// be used in insert or lookup operations.
333/// * value_dtype: Type of the table values.
334///
335/// Optional attributes (see `Attrs`):
336/// * container: If non-empty, this table is placed in the given container.
337/// Otherwise, a default container is used.
338/// * shared_name: If non-empty, this table is shared under the given name across
339/// multiple sessions.
340/// * value_shape: The shape of each value.
341/// * initial_num_buckets: The initial number of hash table buckets. Must be a power
342/// to 2.
343/// * max_load_factor: The maximum ratio between number of entries and number of
344/// buckets before growing the table. Must be between 0 and 1.
345///
346/// Returns:
347/// * `Output`: Handle to a table.
348class MutableDenseHashTable {
349 public:
350 /// Optional attribute setters for MutableDenseHashTable
351 struct Attrs {
352 /// If non-empty, this table is placed in the given container.
353 /// Otherwise, a default container is used.
354 ///
355 /// Defaults to ""
356 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
357 Attrs ret = *this;
358 ret.container_ = x;
359 return ret;
360 }
361
362 /// If non-empty, this table is shared under the given name across
363 /// multiple sessions.
364 ///
365 /// Defaults to ""
366 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
367 Attrs ret = *this;
368 ret.shared_name_ = x;
369 return ret;
370 }
371
372 /// Defaults to false
373 TF_MUST_USE_RESULT Attrs UseNodeNameSharing(bool x) {
374 Attrs ret = *this;
375 ret.use_node_name_sharing_ = x;
376 return ret;
377 }
378
379 /// The shape of each value.
380 ///
381 /// Defaults to []
382 TF_MUST_USE_RESULT Attrs ValueShape(PartialTensorShape x) {
383 Attrs ret = *this;
384 ret.value_shape_ = x;
385 return ret;
386 }
387
388 /// The initial number of hash table buckets. Must be a power
389 /// to 2.
390 ///
391 /// Defaults to 131072
392 TF_MUST_USE_RESULT Attrs InitialNumBuckets(int64 x) {
393 Attrs ret = *this;
394 ret.initial_num_buckets_ = x;
395 return ret;
396 }
397
398 /// The maximum ratio between number of entries and number of
399 /// buckets before growing the table. Must be between 0 and 1.
400 ///
401 /// Defaults to 0.8
402 TF_MUST_USE_RESULT Attrs MaxLoadFactor(float x) {
403 Attrs ret = *this;
404 ret.max_load_factor_ = x;
405 return ret;
406 }
407
408 StringPiece container_ = "";
409 StringPiece shared_name_ = "";
410 bool use_node_name_sharing_ = false;
411 PartialTensorShape value_shape_ = {};
412 int64 initial_num_buckets_ = 131072;
413 float max_load_factor_ = 0.8f;
414 };
415 MutableDenseHashTable(const ::tensorflow::Scope& scope, ::tensorflow::Input
416 empty_key, ::tensorflow::Input deleted_key, DataType
417 value_dtype);
418 MutableDenseHashTable(const ::tensorflow::Scope& scope, ::tensorflow::Input
419 empty_key, ::tensorflow::Input deleted_key, DataType
420 value_dtype, const MutableDenseHashTable::Attrs& attrs);
421 operator ::tensorflow::Output() const { return table_handle; }
422 operator ::tensorflow::Input() const { return table_handle; }
423 ::tensorflow::Node* node() const { return table_handle.node(); }
424
425 static Attrs Container(StringPiece x) {
426 return Attrs().Container(x);
427 }
428 static Attrs SharedName(StringPiece x) {
429 return Attrs().SharedName(x);
430 }
431 static Attrs UseNodeNameSharing(bool x) {
432 return Attrs().UseNodeNameSharing(x);
433 }
434 static Attrs ValueShape(PartialTensorShape x) {
435 return Attrs().ValueShape(x);
436 }
437 static Attrs InitialNumBuckets(int64 x) {
438 return Attrs().InitialNumBuckets(x);
439 }
440 static Attrs MaxLoadFactor(float x) {
441 return Attrs().MaxLoadFactor(x);
442 }
443
444 Operation operation;
445 ::tensorflow::Output table_handle;
446};
447
448/// Creates an empty hash table.
449///
450/// This op creates a mutable hash table, specifying the type of its keys and
451/// values. Each value must be a vector. Data can be inserted into the table using
452/// the insert operations. It does not support the initialization operation.
453///
454/// Args:
455/// * scope: A Scope object
456/// * key_dtype: Type of the table keys.
457/// * value_dtype: Type of the table values.
458///
459/// Optional attributes (see `Attrs`):
460/// * container: If non-empty, this table is placed in the given container.
461/// Otherwise, a default container is used.
462/// * shared_name: If non-empty, this table is shared under the given name across
463/// multiple sessions.
464///
465/// Returns:
466/// * `Output`: Handle to a table.
467class MutableHashTableOfTensors {
468 public:
469 /// Optional attribute setters for MutableHashTableOfTensors
470 struct Attrs {
471 /// If non-empty, this table is placed in the given container.
472 /// Otherwise, a default container is used.
473 ///
474 /// Defaults to ""
475 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
476 Attrs ret = *this;
477 ret.container_ = x;
478 return ret;
479 }
480
481 /// If non-empty, this table is shared under the given name across
482 /// multiple sessions.
483 ///
484 /// Defaults to ""
485 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
486 Attrs ret = *this;
487 ret.shared_name_ = x;
488 return ret;
489 }
490
491 /// Defaults to false
492 TF_MUST_USE_RESULT Attrs UseNodeNameSharing(bool x) {
493 Attrs ret = *this;
494 ret.use_node_name_sharing_ = x;
495 return ret;
496 }
497
498 /// Defaults to []
499 TF_MUST_USE_RESULT Attrs ValueShape(PartialTensorShape x) {
500 Attrs ret = *this;
501 ret.value_shape_ = x;
502 return ret;
503 }
504
505 StringPiece container_ = "";
506 StringPiece shared_name_ = "";
507 bool use_node_name_sharing_ = false;
508 PartialTensorShape value_shape_ = {};
509 };
510 MutableHashTableOfTensors(const ::tensorflow::Scope& scope, DataType key_dtype,
511 DataType value_dtype);
512 MutableHashTableOfTensors(const ::tensorflow::Scope& scope, DataType key_dtype,
513 DataType value_dtype, const
514 MutableHashTableOfTensors::Attrs& attrs);
515 operator ::tensorflow::Output() const { return table_handle; }
516 operator ::tensorflow::Input() const { return table_handle; }
517 ::tensorflow::Node* node() const { return table_handle.node(); }
518
519 static Attrs Container(StringPiece x) {
520 return Attrs().Container(x);
521 }
522 static Attrs SharedName(StringPiece x) {
523 return Attrs().SharedName(x);
524 }
525 static Attrs UseNodeNameSharing(bool x) {
526 return Attrs().UseNodeNameSharing(x);
527 }
528 static Attrs ValueShape(PartialTensorShape x) {
529 return Attrs().ValueShape(x);
530 }
531
532 Operation operation;
533 ::tensorflow::Output table_handle;
534};
535
536/// Creates an empty hash table.
537///
538/// This op creates a mutable hash table, specifying the type of its keys and
539/// values. Each value must be a scalar. Data can be inserted into the table using
540/// the insert operations. It does not support the initialization operation.
541///
542/// Args:
543/// * scope: A Scope object
544/// * key_dtype: Type of the table keys.
545/// * value_dtype: Type of the table values.
546///
547/// Optional attributes (see `Attrs`):
548/// * container: If non-empty, this table is placed in the given container.
549/// Otherwise, a default container is used.
550/// * shared_name: If non-empty, this table is shared under the given name across
551/// multiple sessions.
552/// * use_node_name_sharing: If true and shared_name is empty, the table is shared
553/// using the node name.
554///
555/// Returns:
556/// * `Output`: Handle to a table.
557class MutableHashTable {
558 public:
559 /// Optional attribute setters for MutableHashTable
560 struct Attrs {
561 /// If non-empty, this table is placed in the given container.
562 /// Otherwise, a default container is used.
563 ///
564 /// Defaults to ""
565 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
566 Attrs ret = *this;
567 ret.container_ = x;
568 return ret;
569 }
570
571 /// If non-empty, this table is shared under the given name across
572 /// multiple sessions.
573 ///
574 /// Defaults to ""
575 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
576 Attrs ret = *this;
577 ret.shared_name_ = x;
578 return ret;
579 }
580
581 /// If true and shared_name is empty, the table is shared
582 /// using the node name.
583 ///
584 /// Defaults to false
585 TF_MUST_USE_RESULT Attrs UseNodeNameSharing(bool x) {
586 Attrs ret = *this;
587 ret.use_node_name_sharing_ = x;
588 return ret;
589 }
590
591 StringPiece container_ = "";
592 StringPiece shared_name_ = "";
593 bool use_node_name_sharing_ = false;
594 };
595 MutableHashTable(const ::tensorflow::Scope& scope, DataType key_dtype, DataType
596 value_dtype);
597 MutableHashTable(const ::tensorflow::Scope& scope, DataType key_dtype, DataType
598 value_dtype, const MutableHashTable::Attrs& attrs);
599 operator ::tensorflow::Output() const { return table_handle; }
600 operator ::tensorflow::Input() const { return table_handle; }
601 ::tensorflow::Node* node() const { return table_handle.node(); }
602
603 static Attrs Container(StringPiece x) {
604 return Attrs().Container(x);
605 }
606 static Attrs SharedName(StringPiece x) {
607 return Attrs().SharedName(x);
608 }
609 static Attrs UseNodeNameSharing(bool x) {
610 return Attrs().UseNodeNameSharing(x);
611 }
612
613 Operation operation;
614 ::tensorflow::Output table_handle;
615};
616
617/// @}
618
619} // namespace ops
620} // namespace tensorflow
621
622#endif // TENSORFLOW_CC_OPS_LOOKUP_OPS_H_
623