1// This file is MACHINE GENERATED! Do not edit.
2
3#ifndef TENSORFLOW_CC_OPS_SPARSE_OPS_H_
4#define TENSORFLOW_CC_OPS_SPARSE_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 sparse_ops Sparse Ops
19/// @{
20
21/// Add an `N`-minibatch `SparseTensor` to a `SparseTensorsMap`, return `N` handles.
22///
23/// A `SparseTensor` of rank `R` is represented by three tensors: `sparse_indices`,
24/// `sparse_values`, and `sparse_shape`, where
25///
26/// ```sparse_indices.shape[1] == sparse_shape.shape[0] == R```
27///
28/// An `N`-minibatch of `SparseTensor` objects is represented as a `SparseTensor`
29/// having a first `sparse_indices` column taking values between `[0, N)`, where
30/// the minibatch size `N == sparse_shape[0]`.
31///
32/// The input `SparseTensor` must have rank `R` greater than 1, and the first
33/// dimension is treated as the minibatch dimension. Elements of the `SparseTensor`
34/// must be sorted in increasing order of this first dimension. The stored
35/// `SparseTensor` objects pointed to by each row of the output `sparse_handles`
36/// will have rank `R-1`.
37///
38/// The `SparseTensor` values can then be read out as part of a minibatch by passing
39/// the given keys as vector elements to `TakeManySparseFromTensorsMap`. To ensure
40/// the correct `SparseTensorsMap` is accessed, ensure that the same
41/// `container` and `shared_name` are passed to that Op. If no `shared_name`
42/// is provided here, instead use the *name* of the Operation created by calling
43/// `AddManySparseToTensorsMap` as the `shared_name` passed to
44/// `TakeManySparseFromTensorsMap`. Ensure the Operations are colocated.
45///
46/// Args:
47/// * scope: A Scope object
48/// * sparse_indices: 2-D. The `indices` of the minibatch `SparseTensor`.
49/// `sparse_indices[:, 0]` must be ordered values in `[0, N)`.
50/// * sparse_values: 1-D. The `values` of the minibatch `SparseTensor`.
51/// * sparse_shape: 1-D. The `shape` of the minibatch `SparseTensor`.
52/// The minibatch size `N == sparse_shape[0]`.
53///
54/// Optional attributes (see `Attrs`):
55/// * container: The container name for the `SparseTensorsMap` created by this op.
56/// * shared_name: The shared name for the `SparseTensorsMap` created by this op.
57/// If blank, the new Operation's unique name is used.
58///
59/// Returns:
60/// * `Output`: 1-D. The handles of the `SparseTensor` now stored in the
61/// `SparseTensorsMap`. Shape: `[N]`.
62class AddManySparseToTensorsMap {
63 public:
64 /// Optional attribute setters for AddManySparseToTensorsMap
65 struct Attrs {
66 /// The container name for the `SparseTensorsMap` created by this op.
67 ///
68 /// Defaults to ""
69 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
70 Attrs ret = *this;
71 ret.container_ = x;
72 return ret;
73 }
74
75 /// The shared name for the `SparseTensorsMap` created by this op.
76 /// If blank, the new Operation's unique name is used.
77 ///
78 /// Defaults to ""
79 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
80 Attrs ret = *this;
81 ret.shared_name_ = x;
82 return ret;
83 }
84
85 StringPiece container_ = "";
86 StringPiece shared_name_ = "";
87 };
88 AddManySparseToTensorsMap(const ::tensorflow::Scope& scope, ::tensorflow::Input
89 sparse_indices, ::tensorflow::Input sparse_values,
90 ::tensorflow::Input sparse_shape);
91 AddManySparseToTensorsMap(const ::tensorflow::Scope& scope, ::tensorflow::Input
92 sparse_indices, ::tensorflow::Input sparse_values,
93 ::tensorflow::Input sparse_shape, const
94 AddManySparseToTensorsMap::Attrs& attrs);
95 operator ::tensorflow::Output() const { return sparse_handles; }
96 operator ::tensorflow::Input() const { return sparse_handles; }
97 ::tensorflow::Node* node() const { return sparse_handles.node(); }
98
99 static Attrs Container(StringPiece x) {
100 return Attrs().Container(x);
101 }
102 static Attrs SharedName(StringPiece x) {
103 return Attrs().SharedName(x);
104 }
105
106 Operation operation;
107 ::tensorflow::Output sparse_handles;
108};
109
110/// Add a `SparseTensor` to a `SparseTensorsMap` return its handle.
111///
112/// A `SparseTensor` is represented by three tensors: `sparse_indices`,
113/// `sparse_values`, and `sparse_shape`.
114///
115/// This operator takes the given `SparseTensor` and adds it to a container
116/// object (a `SparseTensorsMap`). A unique key within this container is generated
117/// in the form of an `int64`, and this is the value that is returned.
118///
119/// The `SparseTensor` can then be read out as part of a minibatch by passing
120/// the key as a vector element to `TakeManySparseFromTensorsMap`. To ensure
121/// the correct `SparseTensorsMap` is accessed, ensure that the same
122/// `container` and `shared_name` are passed to that Op. If no `shared_name`
123/// is provided here, instead use the *name* of the Operation created by calling
124/// `AddSparseToTensorsMap` as the `shared_name` passed to
125/// `TakeManySparseFromTensorsMap`. Ensure the Operations are colocated.
126///
127/// Args:
128/// * scope: A Scope object
129/// * sparse_indices: 2-D. The `indices` of the `SparseTensor`.
130/// * sparse_values: 1-D. The `values` of the `SparseTensor`.
131/// * sparse_shape: 1-D. The `shape` of the `SparseTensor`.
132///
133/// Optional attributes (see `Attrs`):
134/// * container: The container name for the `SparseTensorsMap` created by this op.
135/// * shared_name: The shared name for the `SparseTensorsMap` created by this op.
136/// If blank, the new Operation's unique name is used.
137///
138/// Returns:
139/// * `Output`: 0-D. The handle of the `SparseTensor` now stored in the
140/// `SparseTensorsMap`.
141class AddSparseToTensorsMap {
142 public:
143 /// Optional attribute setters for AddSparseToTensorsMap
144 struct Attrs {
145 /// The container name for the `SparseTensorsMap` created by this op.
146 ///
147 /// Defaults to ""
148 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
149 Attrs ret = *this;
150 ret.container_ = x;
151 return ret;
152 }
153
154 /// The shared name for the `SparseTensorsMap` created by this op.
155 /// If blank, the new Operation's unique name is used.
156 ///
157 /// Defaults to ""
158 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
159 Attrs ret = *this;
160 ret.shared_name_ = x;
161 return ret;
162 }
163
164 StringPiece container_ = "";
165 StringPiece shared_name_ = "";
166 };
167 AddSparseToTensorsMap(const ::tensorflow::Scope& scope, ::tensorflow::Input
168 sparse_indices, ::tensorflow::Input sparse_values,
169 ::tensorflow::Input sparse_shape);
170 AddSparseToTensorsMap(const ::tensorflow::Scope& scope, ::tensorflow::Input
171 sparse_indices, ::tensorflow::Input sparse_values,
172 ::tensorflow::Input sparse_shape, const
173 AddSparseToTensorsMap::Attrs& attrs);
174 operator ::tensorflow::Output() const { return sparse_handle; }
175 operator ::tensorflow::Input() const { return sparse_handle; }
176 ::tensorflow::Node* node() const { return sparse_handle.node(); }
177
178 static Attrs Container(StringPiece x) {
179 return Attrs().Container(x);
180 }
181 static Attrs SharedName(StringPiece x) {
182 return Attrs().SharedName(x);
183 }
184
185 Operation operation;
186 ::tensorflow::Output sparse_handle;
187};
188
189/// Deserialize and concatenate `SparseTensors` from a serialized minibatch.
190///
191/// The input `serialized_sparse` must be a string matrix of shape `[N x 3]` where
192/// `N` is the minibatch size and the rows correspond to packed outputs of
193/// `SerializeSparse`. The ranks of the original `SparseTensor` objects
194/// must all match. When the final `SparseTensor` is created, it has rank one
195/// higher than the ranks of the incoming `SparseTensor` objects
196/// (they have been concatenated along a new row dimension).
197///
198/// The output `SparseTensor` object's shape values for all dimensions but the
199/// first are the max across the input `SparseTensor` objects' shape values
200/// for the corresponding dimensions. Its first shape value is `N`, the minibatch
201/// size.
202///
203/// The input `SparseTensor` objects' indices are assumed ordered in
204/// standard lexicographic order. If this is not the case, after this
205/// step run `SparseReorder` to restore index ordering.
206///
207/// For example, if the serialized input is a `[2 x 3]` matrix representing two
208/// original `SparseTensor` objects:
209///
210/// index = [ 0]
211/// [10]
212/// [20]
213/// values = [1, 2, 3]
214/// shape = [50]
215///
216/// and
217///
218/// index = [ 2]
219/// [10]
220/// values = [4, 5]
221/// shape = [30]
222///
223/// then the final deserialized `SparseTensor` will be:
224///
225/// index = [0 0]
226/// [0 10]
227/// [0 20]
228/// [1 2]
229/// [1 10]
230/// values = [1, 2, 3, 4, 5]
231/// shape = [2 50]
232///
233/// Args:
234/// * scope: A Scope object
235/// * serialized_sparse: 2-D, The `N` serialized `SparseTensor` objects.
236/// Must have 3 columns.
237/// * dtype: The `dtype` of the serialized `SparseTensor` objects.
238///
239/// Returns:
240/// * `Output` sparse_indices
241/// * `Output` sparse_values
242/// * `Output` sparse_shape
243class DeserializeManySparse {
244 public:
245 DeserializeManySparse(const ::tensorflow::Scope& scope, ::tensorflow::Input
246 serialized_sparse, DataType dtype);
247
248 Operation operation;
249 ::tensorflow::Output sparse_indices;
250 ::tensorflow::Output sparse_values;
251 ::tensorflow::Output sparse_shape;
252};
253
254/// Deserialize `SparseTensor` objects.
255///
256/// The input `serialized_sparse` must have the shape `[?, ?, ..., ?, 3]` where
257/// the last dimension stores serialized `SparseTensor` objects and the other N
258/// dimensions (N >= 0) correspond to a batch. The ranks of the original
259/// `SparseTensor` objects must all match. When the final `SparseTensor` is
260/// created, its rank is the rank of the incoming `SparseTensor` objects plus N;
261/// the sparse tensors have been concatenated along new dimensions, one for each
262/// batch.
263///
264/// The output `SparseTensor` object's shape values for the original dimensions
265/// are the max across the input `SparseTensor` objects' shape values for the
266/// corresponding dimensions. The new dimensions match the size of the batch.
267///
268/// The input `SparseTensor` objects' indices are assumed ordered in
269/// standard lexicographic order. If this is not the case, after this
270/// step run `SparseReorder` to restore index ordering.
271///
272/// For example, if the serialized input is a `[2 x 3]` matrix representing two
273/// original `SparseTensor` objects:
274///
275/// index = [ 0]
276/// [10]
277/// [20]
278/// values = [1, 2, 3]
279/// shape = [50]
280///
281/// and
282///
283/// index = [ 2]
284/// [10]
285/// values = [4, 5]
286/// shape = [30]
287///
288/// then the final deserialized `SparseTensor` will be:
289///
290/// index = [0 0]
291/// [0 10]
292/// [0 20]
293/// [1 2]
294/// [1 10]
295/// values = [1, 2, 3, 4, 5]
296/// shape = [2 50]
297///
298/// Args:
299/// * scope: A Scope object
300/// * serialized_sparse: The serialized `SparseTensor` objects. The last dimension
301/// must have 3 columns.
302/// * dtype: The `dtype` of the serialized `SparseTensor` objects.
303///
304/// Returns:
305/// * `Output` sparse_indices
306/// * `Output` sparse_values
307/// * `Output` sparse_shape
308class DeserializeSparse {
309 public:
310 DeserializeSparse(const ::tensorflow::Scope& scope, ::tensorflow::Input
311 serialized_sparse, DataType dtype);
312
313 Operation operation;
314 ::tensorflow::Output sparse_indices;
315 ::tensorflow::Output sparse_values;
316 ::tensorflow::Output sparse_shape;
317};
318
319/// Serialize an `N`-minibatch `SparseTensor` into an `[N, 3]` `Tensor` object.
320///
321/// The `SparseTensor` must have rank `R` greater than 1, and the first dimension
322/// is treated as the minibatch dimension. Elements of the `SparseTensor`
323/// must be sorted in increasing order of this first dimension. The serialized
324/// `SparseTensor` objects going into each row of `serialized_sparse` will have
325/// rank `R-1`.
326///
327/// The minibatch size `N` is extracted from `sparse_shape[0]`.
328///
329/// Args:
330/// * scope: A Scope object
331/// * sparse_indices: 2-D. The `indices` of the minibatch `SparseTensor`.
332/// * sparse_values: 1-D. The `values` of the minibatch `SparseTensor`.
333/// * sparse_shape: 1-D. The `shape` of the minibatch `SparseTensor`.
334///
335/// Optional attributes (see `Attrs`):
336/// * out_type: The `dtype` to use for serialization; the supported types are `string`
337/// (default) and `variant`.
338///
339/// Returns:
340/// * `Output`: The serialized_sparse tensor.
341class SerializeManySparse {
342 public:
343 /// Optional attribute setters for SerializeManySparse
344 struct Attrs {
345 /// The `dtype` to use for serialization; the supported types are `string`
346 /// (default) and `variant`.
347 ///
348 /// Defaults to DT_STRING
349 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
350 Attrs ret = *this;
351 ret.out_type_ = x;
352 return ret;
353 }
354
355 DataType out_type_ = DT_STRING;
356 };
357 SerializeManySparse(const ::tensorflow::Scope& scope, ::tensorflow::Input
358 sparse_indices, ::tensorflow::Input sparse_values,
359 ::tensorflow::Input sparse_shape);
360 SerializeManySparse(const ::tensorflow::Scope& scope, ::tensorflow::Input
361 sparse_indices, ::tensorflow::Input sparse_values,
362 ::tensorflow::Input sparse_shape, const
363 SerializeManySparse::Attrs& attrs);
364 operator ::tensorflow::Output() const { return serialized_sparse; }
365 operator ::tensorflow::Input() const { return serialized_sparse; }
366 ::tensorflow::Node* node() const { return serialized_sparse.node(); }
367
368 static Attrs OutType(DataType x) {
369 return Attrs().OutType(x);
370 }
371
372 Operation operation;
373 ::tensorflow::Output serialized_sparse;
374};
375
376/// Serialize a `SparseTensor` into a `[3]` `Tensor` object.
377///
378/// Args:
379/// * scope: A Scope object
380/// * sparse_indices: 2-D. The `indices` of the `SparseTensor`.
381/// * sparse_values: 1-D. The `values` of the `SparseTensor`.
382/// * sparse_shape: 1-D. The `shape` of the `SparseTensor`.
383///
384/// Optional attributes (see `Attrs`):
385/// * out_type: The `dtype` to use for serialization; the supported types are `string`
386/// (default) and `variant`.
387///
388/// Returns:
389/// * `Output`: The serialized_sparse tensor.
390class SerializeSparse {
391 public:
392 /// Optional attribute setters for SerializeSparse
393 struct Attrs {
394 /// The `dtype` to use for serialization; the supported types are `string`
395 /// (default) and `variant`.
396 ///
397 /// Defaults to DT_STRING
398 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
399 Attrs ret = *this;
400 ret.out_type_ = x;
401 return ret;
402 }
403
404 DataType out_type_ = DT_STRING;
405 };
406 SerializeSparse(const ::tensorflow::Scope& scope, ::tensorflow::Input
407 sparse_indices, ::tensorflow::Input sparse_values,
408 ::tensorflow::Input sparse_shape);
409 SerializeSparse(const ::tensorflow::Scope& scope, ::tensorflow::Input
410 sparse_indices, ::tensorflow::Input sparse_values,
411 ::tensorflow::Input sparse_shape, const SerializeSparse::Attrs&
412 attrs);
413 operator ::tensorflow::Output() const { return serialized_sparse; }
414 operator ::tensorflow::Input() const { return serialized_sparse; }
415 ::tensorflow::Node* node() const { return serialized_sparse.node(); }
416
417 static Attrs OutType(DataType x) {
418 return Attrs().OutType(x);
419 }
420
421 Operation operation;
422 ::tensorflow::Output serialized_sparse;
423};
424
425/// Adds two `SparseTensor` objects to produce another `SparseTensor`.
426///
427/// The input `SparseTensor` objects' indices are assumed ordered in standard
428/// lexicographic order. If this is not the case, before this step run
429/// `SparseReorder` to restore index ordering.
430///
431/// By default, if two values sum to zero at some index, the output `SparseTensor`
432/// would still include that particular location in its index, storing a zero in the
433/// corresponding value slot. To override this, callers can specify `thresh`,
434/// indicating that if the sum has a magnitude strictly smaller than `thresh`, its
435/// corresponding value and index would then not be included. In particular,
436/// `thresh == 0` (default) means everything is kept and actual thresholding happens
437/// only for a positive value.
438///
439/// In the following shapes, `nnz` is the count after taking `thresh` into account.
440///
441/// Args:
442/// * scope: A Scope object
443/// * a_indices: 2-D. The `indices` of the first `SparseTensor`, size `[nnz, ndims]` Matrix.
444/// * a_values: 1-D. The `values` of the first `SparseTensor`, size `[nnz]` Vector.
445/// * a_shape: 1-D. The `shape` of the first `SparseTensor`, size `[ndims]` Vector.
446/// * b_indices: 2-D. The `indices` of the second `SparseTensor`, size `[nnz, ndims]` Matrix.
447/// * b_values: 1-D. The `values` of the second `SparseTensor`, size `[nnz]` Vector.
448/// * b_shape: 1-D. The `shape` of the second `SparseTensor`, size `[ndims]` Vector.
449/// * thresh: 0-D. The magnitude threshold that determines if an output value/index
450/// pair takes space.
451///
452/// Returns:
453/// * `Output` sum_indices
454/// * `Output` sum_values
455/// * `Output` sum_shape
456class SparseAdd {
457 public:
458 SparseAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input a_indices,
459 ::tensorflow::Input a_values, ::tensorflow::Input a_shape,
460 ::tensorflow::Input b_indices, ::tensorflow::Input b_values,
461 ::tensorflow::Input b_shape, ::tensorflow::Input thresh);
462
463 Operation operation;
464 ::tensorflow::Output sum_indices;
465 ::tensorflow::Output sum_values;
466 ::tensorflow::Output sum_shape;
467};
468
469/// The gradient operator for the SparseAdd op.
470///
471/// The SparseAdd op calculates A + B, where A, B, and the sum are all represented
472/// as `SparseTensor` objects. This op takes in the upstream gradient w.r.t.
473/// non-empty values of the sum, and outputs the gradients w.r.t. the non-empty
474/// values of A and B.
475///
476/// Args:
477/// * scope: A Scope object
478/// * backprop_val_grad: 1-D with shape `[nnz(sum)]`. The gradient with respect to
479/// the non-empty values of the sum.
480/// * a_indices: 2-D. The `indices` of the `SparseTensor` A, size `[nnz(A), ndims]`.
481/// * b_indices: 2-D. The `indices` of the `SparseTensor` B, size `[nnz(B), ndims]`.
482/// * sum_indices: 2-D. The `indices` of the sum `SparseTensor`, size
483/// `[nnz(sum), ndims]`.
484///
485/// Returns:
486/// * `Output` a_val_grad: 1-D with shape `[nnz(A)]`. The gradient with respect to the
487/// non-empty values of A.
488/// * `Output` b_val_grad: 1-D with shape `[nnz(B)]`. The gradient with respect to the
489/// non-empty values of B.
490class SparseAddGrad {
491 public:
492 SparseAddGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
493 backprop_val_grad, ::tensorflow::Input a_indices,
494 ::tensorflow::Input b_indices, ::tensorflow::Input sum_indices);
495
496 Operation operation;
497 ::tensorflow::Output a_val_grad;
498 ::tensorflow::Output b_val_grad;
499};
500
501/// Concatenates a list of `SparseTensor` along the specified dimension.
502///
503/// Concatenation is with respect to the dense versions of these sparse tensors.
504/// It is assumed that each input is a `SparseTensor` whose elements are ordered
505/// along increasing dimension number.
506///
507/// All inputs' shapes must match, except for the concat dimension. The
508/// `indices`, `values`, and `shapes` lists must have the same length.
509///
510/// The output shape is identical to the inputs', except along the concat
511/// dimension, where it is the sum of the inputs' sizes along that dimension.
512///
513/// The output elements will be resorted to preserve the sort order along
514/// increasing dimension number.
515///
516/// This op runs in `O(M log M)` time, where `M` is the total number of non-empty
517/// values across all inputs. This is due to the need for an internal sort in
518/// order to concatenate efficiently across an arbitrary dimension.
519///
520/// For example, if `concat_dim = 1` and the inputs are
521///
522/// sp_inputs[0]: shape = [2, 3]
523/// [0, 2]: "a"
524/// [1, 0]: "b"
525/// [1, 1]: "c"
526///
527/// sp_inputs[1]: shape = [2, 4]
528/// [0, 1]: "d"
529/// [0, 2]: "e"
530///
531/// then the output will be
532///
533/// shape = [2, 7]
534/// [0, 2]: "a"
535/// [0, 4]: "d"
536/// [0, 5]: "e"
537/// [1, 0]: "b"
538/// [1, 1]: "c"
539///
540/// Graphically this is equivalent to doing
541///
542/// [ a] concat [ d e ] = [ a d e ]
543/// [b c ] [ ] [b c ]
544///
545/// Args:
546/// * scope: A Scope object
547/// * indices: 2-D. Indices of each input `SparseTensor`.
548/// * values: 1-D. Non-empty values of each `SparseTensor`.
549/// * shapes: 1-D. Shapes of each `SparseTensor`.
550/// * concat_dim: Dimension to concatenate along. Must be in range [-rank, rank),
551/// where rank is the number of dimensions in each input `SparseTensor`.
552///
553/// Returns:
554/// * `Output` output_indices: 2-D. Indices of the concatenated `SparseTensor`.
555/// * `Output` output_values: 1-D. Non-empty values of the concatenated `SparseTensor`.
556/// * `Output` output_shape: 1-D. Shape of the concatenated `SparseTensor`.
557class SparseConcat {
558 public:
559 SparseConcat(const ::tensorflow::Scope& scope, ::tensorflow::InputList indices,
560 ::tensorflow::InputList values, ::tensorflow::InputList shapes,
561 int64 concat_dim);
562
563 Operation operation;
564 ::tensorflow::Output output_indices;
565 ::tensorflow::Output output_values;
566 ::tensorflow::Output output_shape;
567};
568
569/// Generates sparse cross from a list of sparse and dense tensors.
570///
571/// The op takes two lists, one of 2D `SparseTensor` and one of 2D `Tensor`, each
572/// representing features of one feature column. It outputs a 2D `SparseTensor` with
573/// the batchwise crosses of these features.
574///
575/// For example, if the inputs are
576///
577/// inputs[0]: SparseTensor with shape = [2, 2]
578/// [0, 0]: "a"
579/// [1, 0]: "b"
580/// [1, 1]: "c"
581///
582/// inputs[1]: SparseTensor with shape = [2, 1]
583/// [0, 0]: "d"
584/// [1, 0]: "e"
585///
586/// inputs[2]: Tensor [["f"], ["g"]]
587///
588/// then the output will be
589///
590/// shape = [2, 2]
591/// [0, 0]: "a_X_d_X_f"
592/// [1, 0]: "b_X_e_X_g"
593/// [1, 1]: "c_X_e_X_g"
594///
595/// if hashed_output=true then the output will be
596///
597/// shape = [2, 2]
598/// [0, 0]: FingerprintCat64(
599/// Fingerprint64("f"), FingerprintCat64(
600/// Fingerprint64("d"), Fingerprint64("a")))
601/// [1, 0]: FingerprintCat64(
602/// Fingerprint64("g"), FingerprintCat64(
603/// Fingerprint64("e"), Fingerprint64("b")))
604/// [1, 1]: FingerprintCat64(
605/// Fingerprint64("g"), FingerprintCat64(
606/// Fingerprint64("e"), Fingerprint64("c")))
607///
608/// Args:
609/// * scope: A Scope object
610/// * indices: 2-D. Indices of each input `SparseTensor`.
611/// * values: 1-D. values of each `SparseTensor`.
612/// * shapes: 1-D. Shapes of each `SparseTensor`.
613/// * dense_inputs: 2-D. Columns represented by dense `Tensor`.
614/// * hashed_output: If true, returns the hash of the cross instead of the string.
615/// This will allow us avoiding string manipulations.
616/// * num_buckets: It is used if hashed_output is true.
617/// output = hashed_value%num_buckets if num_buckets > 0 else hashed_value.
618/// * hash_key: Specify the hash_key that will be used by the `FingerprintCat64`
619/// function to combine the crosses fingerprints.
620///
621/// Returns:
622/// * `Output` output_indices: 2-D. Indices of the concatenated `SparseTensor`.
623/// * `Output` output_values: 1-D. Non-empty values of the concatenated or hashed
624/// `SparseTensor`.
625/// * `Output` output_shape: 1-D. Shape of the concatenated `SparseTensor`.
626class SparseCross {
627 public:
628 SparseCross(const ::tensorflow::Scope& scope, ::tensorflow::InputList indices,
629 ::tensorflow::InputList values, ::tensorflow::InputList shapes,
630 ::tensorflow::InputList dense_inputs, bool hashed_output, int64
631 num_buckets, int64 hash_key, DataType out_type, DataType
632 internal_type);
633
634 Operation operation;
635 ::tensorflow::Output output_indices;
636 ::tensorflow::Output output_values;
637 ::tensorflow::Output output_shape;
638};
639
640/// Generates sparse cross from a list of sparse and dense tensors.
641///
642/// The op takes two lists, one of 2D `SparseTensor` and one of 2D `Tensor`, each
643/// representing features of one feature column. It outputs a 2D `SparseTensor` with
644/// the batchwise crosses of these features.
645///
646/// For example, if the inputs are
647///
648/// inputs[0]: SparseTensor with shape = [2, 2]
649/// [0, 0]: "a"
650/// [1, 0]: "b"
651/// [1, 1]: "c"
652///
653/// inputs[1]: SparseTensor with shape = [2, 1]
654/// [0, 0]: "d"
655/// [1, 0]: "e"
656///
657/// inputs[2]: Tensor [["f"], ["g"]]
658///
659/// then the output will be
660///
661/// shape = [2, 2]
662/// [0, 0]: "a_X_d_X_f"
663/// [1, 0]: "b_X_e_X_g"
664/// [1, 1]: "c_X_e_X_g"
665///
666/// if hashed_output=true then the output will be
667///
668/// shape = [2, 2]
669/// [0, 0]: FingerprintCat64(
670/// Fingerprint64("f"), FingerprintCat64(
671/// Fingerprint64("d"), Fingerprint64("a")))
672/// [1, 0]: FingerprintCat64(
673/// Fingerprint64("g"), FingerprintCat64(
674/// Fingerprint64("e"), Fingerprint64("b")))
675/// [1, 1]: FingerprintCat64(
676/// Fingerprint64("g"), FingerprintCat64(
677/// Fingerprint64("e"), Fingerprint64("c")))
678///
679/// Args:
680/// * scope: A Scope object
681/// * indices: 2-D. Indices of each input `SparseTensor`.
682/// * values: 1-D. values of each `SparseTensor`.
683/// * shapes: 1-D. Shapes of each `SparseTensor`.
684/// * dense_inputs: 2-D. Columns represented by dense `Tensor`.
685/// * num_buckets: It is used if hashed_output is true.
686/// output = hashed_value%num_buckets if num_buckets > 0 else hashed_value.
687/// * strong_hash: boolean, if true, siphash with salt will be used instead of farmhash.
688/// * salt: Specify the salt that will be used by the siphash function.
689///
690/// Returns:
691/// * `Output` output_indices: 2-D. Indices of the concatenated `SparseTensor`.
692/// * `Output` output_values: 1-D. Non-empty values of the concatenated or hashed
693/// `SparseTensor`.
694/// * `Output` output_shape: 1-D. Shape of the concatenated `SparseTensor`.
695class SparseCrossHashed {
696 public:
697 SparseCrossHashed(const ::tensorflow::Scope& scope, ::tensorflow::InputList
698 indices, ::tensorflow::InputList values,
699 ::tensorflow::InputList shapes, ::tensorflow::InputList
700 dense_inputs, ::tensorflow::Input num_buckets,
701 ::tensorflow::Input strong_hash, ::tensorflow::Input salt);
702
703 Operation operation;
704 ::tensorflow::Output output_indices;
705 ::tensorflow::Output output_values;
706 ::tensorflow::Output output_shape;
707};
708
709/// Generates sparse cross from a list of sparse and dense tensors.
710///
711/// The op takes two lists, one of 2D `SparseTensor` and one of 2D `Tensor`, each
712/// representing features of one feature column. It outputs a 2D `SparseTensor` with
713/// the batchwise crosses of these features.
714///
715/// For example, if the inputs are
716///
717/// inputs[0]: SparseTensor with shape = [2, 2]
718/// [0, 0]: "a"
719/// [1, 0]: "b"
720/// [1, 1]: "c"
721///
722/// inputs[1]: SparseTensor with shape = [2, 1]
723/// [0, 0]: "d"
724/// [1, 0]: "e"
725///
726/// inputs[2]: Tensor [["f"], ["g"]]
727///
728/// then the output will be
729///
730/// shape = [2, 2]
731/// [0, 0]: "a_X_d_X_f"
732/// [1, 0]: "b_X_e_X_g"
733/// [1, 1]: "c_X_e_X_g"
734///
735/// if hashed_output=true then the output will be
736///
737/// shape = [2, 2]
738/// [0, 0]: FingerprintCat64(
739/// Fingerprint64("f"), FingerprintCat64(
740/// Fingerprint64("d"), Fingerprint64("a")))
741/// [1, 0]: FingerprintCat64(
742/// Fingerprint64("g"), FingerprintCat64(
743/// Fingerprint64("e"), Fingerprint64("b")))
744/// [1, 1]: FingerprintCat64(
745/// Fingerprint64("g"), FingerprintCat64(
746/// Fingerprint64("e"), Fingerprint64("c")))
747///
748/// Args:
749/// * scope: A Scope object
750/// * indices: 2-D. Indices of each input `SparseTensor`.
751/// * values: 1-D. values of each `SparseTensor`.
752/// * shapes: 1-D. Shapes of each `SparseTensor`.
753/// * dense_inputs: 2-D. Columns represented by dense `Tensor`.
754/// * sep: string used when joining a list of string inputs, can be used as separator later.
755///
756/// Returns:
757/// * `Output` output_indices: 2-D. Indices of the concatenated `SparseTensor`.
758/// * `Output` output_values: 1-D. Non-empty values of the concatenated or hashed
759/// `SparseTensor`.
760/// * `Output` output_shape: 1-D. Shape of the concatenated `SparseTensor`.
761class SparseCrossV2 {
762 public:
763 SparseCrossV2(const ::tensorflow::Scope& scope, ::tensorflow::InputList
764 indices, ::tensorflow::InputList values, ::tensorflow::InputList
765 shapes, ::tensorflow::InputList dense_inputs, ::tensorflow::Input
766 sep);
767
768 Operation operation;
769 ::tensorflow::Output output_indices;
770 ::tensorflow::Output output_values;
771 ::tensorflow::Output output_shape;
772};
773
774/// Adds up a SparseTensor and a dense Tensor, using these special rules:
775///
776/// (1) Broadcasts the dense side to have the same shape as the sparse side, if
777/// eligible;
778/// (2) Then, only the dense values pointed to by the indices of the SparseTensor
779/// participate in the cwise addition.
780///
781/// By these rules, the result is a logical SparseTensor with exactly the same
782/// indices and shape, but possibly with different non-zero values. The output of
783/// this Op is the resultant non-zero values.
784///
785/// Args:
786/// * scope: A Scope object
787/// * sp_indices: 2-D. `N x R` matrix with the indices of non-empty values in a
788/// SparseTensor, possibly not in canonical ordering.
789/// * sp_values: 1-D. `N` non-empty values corresponding to `sp_indices`.
790/// * sp_shape: 1-D. Shape of the input SparseTensor.
791/// * dense: `R`-D. The dense Tensor operand.
792///
793/// Returns:
794/// * `Output`: 1-D. The `N` values that are operated on.
795class SparseDenseCwiseAdd {
796 public:
797 SparseDenseCwiseAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input
798 sp_indices, ::tensorflow::Input sp_values,
799 ::tensorflow::Input sp_shape, ::tensorflow::Input dense);
800 operator ::tensorflow::Output() const { return output; }
801 operator ::tensorflow::Input() const { return output; }
802 ::tensorflow::Node* node() const { return output.node(); }
803
804 Operation operation;
805 ::tensorflow::Output output;
806};
807
808/// Component-wise divides a SparseTensor by a dense Tensor.
809///
810/// *Limitation*: this Op only broadcasts the dense side to the sparse side, but not
811/// the other direction.
812///
813/// Args:
814/// * scope: A Scope object
815/// * sp_indices: 2-D. `N x R` matrix with the indices of non-empty values in a
816/// SparseTensor, possibly not in canonical ordering.
817/// * sp_values: 1-D. `N` non-empty values corresponding to `sp_indices`.
818/// * sp_shape: 1-D. Shape of the input SparseTensor.
819/// * dense: `R`-D. The dense Tensor operand.
820///
821/// Returns:
822/// * `Output`: 1-D. The `N` values that are operated on.
823class SparseDenseCwiseDiv {
824 public:
825 SparseDenseCwiseDiv(const ::tensorflow::Scope& scope, ::tensorflow::Input
826 sp_indices, ::tensorflow::Input sp_values,
827 ::tensorflow::Input sp_shape, ::tensorflow::Input dense);
828 operator ::tensorflow::Output() const { return output; }
829 operator ::tensorflow::Input() const { return output; }
830 ::tensorflow::Node* node() const { return output.node(); }
831
832 Operation operation;
833 ::tensorflow::Output output;
834};
835
836/// Component-wise multiplies a SparseTensor by a dense Tensor.
837///
838/// The output locations corresponding to the implicitly zero elements in the sparse
839/// tensor will be zero (i.e., will not take up storage space), regardless of the
840/// contents of the dense tensor (even if it's +/-INF and that INF*0 == NaN).
841///
842/// *Limitation*: this Op only broadcasts the dense side to the sparse side, but not
843/// the other direction.
844///
845/// Args:
846/// * scope: A Scope object
847/// * sp_indices: 2-D. `N x R` matrix with the indices of non-empty values in a
848/// SparseTensor, possibly not in canonical ordering.
849/// * sp_values: 1-D. `N` non-empty values corresponding to `sp_indices`.
850/// * sp_shape: 1-D. Shape of the input SparseTensor.
851/// * dense: `R`-D. The dense Tensor operand.
852///
853/// Returns:
854/// * `Output`: 1-D. The `N` values that are operated on.
855class SparseDenseCwiseMul {
856 public:
857 SparseDenseCwiseMul(const ::tensorflow::Scope& scope, ::tensorflow::Input
858 sp_indices, ::tensorflow::Input sp_values,
859 ::tensorflow::Input sp_shape, ::tensorflow::Input dense);
860 operator ::tensorflow::Output() const { return output; }
861 operator ::tensorflow::Input() const { return output; }
862 ::tensorflow::Node* node() const { return output.node(); }
863
864 Operation operation;
865 ::tensorflow::Output output;
866};
867
868/// Fills empty rows in the input 2-D `SparseTensor` with a default value.
869///
870/// The input `SparseTensor` is represented via the tuple of inputs
871/// (`indices`, `values`, `dense_shape`). The output `SparseTensor` has the
872/// same `dense_shape` but with indices `output_indices` and values
873/// `output_values`.
874///
875/// This op inserts a single entry for every row that doesn't have any values.
876/// The index is created as `[row, 0, ..., 0]` and the inserted value
877/// is `default_value`.
878///
879/// For example, suppose `sp_input` has shape `[5, 6]` and non-empty values:
880///
881/// [0, 1]: a
882/// [0, 3]: b
883/// [2, 0]: c
884/// [3, 1]: d
885///
886/// Rows 1 and 4 are empty, so the output will be of shape `[5, 6]` with values:
887///
888/// [0, 1]: a
889/// [0, 3]: b
890/// [1, 0]: default_value
891/// [2, 0]: c
892/// [3, 1]: d
893/// [4, 0]: default_value
894///
895/// The output `SparseTensor` will be in row-major order and will have the
896/// same shape as the input.
897///
898/// This op also returns an indicator vector shaped `[dense_shape[0]]` such that
899///
900/// empty_row_indicator[i] = True iff row i was an empty row.
901///
902/// And a reverse index map vector shaped `[indices.shape[0]]` that is used during
903/// backpropagation,
904///
905/// reverse_index_map[j] = out_j s.t. indices[j, :] == output_indices[out_j, :]
906///
907/// Args:
908/// * scope: A Scope object
909/// * indices: 2-D. the indices of the sparse tensor.
910/// * values: 1-D. the values of the sparse tensor.
911/// * dense_shape: 1-D. the shape of the sparse tensor.
912/// * default_value: 0-D. default value to insert into location `[row, 0, ..., 0]`
913/// for rows missing from the input sparse tensor.
914/// output indices: 2-D. the indices of the filled sparse tensor.
915///
916/// Returns:
917/// * `Output` output_indices
918/// * `Output` output_values: 1-D. the values of the filled sparse tensor.
919/// * `Output` empty_row_indicator: 1-D. whether the dense row was missing in the
920/// input sparse tensor.
921/// * `Output` reverse_index_map: 1-D. a map from the input indices to the output indices.
922class SparseFillEmptyRows {
923 public:
924 SparseFillEmptyRows(const ::tensorflow::Scope& scope, ::tensorflow::Input
925 indices, ::tensorflow::Input values, ::tensorflow::Input
926 dense_shape, ::tensorflow::Input default_value);
927
928 Operation operation;
929 ::tensorflow::Output output_indices;
930 ::tensorflow::Output output_values;
931 ::tensorflow::Output empty_row_indicator;
932 ::tensorflow::Output reverse_index_map;
933};
934
935/// The gradient of SparseFillEmptyRows.
936///
937/// Takes vectors reverse_index_map, shaped `[N]`, and grad_values,
938/// shaped `[N_full]`, where `N_full >= N` and copies data into either
939/// `d_values` or `d_default_value`. Here `d_values` is shaped `[N]` and
940/// `d_default_value` is a scalar.
941///
942/// d_values[j] = grad_values[reverse_index_map[j]]
943/// d_default_value = sum_{k : 0 .. N_full - 1} (
944/// grad_values[k] * 1{k not in reverse_index_map})
945///
946/// Args:
947/// * scope: A Scope object
948/// * reverse_index_map: 1-D. The reverse index map from SparseFillEmptyRows.
949/// * grad_values: 1-D. The gradients from backprop.
950///
951/// Returns:
952/// * `Output` d_values: 1-D. The backprop into values.
953/// * `Output` d_default_value: 0-D. The backprop into default_value.
954class SparseFillEmptyRowsGrad {
955 public:
956 SparseFillEmptyRowsGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
957 reverse_index_map, ::tensorflow::Input grad_values);
958
959 Operation operation;
960 ::tensorflow::Output d_values;
961 ::tensorflow::Output d_default_value;
962};
963
964/// Computes the max of elements across dimensions of a SparseTensor.
965///
966/// This Op takes a SparseTensor and is the sparse counterpart to
967/// `tf.reduce_max()`. In particular, this Op also returns a dense `Tensor`
968/// instead of a sparse one.
969///
970/// Reduces `sp_input` along the dimensions given in `reduction_axes`. Unless
971/// `keep_dims` is true, the rank of the tensor is reduced by 1 for each entry in
972/// `reduction_axes`. If `keep_dims` is true, the reduced dimensions are retained
973/// with length 1.
974///
975/// If `reduction_axes` has no entries, all dimensions are reduced, and a tensor
976/// with a single element is returned. Additionally, the axes can be negative,
977/// which are interpreted according to the indexing rules in Python.
978///
979/// Args:
980/// * scope: A Scope object
981/// * input_indices: 2-D. `N x R` matrix with the indices of non-empty values in a
982/// SparseTensor, possibly not in canonical ordering.
983/// * input_values: 1-D. `N` non-empty values corresponding to `input_indices`.
984/// * input_shape: 1-D. Shape of the input SparseTensor.
985/// * reduction_axes: 1-D. Length-`K` vector containing the reduction axes.
986///
987/// Optional attributes (see `Attrs`):
988/// * keep_dims: If true, retain reduced dimensions with length 1.
989///
990/// Returns:
991/// * `Output`: `R-K`-D. The reduced Tensor.
992class SparseReduceMax {
993 public:
994 /// Optional attribute setters for SparseReduceMax
995 struct Attrs {
996 /// If true, retain reduced dimensions with length 1.
997 ///
998 /// Defaults to false
999 TF_MUST_USE_RESULT Attrs KeepDims(bool x) {
1000 Attrs ret = *this;
1001 ret.keep_dims_ = x;
1002 return ret;
1003 }
1004
1005 bool keep_dims_ = false;
1006 };
1007 SparseReduceMax(const ::tensorflow::Scope& scope, ::tensorflow::Input
1008 input_indices, ::tensorflow::Input input_values,
1009 ::tensorflow::Input input_shape, ::tensorflow::Input
1010 reduction_axes);
1011 SparseReduceMax(const ::tensorflow::Scope& scope, ::tensorflow::Input
1012 input_indices, ::tensorflow::Input input_values,
1013 ::tensorflow::Input input_shape, ::tensorflow::Input
1014 reduction_axes, const SparseReduceMax::Attrs& attrs);
1015 operator ::tensorflow::Output() const { return output; }
1016 operator ::tensorflow::Input() const { return output; }
1017 ::tensorflow::Node* node() const { return output.node(); }
1018
1019 static Attrs KeepDims(bool x) {
1020 return Attrs().KeepDims(x);
1021 }
1022
1023 Operation operation;
1024 ::tensorflow::Output output;
1025};
1026
1027/// Computes the max of elements across dimensions of a SparseTensor.
1028///
1029/// This Op takes a SparseTensor and is the sparse counterpart to
1030/// `tf.reduce_max()`. In contrast to SparseReduceMax, this Op returns a
1031/// SparseTensor.
1032///
1033/// Reduces `sp_input` along the dimensions given in `reduction_axes`. Unless
1034/// `keep_dims` is true, the rank of the tensor is reduced by 1 for each entry in
1035/// `reduction_axes`. If `keep_dims` is true, the reduced dimensions are retained
1036/// with length 1.
1037///
1038/// If `reduction_axes` has no entries, all dimensions are reduced, and a tensor
1039/// with a single element is returned. Additionally, the axes can be negative,
1040/// which are interpreted according to the indexing rules in Python.
1041///
1042/// Args:
1043/// * scope: A Scope object
1044/// * input_indices: 2-D. `N x R` matrix with the indices of non-empty values in a
1045/// SparseTensor, possibly not in canonical ordering.
1046/// * input_values: 1-D. `N` non-empty values corresponding to `input_indices`.
1047/// * input_shape: 1-D. Shape of the input SparseTensor.
1048/// * reduction_axes: 1-D. Length-`K` vector containing the reduction axes.
1049///
1050/// Optional attributes (see `Attrs`):
1051/// * keep_dims: If true, retain reduced dimensions with length 1.
1052///
1053/// Returns:
1054/// * `Output` output_indices
1055/// * `Output` output_values
1056/// * `Output` output_shape
1057class SparseReduceMaxSparse {
1058 public:
1059 /// Optional attribute setters for SparseReduceMaxSparse
1060 struct Attrs {
1061 /// If true, retain reduced dimensions with length 1.
1062 ///
1063 /// Defaults to false
1064 TF_MUST_USE_RESULT Attrs KeepDims(bool x) {
1065 Attrs ret = *this;
1066 ret.keep_dims_ = x;
1067 return ret;
1068 }
1069
1070 bool keep_dims_ = false;
1071 };
1072 SparseReduceMaxSparse(const ::tensorflow::Scope& scope, ::tensorflow::Input
1073 input_indices, ::tensorflow::Input input_values,
1074 ::tensorflow::Input input_shape, ::tensorflow::Input
1075 reduction_axes);
1076 SparseReduceMaxSparse(const ::tensorflow::Scope& scope, ::tensorflow::Input
1077 input_indices, ::tensorflow::Input input_values,
1078 ::tensorflow::Input input_shape, ::tensorflow::Input
1079 reduction_axes, const SparseReduceMaxSparse::Attrs&
1080 attrs);
1081
1082 static Attrs KeepDims(bool x) {
1083 return Attrs().KeepDims(x);
1084 }
1085
1086 Operation operation;
1087 ::tensorflow::Output output_indices;
1088 ::tensorflow::Output output_values;
1089 ::tensorflow::Output output_shape;
1090};
1091
1092/// Computes the sum of elements across dimensions of a SparseTensor.
1093///
1094/// This Op takes a SparseTensor and is the sparse counterpart to
1095/// `tf.reduce_sum()`. In particular, this Op also returns a dense `Tensor`
1096/// instead of a sparse one.
1097///
1098/// Reduces `sp_input` along the dimensions given in `reduction_axes`. Unless
1099/// `keep_dims` is true, the rank of the tensor is reduced by 1 for each entry in
1100/// `reduction_axes`. If `keep_dims` is true, the reduced dimensions are retained
1101/// with length 1.
1102///
1103/// If `reduction_axes` has no entries, all dimensions are reduced, and a tensor
1104/// with a single element is returned. Additionally, the axes can be negative,
1105/// which are interpreted according to the indexing rules in Python.
1106///
1107/// Args:
1108/// * scope: A Scope object
1109/// * input_indices: 2-D. `N x R` matrix with the indices of non-empty values in a
1110/// SparseTensor, possibly not in canonical ordering.
1111/// * input_values: 1-D. `N` non-empty values corresponding to `input_indices`.
1112/// * input_shape: 1-D. Shape of the input SparseTensor.
1113/// * reduction_axes: 1-D. Length-`K` vector containing the reduction axes.
1114///
1115/// Optional attributes (see `Attrs`):
1116/// * keep_dims: If true, retain reduced dimensions with length 1.
1117///
1118/// Returns:
1119/// * `Output`: `R-K`-D. The reduced Tensor.
1120class SparseReduceSum {
1121 public:
1122 /// Optional attribute setters for SparseReduceSum
1123 struct Attrs {
1124 /// If true, retain reduced dimensions with length 1.
1125 ///
1126 /// Defaults to false
1127 TF_MUST_USE_RESULT Attrs KeepDims(bool x) {
1128 Attrs ret = *this;
1129 ret.keep_dims_ = x;
1130 return ret;
1131 }
1132
1133 bool keep_dims_ = false;
1134 };
1135 SparseReduceSum(const ::tensorflow::Scope& scope, ::tensorflow::Input
1136 input_indices, ::tensorflow::Input input_values,
1137 ::tensorflow::Input input_shape, ::tensorflow::Input
1138 reduction_axes);
1139 SparseReduceSum(const ::tensorflow::Scope& scope, ::tensorflow::Input
1140 input_indices, ::tensorflow::Input input_values,
1141 ::tensorflow::Input input_shape, ::tensorflow::Input
1142 reduction_axes, const SparseReduceSum::Attrs& attrs);
1143 operator ::tensorflow::Output() const { return output; }
1144 operator ::tensorflow::Input() const { return output; }
1145 ::tensorflow::Node* node() const { return output.node(); }
1146
1147 static Attrs KeepDims(bool x) {
1148 return Attrs().KeepDims(x);
1149 }
1150
1151 Operation operation;
1152 ::tensorflow::Output output;
1153};
1154
1155/// Computes the sum of elements across dimensions of a SparseTensor.
1156///
1157/// This Op takes a SparseTensor and is the sparse counterpart to
1158/// `tf.reduce_sum()`. In contrast to SparseReduceSum, this Op returns a
1159/// SparseTensor.
1160///
1161/// Reduces `sp_input` along the dimensions given in `reduction_axes`. Unless
1162/// `keep_dims` is true, the rank of the tensor is reduced by 1 for each entry in
1163/// `reduction_axes`. If `keep_dims` is true, the reduced dimensions are retained
1164/// with length 1.
1165///
1166/// If `reduction_axes` has no entries, all dimensions are reduced, and a tensor
1167/// with a single element is returned. Additionally, the axes can be negative,
1168/// which are interpreted according to the indexing rules in Python.
1169///
1170/// Args:
1171/// * scope: A Scope object
1172/// * input_indices: 2-D. `N x R` matrix with the indices of non-empty values in a
1173/// SparseTensor, possibly not in canonical ordering.
1174/// * input_values: 1-D. `N` non-empty values corresponding to `input_indices`.
1175/// * input_shape: 1-D. Shape of the input SparseTensor.
1176/// * reduction_axes: 1-D. Length-`K` vector containing the reduction axes.
1177///
1178/// Optional attributes (see `Attrs`):
1179/// * keep_dims: If true, retain reduced dimensions with length 1.
1180///
1181/// Returns:
1182/// * `Output` output_indices
1183/// * `Output` output_values
1184/// * `Output` output_shape
1185class SparseReduceSumSparse {
1186 public:
1187 /// Optional attribute setters for SparseReduceSumSparse
1188 struct Attrs {
1189 /// If true, retain reduced dimensions with length 1.
1190 ///
1191 /// Defaults to false
1192 TF_MUST_USE_RESULT Attrs KeepDims(bool x) {
1193 Attrs ret = *this;
1194 ret.keep_dims_ = x;
1195 return ret;
1196 }
1197
1198 bool keep_dims_ = false;
1199 };
1200 SparseReduceSumSparse(const ::tensorflow::Scope& scope, ::tensorflow::Input
1201 input_indices, ::tensorflow::Input input_values,
1202 ::tensorflow::Input input_shape, ::tensorflow::Input
1203 reduction_axes);
1204 SparseReduceSumSparse(const ::tensorflow::Scope& scope, ::tensorflow::Input
1205 input_indices, ::tensorflow::Input input_values,
1206 ::tensorflow::Input input_shape, ::tensorflow::Input
1207 reduction_axes, const SparseReduceSumSparse::Attrs&
1208 attrs);
1209
1210 static Attrs KeepDims(bool x) {
1211 return Attrs().KeepDims(x);
1212 }
1213
1214 Operation operation;
1215 ::tensorflow::Output output_indices;
1216 ::tensorflow::Output output_values;
1217 ::tensorflow::Output output_shape;
1218};
1219
1220/// Reorders a SparseTensor into the canonical, row-major ordering.
1221///
1222/// Note that by convention, all sparse ops preserve the canonical ordering along
1223/// increasing dimension number. The only time ordering can be violated is during
1224/// manual manipulation of the indices and values vectors to add entries.
1225///
1226/// Reordering does not affect the shape of the SparseTensor.
1227///
1228/// If the tensor has rank `R` and `N` non-empty values, `input_indices` has
1229/// shape `[N, R]`, input_values has length `N`, and input_shape has length `R`.
1230///
1231/// Args:
1232/// * scope: A Scope object
1233/// * input_indices: 2-D. `N x R` matrix with the indices of non-empty values in a
1234/// SparseTensor, possibly not in canonical ordering.
1235/// * input_values: 1-D. `N` non-empty values corresponding to `input_indices`.
1236/// * input_shape: 1-D. Shape of the input SparseTensor.
1237///
1238/// Returns:
1239/// * `Output` output_indices: 2-D. `N x R` matrix with the same indices as input_indices, but
1240/// in canonical row-major ordering.
1241/// * `Output` output_values: 1-D. `N` non-empty values corresponding to `output_indices`.
1242class SparseReorder {
1243 public:
1244 SparseReorder(const ::tensorflow::Scope& scope, ::tensorflow::Input
1245 input_indices, ::tensorflow::Input input_values,
1246 ::tensorflow::Input input_shape);
1247
1248 Operation operation;
1249 ::tensorflow::Output output_indices;
1250 ::tensorflow::Output output_values;
1251};
1252
1253/// Reshapes a SparseTensor to represent values in a new dense shape.
1254///
1255/// This operation has the same semantics as reshape on the represented dense
1256/// tensor. The `input_indices` are recomputed based on the requested `new_shape`.
1257///
1258/// If one component of `new_shape` is the special value -1, the size of that
1259/// dimension is computed so that the total dense size remains constant. At
1260/// most one component of `new_shape` can be -1. The number of dense elements
1261/// implied by `new_shape` must be the same as the number of dense elements
1262/// originally implied by `input_shape`.
1263///
1264/// Reshaping does not affect the order of values in the SparseTensor.
1265///
1266/// If the input tensor has rank `R_in` and `N` non-empty values, and `new_shape`
1267/// has length `R_out`, then `input_indices` has shape `[N, R_in]`,
1268/// `input_shape` has length `R_in`, `output_indices` has shape `[N, R_out]`, and
1269/// `output_shape` has length `R_out`.
1270///
1271/// Args:
1272/// * scope: A Scope object
1273/// * input_indices: 2-D. `N x R_in` matrix with the indices of non-empty values in a
1274/// SparseTensor.
1275/// * input_shape: 1-D. `R_in` vector with the input SparseTensor's dense shape.
1276/// * new_shape: 1-D. `R_out` vector with the requested new dense shape.
1277///
1278/// Returns:
1279/// * `Output` output_indices: 2-D. `N x R_out` matrix with the updated indices of non-empty
1280/// values in the output SparseTensor.
1281/// * `Output` output_shape: 1-D. `R_out` vector with the full dense shape of the output
1282/// SparseTensor. This is the same as `new_shape` but with any -1 dimensions
1283/// filled in.
1284class SparseReshape {
1285 public:
1286 SparseReshape(const ::tensorflow::Scope& scope, ::tensorflow::Input
1287 input_indices, ::tensorflow::Input input_shape,
1288 ::tensorflow::Input new_shape);
1289
1290 Operation operation;
1291 ::tensorflow::Output output_indices;
1292 ::tensorflow::Output output_shape;
1293};
1294
1295/// Slice a `SparseTensor` based on the `start` and `size`.
1296///
1297/// For example, if the input is
1298///
1299/// input_tensor = shape = [2, 7]
1300/// [ a d e ]
1301/// [b c ]
1302///
1303/// Graphically the output tensors are:
1304///
1305/// sparse_slice([0, 0], [2, 4]) = shape = [2, 4]
1306/// [ a ]
1307/// [b c ]
1308///
1309/// sparse_slice([0, 4], [2, 3]) = shape = [2, 3]
1310/// [ d e ]
1311/// [ ]
1312///
1313/// Args:
1314/// * scope: A Scope object
1315/// * indices: 2-D tensor represents the indices of the sparse tensor.
1316/// * values: 1-D tensor represents the values of the sparse tensor.
1317/// * shape: 1-D. tensor represents the shape of the sparse tensor.
1318/// * start: 1-D. tensor represents the start of the slice.
1319/// * size: 1-D. tensor represents the size of the slice.
1320/// output indices: A list of 1-D tensors represents the indices of the output
1321/// sparse tensors.
1322///
1323/// Returns:
1324/// * `Output` output_indices
1325/// * `Output` output_values: A list of 1-D tensors represents the values of the output sparse
1326/// tensors.
1327/// * `Output` output_shape: A list of 1-D tensors represents the shape of the output sparse
1328/// tensors.
1329class SparseSlice {
1330 public:
1331 SparseSlice(const ::tensorflow::Scope& scope, ::tensorflow::Input indices,
1332 ::tensorflow::Input values, ::tensorflow::Input shape,
1333 ::tensorflow::Input start, ::tensorflow::Input size);
1334
1335 Operation operation;
1336 ::tensorflow::Output output_indices;
1337 ::tensorflow::Output output_values;
1338 ::tensorflow::Output output_shape;
1339};
1340
1341/// The gradient operator for the SparseSlice op.
1342///
1343/// This op takes in the upstream gradient w.r.t. non-empty values of
1344/// the sliced `SparseTensor`, and outputs the gradients w.r.t.
1345/// the non-empty values of input `SparseTensor`.
1346///
1347/// Args:
1348/// * scope: A Scope object
1349/// * backprop_val_grad: 1-D. The gradient with respect to
1350/// the non-empty values of the sliced `SparseTensor`.
1351/// * input_indices: 2-D. The `indices` of the input `SparseTensor`.
1352/// * input_start: 1-D. tensor represents the start of the slice.
1353/// * output_indices: 2-D. The `indices` of the sliced `SparseTensor`.
1354///
1355/// Returns:
1356/// * `Output`: 1-D. The gradient with respect to the non-empty values of input `SparseTensor`.
1357class SparseSliceGrad {
1358 public:
1359 SparseSliceGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
1360 backprop_val_grad, ::tensorflow::Input input_indices,
1361 ::tensorflow::Input input_start, ::tensorflow::Input
1362 output_indices);
1363 operator ::tensorflow::Output() const { return val_grad; }
1364 operator ::tensorflow::Input() const { return val_grad; }
1365 ::tensorflow::Node* node() const { return val_grad.node(); }
1366
1367 Operation operation;
1368 ::tensorflow::Output val_grad;
1369};
1370
1371/// Applies softmax to a batched N-D `SparseTensor`.
1372///
1373/// The inputs represent an N-D SparseTensor with logical shape `[..., B, C]`
1374/// (where `N >= 2`), and with indices sorted in the canonical lexicographic order.
1375///
1376/// This op is equivalent to applying the normal `tf.nn.softmax()` to each innermost
1377/// logical submatrix with shape `[B, C]`, but with the catch that *the implicitly
1378/// zero elements do not participate*. Specifically, the algorithm is equivalent
1379/// to the following:
1380///
1381/// (1) Applies `tf.nn.softmax()` to a densified view of each innermost submatrix
1382/// with shape `[B, C]`, along the size-C dimension;
1383/// (2) Masks out the original implicitly-zero locations;
1384/// (3) Renormalizes the remaining elements.
1385///
1386/// Hence, the `SparseTensor` result has exactly the same non-zero indices and
1387/// shape.
1388///
1389/// Args:
1390/// * scope: A Scope object
1391/// * sp_indices: 2-D. `NNZ x R` matrix with the indices of non-empty values in a
1392/// SparseTensor, in canonical ordering.
1393/// * sp_values: 1-D. `NNZ` non-empty values corresponding to `sp_indices`.
1394/// * sp_shape: 1-D. Shape of the input SparseTensor.
1395///
1396/// Returns:
1397/// * `Output`: 1-D. The `NNZ` values for the result `SparseTensor`.
1398class SparseSoftmax {
1399 public:
1400 SparseSoftmax(const ::tensorflow::Scope& scope, ::tensorflow::Input sp_indices,
1401 ::tensorflow::Input sp_values, ::tensorflow::Input sp_shape);
1402 operator ::tensorflow::Output() const { return output; }
1403 operator ::tensorflow::Input() const { return output; }
1404 ::tensorflow::Node* node() const { return output.node(); }
1405
1406 Operation operation;
1407 ::tensorflow::Output output;
1408};
1409
1410/// Returns the element-wise max of two SparseTensors.
1411///
1412/// Assumes the two SparseTensors have the same shape, i.e., no broadcasting.
1413///
1414/// Args:
1415/// * scope: A Scope object
1416/// * a_indices: 2-D. `N x R` matrix with the indices of non-empty values in a
1417/// SparseTensor, in the canonical lexicographic ordering.
1418/// * a_values: 1-D. `N` non-empty values corresponding to `a_indices`.
1419/// * a_shape: 1-D. Shape of the input SparseTensor.
1420/// * b_indices: counterpart to `a_indices` for the other operand.
1421/// * b_values: counterpart to `a_values` for the other operand; must be of the same dtype.
1422/// * b_shape: counterpart to `a_shape` for the other operand; the two shapes must be equal.
1423///
1424/// Returns:
1425/// * `Output` output_indices: 2-D. The indices of the output SparseTensor.
1426/// * `Output` output_values: 1-D. The values of the output SparseTensor.
1427class SparseSparseMaximum {
1428 public:
1429 SparseSparseMaximum(const ::tensorflow::Scope& scope, ::tensorflow::Input
1430 a_indices, ::tensorflow::Input a_values,
1431 ::tensorflow::Input a_shape, ::tensorflow::Input b_indices,
1432 ::tensorflow::Input b_values, ::tensorflow::Input b_shape);
1433
1434 Operation operation;
1435 ::tensorflow::Output output_indices;
1436 ::tensorflow::Output output_values;
1437};
1438
1439/// Returns the element-wise min of two SparseTensors.
1440///
1441/// Assumes the two SparseTensors have the same shape, i.e., no broadcasting.
1442///
1443/// Args:
1444/// * scope: A Scope object
1445/// * a_indices: 2-D. `N x R` matrix with the indices of non-empty values in a
1446/// SparseTensor, in the canonical lexicographic ordering.
1447/// * a_values: 1-D. `N` non-empty values corresponding to `a_indices`.
1448/// * a_shape: 1-D. Shape of the input SparseTensor.
1449/// * b_indices: counterpart to `a_indices` for the other operand.
1450/// * b_values: counterpart to `a_values` for the other operand; must be of the same dtype.
1451/// * b_shape: counterpart to `a_shape` for the other operand; the two shapes must be equal.
1452///
1453/// Returns:
1454/// * `Output` output_indices: 2-D. The indices of the output SparseTensor.
1455/// * `Output` output_values: 1-D. The values of the output SparseTensor.
1456class SparseSparseMinimum {
1457 public:
1458 SparseSparseMinimum(const ::tensorflow::Scope& scope, ::tensorflow::Input
1459 a_indices, ::tensorflow::Input a_values,
1460 ::tensorflow::Input a_shape, ::tensorflow::Input b_indices,
1461 ::tensorflow::Input b_values, ::tensorflow::Input b_shape);
1462
1463 Operation operation;
1464 ::tensorflow::Output output_indices;
1465 ::tensorflow::Output output_values;
1466};
1467
1468/// Split a `SparseTensor` into `num_split` tensors along one dimension.
1469///
1470/// If the `shape[split_dim]` is not an integer multiple of `num_split`. Slices
1471/// `[0 : shape[split_dim] % num_split]` gets one extra dimension.
1472/// For example, if `split_dim = 1` and `num_split = 2` and the input is
1473///
1474/// input_tensor = shape = [2, 7]
1475/// [ a d e ]
1476/// [b c ]
1477///
1478/// Graphically the output tensors are:
1479///
1480/// output_tensor[0] = shape = [2, 4]
1481/// [ a ]
1482/// [b c ]
1483///
1484/// output_tensor[1] = shape = [2, 3]
1485/// [ d e ]
1486/// [ ]
1487///
1488/// Args:
1489/// * scope: A Scope object
1490/// * split_dim: 0-D. The dimension along which to split. Must be in the range
1491/// `[0, rank(shape))`.
1492/// * indices: 2-D tensor represents the indices of the sparse tensor.
1493/// * values: 1-D tensor represents the values of the sparse tensor.
1494/// * shape: 1-D. tensor represents the shape of the sparse tensor.
1495/// output indices: A list of 1-D tensors represents the indices of the output
1496/// sparse tensors.
1497/// * num_split: The number of ways to split.
1498///
1499/// Returns:
1500/// * `OutputList` output_indices
1501/// * `OutputList` output_values: A list of 1-D tensors represents the values of the output sparse
1502/// tensors.
1503/// * `OutputList` output_shape: A list of 1-D tensors represents the shape of the output sparse
1504/// tensors.
1505class SparseSplit {
1506 public:
1507 SparseSplit(const ::tensorflow::Scope& scope, ::tensorflow::Input split_dim,
1508 ::tensorflow::Input indices, ::tensorflow::Input values,
1509 ::tensorflow::Input shape, int64 num_split);
1510
1511 Operation operation;
1512 ::tensorflow::OutputList output_indices;
1513 ::tensorflow::OutputList output_values;
1514 ::tensorflow::OutputList output_shape;
1515};
1516
1517/// Adds up a `SparseTensor` and a dense `Tensor`, producing a dense `Tensor`.
1518///
1519/// This Op does not require `a_indices` be sorted in standard lexicographic order.
1520///
1521/// Args:
1522/// * scope: A Scope object
1523/// * a_indices: 2-D. The `indices` of the `SparseTensor`, with shape `[nnz, ndims]`.
1524/// * a_values: 1-D. The `values` of the `SparseTensor`, with shape `[nnz]`.
1525/// * a_shape: 1-D. The `shape` of the `SparseTensor`, with shape `[ndims]`.
1526/// * b: `ndims`-D Tensor. With shape `a_shape`.
1527///
1528/// Returns:
1529/// * `Output`: The output tensor.
1530class SparseTensorDenseAdd {
1531 public:
1532 SparseTensorDenseAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input
1533 a_indices, ::tensorflow::Input a_values,
1534 ::tensorflow::Input a_shape, ::tensorflow::Input b);
1535 operator ::tensorflow::Output() const { return output; }
1536 operator ::tensorflow::Input() const { return output; }
1537 ::tensorflow::Node* node() const { return output.node(); }
1538
1539 Operation operation;
1540 ::tensorflow::Output output;
1541};
1542
1543/// Multiply SparseTensor (of rank 2) "A" by dense matrix "B".
1544///
1545/// No validity checking is performed on the indices of A. However, the following
1546/// input format is recommended for optimal behavior:
1547///
1548/// if adjoint_a == false:
1549/// A should be sorted in lexicographically increasing order. Use SparseReorder
1550/// if you're not sure.
1551/// if adjoint_a == true:
1552/// A should be sorted in order of increasing dimension 1 (i.e., "column major"
1553/// order instead of "row major" order).
1554///
1555/// Args:
1556/// * scope: A Scope object
1557/// * a_indices: 2-D. The `indices` of the `SparseTensor`, size `[nnz, 2]` Matrix.
1558/// * a_values: 1-D. The `values` of the `SparseTensor`, size `[nnz]` Vector.
1559/// * a_shape: 1-D. The `shape` of the `SparseTensor`, size `[2]` Vector.
1560/// * b: 2-D. A dense Matrix.
1561///
1562/// Optional attributes (see `Attrs`):
1563/// * adjoint_a: Use the adjoint of A in the matrix multiply. If A is complex, this
1564/// is transpose(conj(A)). Otherwise it's transpose(A).
1565/// * adjoint_b: Use the adjoint of B in the matrix multiply. If B is complex, this
1566/// is transpose(conj(B)). Otherwise it's transpose(B).
1567///
1568/// Returns:
1569/// * `Output`: The product tensor.
1570class SparseTensorDenseMatMul {
1571 public:
1572 /// Optional attribute setters for SparseTensorDenseMatMul
1573 struct Attrs {
1574 /// Use the adjoint of A in the matrix multiply. If A is complex, this
1575 /// is transpose(conj(A)). Otherwise it's transpose(A).
1576 ///
1577 /// Defaults to false
1578 TF_MUST_USE_RESULT Attrs AdjointA(bool x) {
1579 Attrs ret = *this;
1580 ret.adjoint_a_ = x;
1581 return ret;
1582 }
1583
1584 /// Use the adjoint of B in the matrix multiply. If B is complex, this
1585 /// is transpose(conj(B)). Otherwise it's transpose(B).
1586 ///
1587 /// Defaults to false
1588 TF_MUST_USE_RESULT Attrs AdjointB(bool x) {
1589 Attrs ret = *this;
1590 ret.adjoint_b_ = x;
1591 return ret;
1592 }
1593
1594 bool adjoint_a_ = false;
1595 bool adjoint_b_ = false;
1596 };
1597 SparseTensorDenseMatMul(const ::tensorflow::Scope& scope, ::tensorflow::Input
1598 a_indices, ::tensorflow::Input a_values,
1599 ::tensorflow::Input a_shape, ::tensorflow::Input b);
1600 SparseTensorDenseMatMul(const ::tensorflow::Scope& scope, ::tensorflow::Input
1601 a_indices, ::tensorflow::Input a_values,
1602 ::tensorflow::Input a_shape, ::tensorflow::Input b,
1603 const SparseTensorDenseMatMul::Attrs& attrs);
1604 operator ::tensorflow::Output() const { return product; }
1605 operator ::tensorflow::Input() const { return product; }
1606 ::tensorflow::Node* node() const { return product.node(); }
1607
1608 static Attrs AdjointA(bool x) {
1609 return Attrs().AdjointA(x);
1610 }
1611 static Attrs AdjointB(bool x) {
1612 return Attrs().AdjointB(x);
1613 }
1614
1615 Operation operation;
1616 ::tensorflow::Output product;
1617};
1618
1619/// Converts a sparse representation into a dense tensor.
1620///
1621/// Builds an array `dense` with shape `output_shape` such that
1622///
1623/// ```
1624/// # If sparse_indices is scalar
1625/// dense[i] = (i == sparse_indices ? sparse_values : default_value)
1626///
1627/// # If sparse_indices is a vector, then for each i
1628/// dense[sparse_indices[i]] = sparse_values[i]
1629///
1630/// # If sparse_indices is an n by d matrix, then for each i in [0, n)
1631/// dense[sparse_indices[i][0], ..., sparse_indices[i][d-1]] = sparse_values[i]
1632/// ```
1633///
1634/// All other values in `dense` are set to `default_value`. If `sparse_values` is a
1635/// scalar, all sparse indices are set to this single value.
1636///
1637/// Indices should be sorted in lexicographic order, and indices must not
1638/// contain any repeats. If `validate_indices` is true, these properties
1639/// are checked during execution.
1640///
1641/// Args:
1642/// * scope: A Scope object
1643/// * sparse_indices: 0-D, 1-D, or 2-D. `sparse_indices[i]` contains the complete
1644/// index where `sparse_values[i]` will be placed.
1645/// * output_shape: 1-D. Shape of the dense output tensor.
1646/// * sparse_values: 1-D. Values corresponding to each row of `sparse_indices`,
1647/// or a scalar value to be used for all sparse indices.
1648/// * default_value: Scalar value to set for indices not specified in
1649/// `sparse_indices`.
1650///
1651/// Optional attributes (see `Attrs`):
1652/// * validate_indices: If true, indices are checked to make sure they are sorted in
1653/// lexicographic order and that there are no repeats.
1654///
1655/// Returns:
1656/// * `Output`: Dense output tensor of shape `output_shape`.
1657class SparseToDense {
1658 public:
1659 /// Optional attribute setters for SparseToDense
1660 struct Attrs {
1661 /// If true, indices are checked to make sure they are sorted in
1662 /// lexicographic order and that there are no repeats.
1663 ///
1664 /// Defaults to true
1665 TF_MUST_USE_RESULT Attrs ValidateIndices(bool x) {
1666 Attrs ret = *this;
1667 ret.validate_indices_ = x;
1668 return ret;
1669 }
1670
1671 bool validate_indices_ = true;
1672 };
1673 SparseToDense(const ::tensorflow::Scope& scope, ::tensorflow::Input
1674 sparse_indices, ::tensorflow::Input output_shape,
1675 ::tensorflow::Input sparse_values, ::tensorflow::Input
1676 default_value);
1677 SparseToDense(const ::tensorflow::Scope& scope, ::tensorflow::Input
1678 sparse_indices, ::tensorflow::Input output_shape,
1679 ::tensorflow::Input sparse_values, ::tensorflow::Input
1680 default_value, const SparseToDense::Attrs& attrs);
1681 operator ::tensorflow::Output() const { return dense; }
1682 operator ::tensorflow::Input() const { return dense; }
1683 ::tensorflow::Node* node() const { return dense.node(); }
1684
1685 static Attrs ValidateIndices(bool x) {
1686 return Attrs().ValidateIndices(x);
1687 }
1688
1689 Operation operation;
1690 ::tensorflow::Output dense;
1691};
1692
1693/// Read `SparseTensors` from a `SparseTensorsMap` and concatenate them.
1694///
1695/// The input `sparse_handles` must be an `int64` matrix of shape `[N, 1]` where
1696/// `N` is the minibatch size and the rows correspond to the output handles of
1697/// `AddSparseToTensorsMap` or `AddManySparseToTensorsMap`. The ranks of the
1698/// original `SparseTensor` objects that went into the given input ops must all
1699/// match. When the final `SparseTensor` is created, it has rank one
1700/// higher than the ranks of the incoming `SparseTensor` objects
1701/// (they have been concatenated along a new row dimension on the left).
1702///
1703/// The output `SparseTensor` object's shape values for all dimensions but the
1704/// first are the max across the input `SparseTensor` objects' shape values
1705/// for the corresponding dimensions. Its first shape value is `N`, the minibatch
1706/// size.
1707///
1708/// The input `SparseTensor` objects' indices are assumed ordered in
1709/// standard lexicographic order. If this is not the case, after this
1710/// step run `SparseReorder` to restore index ordering.
1711///
1712/// For example, if the handles represent an input, which is a `[2, 3]` matrix
1713/// representing two original `SparseTensor` objects:
1714///
1715/// ```
1716/// index = [ 0]
1717/// [10]
1718/// [20]
1719/// values = [1, 2, 3]
1720/// shape = [50]
1721/// ```
1722///
1723/// and
1724///
1725/// ```
1726/// index = [ 2]
1727/// [10]
1728/// values = [4, 5]
1729/// shape = [30]
1730/// ```
1731///
1732/// then the final `SparseTensor` will be:
1733///
1734/// ```
1735/// index = [0 0]
1736/// [0 10]
1737/// [0 20]
1738/// [1 2]
1739/// [1 10]
1740/// values = [1, 2, 3, 4, 5]
1741/// shape = [2 50]
1742/// ```
1743///
1744/// Args:
1745/// * scope: A Scope object
1746/// * sparse_handles: 1-D, The `N` serialized `SparseTensor` objects.
1747/// Shape: `[N]`.
1748/// * dtype: The `dtype` of the `SparseTensor` objects stored in the
1749/// `SparseTensorsMap`.
1750///
1751/// Optional attributes (see `Attrs`):
1752/// * container: The container name for the `SparseTensorsMap` read by this op.
1753/// * shared_name: The shared name for the `SparseTensorsMap` read by this op.
1754/// It should not be blank; rather the `shared_name` or unique Operation name
1755/// of the Op that created the original `SparseTensorsMap` should be used.
1756///
1757/// Returns:
1758/// * `Output` sparse_indices: 2-D. The `indices` of the minibatch `SparseTensor`.
1759/// * `Output` sparse_values: 1-D. The `values` of the minibatch `SparseTensor`.
1760/// * `Output` sparse_shape: 1-D. The `shape` of the minibatch `SparseTensor`.
1761class TakeManySparseFromTensorsMap {
1762 public:
1763 /// Optional attribute setters for TakeManySparseFromTensorsMap
1764 struct Attrs {
1765 /// The container name for the `SparseTensorsMap` read by this op.
1766 ///
1767 /// Defaults to ""
1768 TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
1769 Attrs ret = *this;
1770 ret.container_ = x;
1771 return ret;
1772 }
1773
1774 /// The shared name for the `SparseTensorsMap` read by this op.
1775 /// It should not be blank; rather the `shared_name` or unique Operation name
1776 /// of the Op that created the original `SparseTensorsMap` should be used.
1777 ///
1778 /// Defaults to ""
1779 TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
1780 Attrs ret = *this;
1781 ret.shared_name_ = x;
1782 return ret;
1783 }
1784
1785 StringPiece container_ = "";
1786 StringPiece shared_name_ = "";
1787 };
1788 TakeManySparseFromTensorsMap(const ::tensorflow::Scope& scope,
1789 ::tensorflow::Input sparse_handles, DataType
1790 dtype);
1791 TakeManySparseFromTensorsMap(const ::tensorflow::Scope& scope,
1792 ::tensorflow::Input sparse_handles, DataType
1793 dtype, const TakeManySparseFromTensorsMap::Attrs&
1794 attrs);
1795
1796 static Attrs Container(StringPiece x) {
1797 return Attrs().Container(x);
1798 }
1799 static Attrs SharedName(StringPiece x) {
1800 return Attrs().SharedName(x);
1801 }
1802
1803 Operation operation;
1804 ::tensorflow::Output sparse_indices;
1805 ::tensorflow::Output sparse_values;
1806 ::tensorflow::Output sparse_shape;
1807};
1808
1809/// @}
1810
1811} // namespace ops
1812} // namespace tensorflow
1813
1814#endif // TENSORFLOW_CC_OPS_SPARSE_OPS_H_
1815