1 | // This file is MACHINE GENERATED! Do not edit. |
2 | |
3 | #ifndef TENSORFLOW_CC_OPS_STATE_OPS_H_ |
4 | #define TENSORFLOW_CC_OPS_STATE_OPS_H_ |
5 | |
6 | // This file is MACHINE GENERATED! Do not edit. |
7 | |
8 | #include "tensorflow/cc/framework/ops.h" |
9 | #include "tensorflow/cc/framework/scope.h" |
10 | #include "tensorflow/core/framework/tensor.h" |
11 | #include "tensorflow/core/framework/tensor_shape.h" |
12 | #include "tensorflow/core/framework/types.h" |
13 | #include "tensorflow/core/lib/gtl/array_slice.h" |
14 | |
15 | namespace tensorflow { |
16 | namespace ops { |
17 | |
18 | /// @defgroup state_ops State Ops |
19 | /// @{ |
20 | |
21 | /// Update 'ref' by assigning 'value' to it. |
22 | /// |
23 | /// This operation outputs "ref" after the assignment is done. |
24 | /// This makes it easier to chain operations that need to use the reset value. |
25 | /// |
26 | /// Args: |
27 | /// * scope: A Scope object |
28 | /// * ref: Should be from a `Variable` node. May be uninitialized. |
29 | /// * value: The value to be assigned to the variable. |
30 | /// |
31 | /// Optional attributes (see `Attrs`): |
32 | /// * validate_shape: If true, the operation will validate that the shape |
33 | /// of 'value' matches the shape of the Tensor being assigned to. If false, |
34 | /// 'ref' will take on the shape of 'value'. |
35 | /// * use_locking: If True, the assignment will be protected by a lock; |
36 | /// otherwise the behavior is undefined, but may exhibit less contention. |
37 | /// |
38 | /// Returns: |
39 | /// * `Output`: = Same as "ref". Returned as a convenience for operations that want |
40 | /// to use the new value after the variable has been reset. |
41 | class Assign { |
42 | public: |
43 | /// Optional attribute setters for Assign |
44 | struct Attrs { |
45 | /// If true, the operation will validate that the shape |
46 | /// of 'value' matches the shape of the Tensor being assigned to. If false, |
47 | /// 'ref' will take on the shape of 'value'. |
48 | /// |
49 | /// Defaults to true |
50 | TF_MUST_USE_RESULT Attrs ValidateShape(bool x) { |
51 | Attrs ret = *this; |
52 | ret.validate_shape_ = x; |
53 | return ret; |
54 | } |
55 | |
56 | /// If True, the assignment will be protected by a lock; |
57 | /// otherwise the behavior is undefined, but may exhibit less contention. |
58 | /// |
59 | /// Defaults to true |
60 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
61 | Attrs ret = *this; |
62 | ret.use_locking_ = x; |
63 | return ret; |
64 | } |
65 | |
66 | bool validate_shape_ = true; |
67 | bool use_locking_ = true; |
68 | }; |
69 | Assign(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
70 | ::tensorflow::Input value); |
71 | Assign(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
72 | ::tensorflow::Input value, const Assign::Attrs& attrs); |
73 | operator ::tensorflow::Output() const { return output_ref; } |
74 | operator ::tensorflow::Input() const { return output_ref; } |
75 | ::tensorflow::Node* node() const { return output_ref.node(); } |
76 | |
77 | static Attrs ValidateShape(bool x) { |
78 | return Attrs().ValidateShape(x); |
79 | } |
80 | static Attrs UseLocking(bool x) { |
81 | return Attrs().UseLocking(x); |
82 | } |
83 | |
84 | Operation operation; |
85 | ::tensorflow::Output output_ref; |
86 | }; |
87 | |
88 | /// Update 'ref' by adding 'value' to it. |
89 | /// |
90 | /// This operation outputs "ref" after the update is done. |
91 | /// This makes it easier to chain operations that need to use the reset value. |
92 | /// |
93 | /// Args: |
94 | /// * scope: A Scope object |
95 | /// * ref: Should be from a `Variable` node. |
96 | /// * value: The value to be added to the variable. |
97 | /// |
98 | /// Optional attributes (see `Attrs`): |
99 | /// * use_locking: If True, the addition will be protected by a lock; |
100 | /// otherwise the behavior is undefined, but may exhibit less contention. |
101 | /// |
102 | /// Returns: |
103 | /// * `Output`: = Same as "ref". Returned as a convenience for operations that want |
104 | /// to use the new value after the variable has been updated. |
105 | class AssignAdd { |
106 | public: |
107 | /// Optional attribute setters for AssignAdd |
108 | struct Attrs { |
109 | /// If True, the addition will be protected by a lock; |
110 | /// otherwise the behavior is undefined, but may exhibit less contention. |
111 | /// |
112 | /// Defaults to false |
113 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
114 | Attrs ret = *this; |
115 | ret.use_locking_ = x; |
116 | return ret; |
117 | } |
118 | |
119 | bool use_locking_ = false; |
120 | }; |
121 | AssignAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
122 | ::tensorflow::Input value); |
123 | AssignAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
124 | ::tensorflow::Input value, const AssignAdd::Attrs& attrs); |
125 | operator ::tensorflow::Output() const { return output_ref; } |
126 | operator ::tensorflow::Input() const { return output_ref; } |
127 | ::tensorflow::Node* node() const { return output_ref.node(); } |
128 | |
129 | static Attrs UseLocking(bool x) { |
130 | return Attrs().UseLocking(x); |
131 | } |
132 | |
133 | Operation operation; |
134 | ::tensorflow::Output output_ref; |
135 | }; |
136 | |
137 | /// Update 'ref' by subtracting 'value' from it. |
138 | /// |
139 | /// This operation outputs "ref" after the update is done. |
140 | /// This makes it easier to chain operations that need to use the reset value. |
141 | /// |
142 | /// Args: |
143 | /// * scope: A Scope object |
144 | /// * ref: Should be from a `Variable` node. |
145 | /// * value: The value to be subtracted to the variable. |
146 | /// |
147 | /// Optional attributes (see `Attrs`): |
148 | /// * use_locking: If True, the subtraction will be protected by a lock; |
149 | /// otherwise the behavior is undefined, but may exhibit less contention. |
150 | /// |
151 | /// Returns: |
152 | /// * `Output`: = Same as "ref". Returned as a convenience for operations that want |
153 | /// to use the new value after the variable has been updated. |
154 | class AssignSub { |
155 | public: |
156 | /// Optional attribute setters for AssignSub |
157 | struct Attrs { |
158 | /// If True, the subtraction will be protected by a lock; |
159 | /// otherwise the behavior is undefined, but may exhibit less contention. |
160 | /// |
161 | /// Defaults to false |
162 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
163 | Attrs ret = *this; |
164 | ret.use_locking_ = x; |
165 | return ret; |
166 | } |
167 | |
168 | bool use_locking_ = false; |
169 | }; |
170 | AssignSub(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
171 | ::tensorflow::Input value); |
172 | AssignSub(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
173 | ::tensorflow::Input value, const AssignSub::Attrs& attrs); |
174 | operator ::tensorflow::Output() const { return output_ref; } |
175 | operator ::tensorflow::Input() const { return output_ref; } |
176 | ::tensorflow::Node* node() const { return output_ref.node(); } |
177 | |
178 | static Attrs UseLocking(bool x) { |
179 | return Attrs().UseLocking(x); |
180 | } |
181 | |
182 | Operation operation; |
183 | ::tensorflow::Output output_ref; |
184 | }; |
185 | |
186 | /// Increments 'ref' until it reaches 'limit'. |
187 | /// |
188 | /// Args: |
189 | /// * scope: A Scope object |
190 | /// * ref: Should be from a scalar `Variable` node. |
191 | /// * limit: If incrementing ref would bring it above limit, instead generates an |
192 | /// 'OutOfRange' error. |
193 | /// |
194 | /// Returns: |
195 | /// * `Output`: A copy of the input before increment. If nothing else modifies the |
196 | /// input, the values produced will all be distinct. |
197 | class CountUpTo { |
198 | public: |
199 | CountUpTo(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, int64 |
200 | limit); |
201 | operator ::tensorflow::Output() const { return output; } |
202 | operator ::tensorflow::Input() const { return output; } |
203 | ::tensorflow::Node* node() const { return output.node(); } |
204 | |
205 | Operation operation; |
206 | ::tensorflow::Output output; |
207 | }; |
208 | |
209 | /// Destroys the temporary variable and returns its final value. |
210 | /// |
211 | /// Sets output to the value of the Tensor pointed to by 'ref', then destroys |
212 | /// the temporary variable called 'var_name'. |
213 | /// All other uses of 'ref' *must* have executed before this op. |
214 | /// This is typically achieved by chaining the ref through each assign op, or by |
215 | /// using control dependencies. |
216 | /// |
217 | /// Outputs the final value of the tensor pointed to by 'ref'. |
218 | /// |
219 | /// Args: |
220 | /// * scope: A Scope object |
221 | /// * ref: A reference to the temporary variable tensor. |
222 | /// * var_name: Name of the temporary variable, usually the name of the matching |
223 | /// 'TemporaryVariable' op. |
224 | /// |
225 | /// Returns: |
226 | /// * `Output`: The value tensor. |
227 | class DestroyTemporaryVariable { |
228 | public: |
229 | DestroyTemporaryVariable(const ::tensorflow::Scope& scope, ::tensorflow::Input |
230 | ref, StringPiece var_name); |
231 | operator ::tensorflow::Output() const { return value; } |
232 | operator ::tensorflow::Input() const { return value; } |
233 | ::tensorflow::Node* node() const { return value.node(); } |
234 | |
235 | Operation operation; |
236 | ::tensorflow::Output value; |
237 | }; |
238 | |
239 | /// Checks whether a tensor has been initialized. |
240 | /// |
241 | /// Outputs boolean scalar indicating whether the tensor has been initialized. |
242 | /// |
243 | /// Args: |
244 | /// * scope: A Scope object |
245 | /// * ref: Should be from a `Variable` node. May be uninitialized. |
246 | /// |
247 | /// Returns: |
248 | /// * `Output`: The is_initialized tensor. |
249 | class IsVariableInitialized { |
250 | public: |
251 | IsVariableInitialized(const ::tensorflow::Scope& scope, ::tensorflow::Input |
252 | ref); |
253 | operator ::tensorflow::Output() const { return is_initialized; } |
254 | operator ::tensorflow::Input() const { return is_initialized; } |
255 | ::tensorflow::Node* node() const { return is_initialized.node(); } |
256 | |
257 | Operation operation; |
258 | ::tensorflow::Output is_initialized; |
259 | }; |
260 | |
261 | /// Increments variable pointed to by 'resource' until it reaches 'limit'. |
262 | /// |
263 | /// Args: |
264 | /// * scope: A Scope object |
265 | /// * resource: Should be from a scalar `Variable` node. |
266 | /// * limit: If incrementing ref would bring it above limit, instead generates an |
267 | /// 'OutOfRange' error. |
268 | /// |
269 | /// Returns: |
270 | /// * `Output`: A copy of the input before increment. If nothing else modifies the |
271 | /// input, the values produced will all be distinct. |
272 | class ResourceCountUpTo { |
273 | public: |
274 | ResourceCountUpTo(const ::tensorflow::Scope& scope, ::tensorflow::Input |
275 | resource, int64 limit, DataType T); |
276 | operator ::tensorflow::Output() const { return output; } |
277 | operator ::tensorflow::Input() const { return output; } |
278 | ::tensorflow::Node* node() const { return output.node(); } |
279 | |
280 | Operation operation; |
281 | ::tensorflow::Output output; |
282 | }; |
283 | |
284 | /// Applies sparse addition to individual values or slices in a Variable. |
285 | /// |
286 | /// `ref` is a `Tensor` with rank `P` and `indices` is a `Tensor` of rank `Q`. |
287 | /// |
288 | /// `indices` must be integer tensor, containing indices into `ref`. |
289 | /// It must be shape `[d_0, ..., d_{Q-2}, K]` where `0 < K <= P`. |
290 | /// |
291 | /// The innermost dimension of `indices` (with length `K`) corresponds to |
292 | /// indices into elements (if `K = P`) or slices (if `K < P`) along the `K`th |
293 | /// dimension of `ref`. |
294 | /// |
295 | /// `updates` is `Tensor` of rank `Q-1+P-K` with shape: |
296 | /// |
297 | /// ``` |
298 | /// [d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]] |
299 | /// ``` |
300 | /// |
301 | /// For example, say we want to add 4 scattered elements to a rank-1 tensor to |
302 | /// 8 elements. In Python, that addition would look like this: |
303 | /// |
304 | /// ```python |
305 | /// ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8], use_resource=True) |
306 | /// indices = tf.constant([[4], [3], [1], [7]]) |
307 | /// updates = tf.constant([9, 10, 11, 12]) |
308 | /// add = tf.scatter_nd_add(ref, indices, updates) |
309 | /// with tf.Session() as sess: |
310 | /// print sess.run(add) |
311 | /// ``` |
312 | /// |
313 | /// The resulting update to ref would look like this: |
314 | /// |
315 | /// [1, 13, 3, 14, 14, 6, 7, 20] |
316 | /// |
317 | /// See `tf.scatter_nd` for more details about how to make updates to |
318 | /// slices. |
319 | /// |
320 | /// Args: |
321 | /// * scope: A Scope object |
322 | /// * ref: A resource handle. Must be from a VarHandleOp. |
323 | /// * indices: A Tensor. Must be one of the following types: int32, int64. |
324 | /// A tensor of indices into ref. |
325 | /// * updates: A Tensor. Must have the same type as ref. A tensor of |
326 | /// values to add to ref. |
327 | /// |
328 | /// Optional attributes (see `Attrs`): |
329 | /// * use_locking: An optional bool. Defaults to True. If True, the assignment will |
330 | /// be protected by a lock; otherwise the behavior is undefined, |
331 | /// but may exhibit less contention. |
332 | /// |
333 | /// Returns: |
334 | /// * the created `Operation` |
335 | class ResourceScatterNdAdd { |
336 | public: |
337 | /// Optional attribute setters for ResourceScatterNdAdd |
338 | struct Attrs { |
339 | /// An optional bool. Defaults to True. If True, the assignment will |
340 | /// be protected by a lock; otherwise the behavior is undefined, |
341 | /// but may exhibit less contention. |
342 | /// |
343 | /// Defaults to true |
344 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
345 | Attrs ret = *this; |
346 | ret.use_locking_ = x; |
347 | return ret; |
348 | } |
349 | |
350 | bool use_locking_ = true; |
351 | }; |
352 | ResourceScatterNdAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
353 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
354 | ResourceScatterNdAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
355 | ::tensorflow::Input indices, ::tensorflow::Input updates, |
356 | const ResourceScatterNdAdd::Attrs& attrs); |
357 | operator ::tensorflow::Operation() const { return operation; } |
358 | |
359 | static Attrs UseLocking(bool x) { |
360 | return Attrs().UseLocking(x); |
361 | } |
362 | |
363 | Operation operation; |
364 | }; |
365 | |
366 | /// TODO: add doc. |
367 | /// |
368 | /// Args: |
369 | /// * scope: A Scope object |
370 | /// * ref: A resource handle. Must be from a VarHandleOp. |
371 | /// * indices: A Tensor. Must be one of the following types: int32, int64. |
372 | /// A tensor of indices into ref. |
373 | /// * updates: A Tensor. Must have the same type as ref. A tensor of |
374 | /// values whose element wise max is taken with ref |
375 | /// |
376 | /// Optional attributes (see `Attrs`): |
377 | /// * use_locking: An optional bool. Defaults to True. If True, the assignment will |
378 | /// be protected by a lock; otherwise the behavior is undefined, |
379 | /// but may exhibit less contention. |
380 | /// |
381 | /// Returns: |
382 | /// * the created `Operation` |
383 | class ResourceScatterNdMax { |
384 | public: |
385 | /// Optional attribute setters for ResourceScatterNdMax |
386 | struct Attrs { |
387 | /// An optional bool. Defaults to True. If True, the assignment will |
388 | /// be protected by a lock; otherwise the behavior is undefined, |
389 | /// but may exhibit less contention. |
390 | /// |
391 | /// Defaults to true |
392 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
393 | Attrs ret = *this; |
394 | ret.use_locking_ = x; |
395 | return ret; |
396 | } |
397 | |
398 | bool use_locking_ = true; |
399 | }; |
400 | ResourceScatterNdMax(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
401 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
402 | ResourceScatterNdMax(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
403 | ::tensorflow::Input indices, ::tensorflow::Input updates, |
404 | const ResourceScatterNdMax::Attrs& attrs); |
405 | operator ::tensorflow::Operation() const { return operation; } |
406 | |
407 | static Attrs UseLocking(bool x) { |
408 | return Attrs().UseLocking(x); |
409 | } |
410 | |
411 | Operation operation; |
412 | }; |
413 | |
414 | /// TODO: add doc. |
415 | /// |
416 | /// Args: |
417 | /// * scope: A Scope object |
418 | /// * ref: A resource handle. Must be from a VarHandleOp. |
419 | /// * indices: A Tensor. Must be one of the following types: int32, int64. |
420 | /// A tensor of indices into ref. |
421 | /// * updates: A Tensor. Must have the same type as ref. A tensor of |
422 | /// values whose element wise min is taken with ref. |
423 | /// |
424 | /// Optional attributes (see `Attrs`): |
425 | /// * use_locking: An optional bool. Defaults to True. If True, the assignment will |
426 | /// be protected by a lock; otherwise the behavior is undefined, |
427 | /// but may exhibit less contention. |
428 | /// |
429 | /// Returns: |
430 | /// * the created `Operation` |
431 | class ResourceScatterNdMin { |
432 | public: |
433 | /// Optional attribute setters for ResourceScatterNdMin |
434 | struct Attrs { |
435 | /// An optional bool. Defaults to True. If True, the assignment will |
436 | /// be protected by a lock; otherwise the behavior is undefined, |
437 | /// but may exhibit less contention. |
438 | /// |
439 | /// Defaults to true |
440 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
441 | Attrs ret = *this; |
442 | ret.use_locking_ = x; |
443 | return ret; |
444 | } |
445 | |
446 | bool use_locking_ = true; |
447 | }; |
448 | ResourceScatterNdMin(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
449 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
450 | ResourceScatterNdMin(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
451 | ::tensorflow::Input indices, ::tensorflow::Input updates, |
452 | const ResourceScatterNdMin::Attrs& attrs); |
453 | operator ::tensorflow::Operation() const { return operation; } |
454 | |
455 | static Attrs UseLocking(bool x) { |
456 | return Attrs().UseLocking(x); |
457 | } |
458 | |
459 | Operation operation; |
460 | }; |
461 | |
462 | /// Applies sparse subtraction to individual values or slices in a Variable. |
463 | /// |
464 | /// `ref` is a `Tensor` with rank `P` and `indices` is a `Tensor` of rank `Q`. |
465 | /// |
466 | /// `indices` must be integer tensor, containing indices into `ref`. |
467 | /// It must be shape `[d_0, ..., d_{Q-2}, K]` where `0 < K <= P`. |
468 | /// |
469 | /// The innermost dimension of `indices` (with length `K`) corresponds to |
470 | /// indices into elements (if `K = P`) or slices (if `K < P`) along the `K`th |
471 | /// dimension of `ref`. |
472 | /// |
473 | /// `updates` is `Tensor` of rank `Q-1+P-K` with shape: |
474 | /// |
475 | /// ``` |
476 | /// [d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]] |
477 | /// ``` |
478 | /// |
479 | /// For example, say we want to subtract 4 scattered elements from a rank-1 tensor |
480 | /// with 8 elements. In Python, that subtraction would look like this: |
481 | /// |
482 | /// ```python |
483 | /// ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8], use_resource=True) |
484 | /// indices = tf.constant([[4], [3], [1], [7]]) |
485 | /// updates = tf.constant([9, 10, 11, 12]) |
486 | /// sub = tf.scatter_nd_sub(ref, indices, updates) |
487 | /// with tf.Session() as sess: |
488 | /// print sess.run(sub) |
489 | /// ``` |
490 | /// |
491 | /// The resulting update to ref would look like this: |
492 | /// |
493 | /// [1, -9, 3, -6, -4, 6, 7, -4] |
494 | /// |
495 | /// See `tf.scatter_nd` for more details about how to make updates to |
496 | /// slices. |
497 | /// |
498 | /// Args: |
499 | /// * scope: A Scope object |
500 | /// * ref: A resource handle. Must be from a VarHandleOp. |
501 | /// * indices: A Tensor. Must be one of the following types: int32, int64. |
502 | /// A tensor of indices into ref. |
503 | /// * updates: A Tensor. Must have the same type as ref. A tensor of |
504 | /// values to add to ref. |
505 | /// |
506 | /// Optional attributes (see `Attrs`): |
507 | /// * use_locking: An optional bool. Defaults to True. If True, the assignment will |
508 | /// be protected by a lock; otherwise the behavior is undefined, |
509 | /// but may exhibit less contention. |
510 | /// |
511 | /// Returns: |
512 | /// * the created `Operation` |
513 | class ResourceScatterNdSub { |
514 | public: |
515 | /// Optional attribute setters for ResourceScatterNdSub |
516 | struct Attrs { |
517 | /// An optional bool. Defaults to True. If True, the assignment will |
518 | /// be protected by a lock; otherwise the behavior is undefined, |
519 | /// but may exhibit less contention. |
520 | /// |
521 | /// Defaults to true |
522 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
523 | Attrs ret = *this; |
524 | ret.use_locking_ = x; |
525 | return ret; |
526 | } |
527 | |
528 | bool use_locking_ = true; |
529 | }; |
530 | ResourceScatterNdSub(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
531 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
532 | ResourceScatterNdSub(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
533 | ::tensorflow::Input indices, ::tensorflow::Input updates, |
534 | const ResourceScatterNdSub::Attrs& attrs); |
535 | operator ::tensorflow::Operation() const { return operation; } |
536 | |
537 | static Attrs UseLocking(bool x) { |
538 | return Attrs().UseLocking(x); |
539 | } |
540 | |
541 | Operation operation; |
542 | }; |
543 | |
544 | /// Applies sparse `updates` to individual values or slices within a given |
545 | /// |
546 | /// variable according to `indices`. |
547 | /// |
548 | /// `ref` is a `Tensor` with rank `P` and `indices` is a `Tensor` of rank `Q`. |
549 | /// |
550 | /// `indices` must be integer tensor, containing indices into `ref`. |
551 | /// It must be shape `[d_0, ..., d_{Q-2}, K]` where `0 < K <= P`. |
552 | /// |
553 | /// The innermost dimension of `indices` (with length `K`) corresponds to |
554 | /// indices into elements (if `K = P`) or slices (if `K < P`) along the `K`th |
555 | /// dimension of `ref`. |
556 | /// |
557 | /// `updates` is `Tensor` of rank `Q-1+P-K` with shape: |
558 | /// |
559 | /// ``` |
560 | /// [d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]. |
561 | /// ``` |
562 | /// |
563 | /// For example, say we want to update 4 scattered elements to a rank-1 tensor to |
564 | /// 8 elements. In Python, that update would look like this: |
565 | /// |
566 | /// ```python |
567 | /// ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8]) |
568 | /// indices = tf.constant([[4], [3], [1] ,[7]]) |
569 | /// updates = tf.constant([9, 10, 11, 12]) |
570 | /// update = tf.scatter_nd_update(ref, indices, updates) |
571 | /// with tf.Session() as sess: |
572 | /// print sess.run(update) |
573 | /// ``` |
574 | /// |
575 | /// The resulting update to ref would look like this: |
576 | /// |
577 | /// [1, 11, 3, 10, 9, 6, 7, 12] |
578 | /// |
579 | /// See `tf.scatter_nd` for more details about how to make updates to |
580 | /// slices. |
581 | /// |
582 | /// Args: |
583 | /// * scope: A Scope object |
584 | /// * ref: A resource handle. Must be from a VarHandleOp. |
585 | /// * indices: A Tensor. Must be one of the following types: int32, int64. |
586 | /// A tensor of indices into ref. |
587 | /// * updates: A Tensor. Must have the same type as ref. A tensor of updated |
588 | /// values to add to ref. |
589 | /// |
590 | /// Optional attributes (see `Attrs`): |
591 | /// * use_locking: An optional bool. Defaults to True. If True, the assignment will |
592 | /// be protected by a lock; otherwise the behavior is undefined, |
593 | /// but may exhibit less contention. |
594 | /// |
595 | /// Returns: |
596 | /// * the created `Operation` |
597 | class ResourceScatterNdUpdate { |
598 | public: |
599 | /// Optional attribute setters for ResourceScatterNdUpdate |
600 | struct Attrs { |
601 | /// An optional bool. Defaults to True. If True, the assignment will |
602 | /// be protected by a lock; otherwise the behavior is undefined, |
603 | /// but may exhibit less contention. |
604 | /// |
605 | /// Defaults to true |
606 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
607 | Attrs ret = *this; |
608 | ret.use_locking_ = x; |
609 | return ret; |
610 | } |
611 | |
612 | bool use_locking_ = true; |
613 | }; |
614 | ResourceScatterNdUpdate(const ::tensorflow::Scope& scope, ::tensorflow::Input |
615 | ref, ::tensorflow::Input indices, ::tensorflow::Input |
616 | updates); |
617 | ResourceScatterNdUpdate(const ::tensorflow::Scope& scope, ::tensorflow::Input |
618 | ref, ::tensorflow::Input indices, ::tensorflow::Input |
619 | updates, const ResourceScatterNdUpdate::Attrs& attrs); |
620 | operator ::tensorflow::Operation() const { return operation; } |
621 | |
622 | static Attrs UseLocking(bool x) { |
623 | return Attrs().UseLocking(x); |
624 | } |
625 | |
626 | Operation operation; |
627 | }; |
628 | |
629 | /// Adds sparse updates to a variable reference. |
630 | /// |
631 | /// This operation computes |
632 | /// |
633 | /// # Scalar indices |
634 | /// ref[indices, ...] += updates[...] |
635 | /// |
636 | /// # Vector indices (for each i) |
637 | /// ref[indices[i], ...] += updates[i, ...] |
638 | /// |
639 | /// # High rank indices (for each i, ..., j) |
640 | /// ref[indices[i, ..., j], ...] += updates[i, ..., j, ...] |
641 | /// |
642 | /// This operation outputs `ref` after the update is done. |
643 | /// This makes it easier to chain operations that need to use the reset value. |
644 | /// |
645 | /// Duplicate entries are handled correctly: if multiple `indices` reference |
646 | /// the same location, their contributions add. |
647 | /// |
648 | /// Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []`. |
649 | /// |
650 | /// <div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;"> |
651 | /// <img style="width:100%" src="https://www.tensorflow.org/images/ScatterAdd.png" alt> |
652 | /// </div> |
653 | /// |
654 | /// Args: |
655 | /// * scope: A Scope object |
656 | /// * ref: Should be from a `Variable` node. |
657 | /// * indices: A tensor of indices into the first dimension of `ref`. |
658 | /// * updates: A tensor of updated values to add to `ref`. |
659 | /// |
660 | /// Optional attributes (see `Attrs`): |
661 | /// * use_locking: If True, the addition will be protected by a lock; |
662 | /// otherwise the behavior is undefined, but may exhibit less contention. |
663 | /// |
664 | /// Returns: |
665 | /// * `Output`: = Same as `ref`. Returned as a convenience for operations that want |
666 | /// to use the updated values after the update is done. |
667 | class ScatterAdd { |
668 | public: |
669 | /// Optional attribute setters for ScatterAdd |
670 | struct Attrs { |
671 | /// If True, the addition will be protected by a lock; |
672 | /// otherwise the behavior is undefined, but may exhibit less contention. |
673 | /// |
674 | /// Defaults to false |
675 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
676 | Attrs ret = *this; |
677 | ret.use_locking_ = x; |
678 | return ret; |
679 | } |
680 | |
681 | bool use_locking_ = false; |
682 | }; |
683 | ScatterAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
684 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
685 | ScatterAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
686 | ::tensorflow::Input indices, ::tensorflow::Input updates, const |
687 | ScatterAdd::Attrs& attrs); |
688 | operator ::tensorflow::Output() const { return output_ref; } |
689 | operator ::tensorflow::Input() const { return output_ref; } |
690 | ::tensorflow::Node* node() const { return output_ref.node(); } |
691 | |
692 | static Attrs UseLocking(bool x) { |
693 | return Attrs().UseLocking(x); |
694 | } |
695 | |
696 | Operation operation; |
697 | ::tensorflow::Output output_ref; |
698 | }; |
699 | |
700 | /// Divides a variable reference by sparse updates. |
701 | /// |
702 | /// This operation computes |
703 | /// |
704 | /// ```python |
705 | /// # Scalar indices |
706 | /// ref[indices, ...] /= updates[...] |
707 | /// |
708 | /// # Vector indices (for each i) |
709 | /// ref[indices[i], ...] /= updates[i, ...] |
710 | /// |
711 | /// # High rank indices (for each i, ..., j) |
712 | /// ref[indices[i, ..., j], ...] /= updates[i, ..., j, ...] |
713 | /// ``` |
714 | /// |
715 | /// This operation outputs `ref` after the update is done. |
716 | /// This makes it easier to chain operations that need to use the reset value. |
717 | /// |
718 | /// Duplicate entries are handled correctly: if multiple `indices` reference |
719 | /// the same location, their contributions divide. |
720 | /// |
721 | /// Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []`. |
722 | /// |
723 | /// Args: |
724 | /// * scope: A Scope object |
725 | /// * ref: Should be from a `Variable` node. |
726 | /// * indices: A tensor of indices into the first dimension of `ref`. |
727 | /// * updates: A tensor of values that `ref` is divided by. |
728 | /// |
729 | /// Optional attributes (see `Attrs`): |
730 | /// * use_locking: If True, the operation will be protected by a lock; |
731 | /// otherwise the behavior is undefined, but may exhibit less contention. |
732 | /// |
733 | /// Returns: |
734 | /// * `Output`: = Same as `ref`. Returned as a convenience for operations that want |
735 | /// to use the updated values after the update is done. |
736 | class ScatterDiv { |
737 | public: |
738 | /// Optional attribute setters for ScatterDiv |
739 | struct Attrs { |
740 | /// If True, the operation will be protected by a lock; |
741 | /// otherwise the behavior is undefined, but may exhibit less contention. |
742 | /// |
743 | /// Defaults to false |
744 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
745 | Attrs ret = *this; |
746 | ret.use_locking_ = x; |
747 | return ret; |
748 | } |
749 | |
750 | bool use_locking_ = false; |
751 | }; |
752 | ScatterDiv(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
753 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
754 | ScatterDiv(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
755 | ::tensorflow::Input indices, ::tensorflow::Input updates, const |
756 | ScatterDiv::Attrs& attrs); |
757 | operator ::tensorflow::Output() const { return output_ref; } |
758 | operator ::tensorflow::Input() const { return output_ref; } |
759 | ::tensorflow::Node* node() const { return output_ref.node(); } |
760 | |
761 | static Attrs UseLocking(bool x) { |
762 | return Attrs().UseLocking(x); |
763 | } |
764 | |
765 | Operation operation; |
766 | ::tensorflow::Output output_ref; |
767 | }; |
768 | |
769 | /// Reduces sparse updates into a variable reference using the `max` operation. |
770 | /// |
771 | /// This operation computes |
772 | /// |
773 | /// # Scalar indices |
774 | /// ref[indices, ...] = max(ref[indices, ...], updates[...]) |
775 | /// |
776 | /// # Vector indices (for each i) |
777 | /// ref[indices[i], ...] = max(ref[indices[i], ...], updates[i, ...]) |
778 | /// |
779 | /// # High rank indices (for each i, ..., j) |
780 | /// ref[indices[i, ..., j], ...] = max(ref[indices[i, ..., j], ...], updates[i, ..., j, ...]) |
781 | /// |
782 | /// This operation outputs `ref` after the update is done. |
783 | /// This makes it easier to chain operations that need to use the reset value. |
784 | /// |
785 | /// Duplicate entries are handled correctly: if multiple `indices` reference |
786 | /// the same location, their contributions combine. |
787 | /// |
788 | /// Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []`. |
789 | /// |
790 | /// <div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;"> |
791 | /// <img style="width:100%" src="https://www.tensorflow.org/images/ScatterAdd.png" alt> |
792 | /// </div> |
793 | /// |
794 | /// Args: |
795 | /// * scope: A Scope object |
796 | /// * ref: Should be from a `Variable` node. |
797 | /// * indices: A tensor of indices into the first dimension of `ref`. |
798 | /// * updates: A tensor of updated values to reduce into `ref`. |
799 | /// |
800 | /// Optional attributes (see `Attrs`): |
801 | /// * use_locking: If True, the update will be protected by a lock; |
802 | /// otherwise the behavior is undefined, but may exhibit less contention. |
803 | /// |
804 | /// Returns: |
805 | /// * `Output`: = Same as `ref`. Returned as a convenience for operations that want |
806 | /// to use the updated values after the update is done. |
807 | class ScatterMax { |
808 | public: |
809 | /// Optional attribute setters for ScatterMax |
810 | struct Attrs { |
811 | /// If True, the update will be protected by a lock; |
812 | /// otherwise the behavior is undefined, but may exhibit less contention. |
813 | /// |
814 | /// Defaults to false |
815 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
816 | Attrs ret = *this; |
817 | ret.use_locking_ = x; |
818 | return ret; |
819 | } |
820 | |
821 | bool use_locking_ = false; |
822 | }; |
823 | ScatterMax(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
824 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
825 | ScatterMax(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
826 | ::tensorflow::Input indices, ::tensorflow::Input updates, const |
827 | ScatterMax::Attrs& attrs); |
828 | operator ::tensorflow::Output() const { return output_ref; } |
829 | operator ::tensorflow::Input() const { return output_ref; } |
830 | ::tensorflow::Node* node() const { return output_ref.node(); } |
831 | |
832 | static Attrs UseLocking(bool x) { |
833 | return Attrs().UseLocking(x); |
834 | } |
835 | |
836 | Operation operation; |
837 | ::tensorflow::Output output_ref; |
838 | }; |
839 | |
840 | /// Reduces sparse updates into a variable reference using the `min` operation. |
841 | /// |
842 | /// This operation computes |
843 | /// |
844 | /// # Scalar indices |
845 | /// ref[indices, ...] = min(ref[indices, ...], updates[...]) |
846 | /// |
847 | /// # Vector indices (for each i) |
848 | /// ref[indices[i], ...] = min(ref[indices[i], ...], updates[i, ...]) |
849 | /// |
850 | /// # High rank indices (for each i, ..., j) |
851 | /// ref[indices[i, ..., j], ...] = min(ref[indices[i, ..., j], ...], updates[i, ..., j, ...]) |
852 | /// |
853 | /// This operation outputs `ref` after the update is done. |
854 | /// This makes it easier to chain operations that need to use the reset value. |
855 | /// |
856 | /// Duplicate entries are handled correctly: if multiple `indices` reference |
857 | /// the same location, their contributions combine. |
858 | /// |
859 | /// Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []`. |
860 | /// |
861 | /// <div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;"> |
862 | /// <img style="width:100%" src="https://www.tensorflow.org/images/ScatterAdd.png" alt> |
863 | /// </div> |
864 | /// |
865 | /// Args: |
866 | /// * scope: A Scope object |
867 | /// * ref: Should be from a `Variable` node. |
868 | /// * indices: A tensor of indices into the first dimension of `ref`. |
869 | /// * updates: A tensor of updated values to reduce into `ref`. |
870 | /// |
871 | /// Optional attributes (see `Attrs`): |
872 | /// * use_locking: If True, the update will be protected by a lock; |
873 | /// otherwise the behavior is undefined, but may exhibit less contention. |
874 | /// |
875 | /// Returns: |
876 | /// * `Output`: = Same as `ref`. Returned as a convenience for operations that want |
877 | /// to use the updated values after the update is done. |
878 | class ScatterMin { |
879 | public: |
880 | /// Optional attribute setters for ScatterMin |
881 | struct Attrs { |
882 | /// If True, the update will be protected by a lock; |
883 | /// otherwise the behavior is undefined, but may exhibit less contention. |
884 | /// |
885 | /// Defaults to false |
886 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
887 | Attrs ret = *this; |
888 | ret.use_locking_ = x; |
889 | return ret; |
890 | } |
891 | |
892 | bool use_locking_ = false; |
893 | }; |
894 | ScatterMin(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
895 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
896 | ScatterMin(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
897 | ::tensorflow::Input indices, ::tensorflow::Input updates, const |
898 | ScatterMin::Attrs& attrs); |
899 | operator ::tensorflow::Output() const { return output_ref; } |
900 | operator ::tensorflow::Input() const { return output_ref; } |
901 | ::tensorflow::Node* node() const { return output_ref.node(); } |
902 | |
903 | static Attrs UseLocking(bool x) { |
904 | return Attrs().UseLocking(x); |
905 | } |
906 | |
907 | Operation operation; |
908 | ::tensorflow::Output output_ref; |
909 | }; |
910 | |
911 | /// Multiplies sparse updates into a variable reference. |
912 | /// |
913 | /// This operation computes |
914 | /// |
915 | /// ```python |
916 | /// # Scalar indices |
917 | /// ref[indices, ...] *= updates[...] |
918 | /// |
919 | /// # Vector indices (for each i) |
920 | /// ref[indices[i], ...] *= updates[i, ...] |
921 | /// |
922 | /// # High rank indices (for each i, ..., j) |
923 | /// ref[indices[i, ..., j], ...] *= updates[i, ..., j, ...] |
924 | /// ``` |
925 | /// |
926 | /// This operation outputs `ref` after the update is done. |
927 | /// This makes it easier to chain operations that need to use the reset value. |
928 | /// |
929 | /// Duplicate entries are handled correctly: if multiple `indices` reference |
930 | /// the same location, their contributions multiply. |
931 | /// |
932 | /// Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []`. |
933 | /// |
934 | /// Args: |
935 | /// * scope: A Scope object |
936 | /// * ref: Should be from a `Variable` node. |
937 | /// * indices: A tensor of indices into the first dimension of `ref`. |
938 | /// * updates: A tensor of updated values to multiply to `ref`. |
939 | /// |
940 | /// Optional attributes (see `Attrs`): |
941 | /// * use_locking: If True, the operation will be protected by a lock; |
942 | /// otherwise the behavior is undefined, but may exhibit less contention. |
943 | /// |
944 | /// Returns: |
945 | /// * `Output`: = Same as `ref`. Returned as a convenience for operations that want |
946 | /// to use the updated values after the update is done. |
947 | class ScatterMul { |
948 | public: |
949 | /// Optional attribute setters for ScatterMul |
950 | struct Attrs { |
951 | /// If True, the operation will be protected by a lock; |
952 | /// otherwise the behavior is undefined, but may exhibit less contention. |
953 | /// |
954 | /// Defaults to false |
955 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
956 | Attrs ret = *this; |
957 | ret.use_locking_ = x; |
958 | return ret; |
959 | } |
960 | |
961 | bool use_locking_ = false; |
962 | }; |
963 | ScatterMul(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
964 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
965 | ScatterMul(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
966 | ::tensorflow::Input indices, ::tensorflow::Input updates, const |
967 | ScatterMul::Attrs& attrs); |
968 | operator ::tensorflow::Output() const { return output_ref; } |
969 | operator ::tensorflow::Input() const { return output_ref; } |
970 | ::tensorflow::Node* node() const { return output_ref.node(); } |
971 | |
972 | static Attrs UseLocking(bool x) { |
973 | return Attrs().UseLocking(x); |
974 | } |
975 | |
976 | Operation operation; |
977 | ::tensorflow::Output output_ref; |
978 | }; |
979 | |
980 | /// Applies sparse addition to individual values or slices in a Variable. |
981 | /// |
982 | /// `ref` is a `Tensor` with rank `P` and `indices` is a `Tensor` of rank `Q`. |
983 | /// |
984 | /// `indices` must be integer tensor, containing indices into `ref`. |
985 | /// It must be shape `[d_0, ..., d_{Q-2}, K]` where `0 < K <= P`. |
986 | /// |
987 | /// The innermost dimension of `indices` (with length `K`) corresponds to |
988 | /// indices into elements (if `K = P`) or slices (if `K < P`) along the `K`th |
989 | /// dimension of `ref`. |
990 | /// |
991 | /// `updates` is `Tensor` of rank `Q-1+P-K` with shape: |
992 | /// |
993 | /// ``` |
994 | /// [d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]] |
995 | /// ``` |
996 | /// |
997 | /// For example, say we want to add 4 scattered elements to a rank-1 tensor to |
998 | /// 8 elements. In Python, that addition would look like this: |
999 | /// |
1000 | /// ```python |
1001 | /// ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8]) |
1002 | /// indices = tf.constant([[4], [3], [1], [7]]) |
1003 | /// updates = tf.constant([9, 10, 11, 12]) |
1004 | /// add = tf.scatter_nd_add(ref, indices, updates) |
1005 | /// with tf.Session() as sess: |
1006 | /// print sess.run(add) |
1007 | /// ``` |
1008 | /// |
1009 | /// The resulting update to ref would look like this: |
1010 | /// |
1011 | /// [1, 13, 3, 14, 14, 6, 7, 20] |
1012 | /// |
1013 | /// See `tf.scatter_nd` for more details about how to make updates to |
1014 | /// slices. |
1015 | /// |
1016 | /// Args: |
1017 | /// * scope: A Scope object |
1018 | /// * ref: A mutable Tensor. Should be from a Variable node. |
1019 | /// * indices: A Tensor. Must be one of the following types: int32, int64. |
1020 | /// A tensor of indices into ref. |
1021 | /// * updates: A Tensor. Must have the same type as ref. A tensor of updated values |
1022 | /// to add to ref. |
1023 | /// |
1024 | /// Optional attributes (see `Attrs`): |
1025 | /// * use_locking: An optional bool. Defaults to True. If True, the assignment will |
1026 | /// be protected by a lock; otherwise the behavior is undefined, |
1027 | /// but may exhibit less contention. |
1028 | /// |
1029 | /// Returns: |
1030 | /// * `Output`: Same as ref. Returned as a convenience for operations that want |
1031 | /// to use the updated values after the update is done. |
1032 | class ScatterNdAdd { |
1033 | public: |
1034 | /// Optional attribute setters for ScatterNdAdd |
1035 | struct Attrs { |
1036 | /// An optional bool. Defaults to True. If True, the assignment will |
1037 | /// be protected by a lock; otherwise the behavior is undefined, |
1038 | /// but may exhibit less contention. |
1039 | /// |
1040 | /// Defaults to false |
1041 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
1042 | Attrs ret = *this; |
1043 | ret.use_locking_ = x; |
1044 | return ret; |
1045 | } |
1046 | |
1047 | bool use_locking_ = false; |
1048 | }; |
1049 | ScatterNdAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
1050 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
1051 | ScatterNdAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
1052 | ::tensorflow::Input indices, ::tensorflow::Input updates, const |
1053 | ScatterNdAdd::Attrs& attrs); |
1054 | operator ::tensorflow::Output() const { return output_ref; } |
1055 | operator ::tensorflow::Input() const { return output_ref; } |
1056 | ::tensorflow::Node* node() const { return output_ref.node(); } |
1057 | |
1058 | static Attrs UseLocking(bool x) { |
1059 | return Attrs().UseLocking(x); |
1060 | } |
1061 | |
1062 | Operation operation; |
1063 | ::tensorflow::Output output_ref; |
1064 | }; |
1065 | |
1066 | /// Applies sparse subtraction to individual values or slices in a Variable. |
1067 | /// |
1068 | /// within a given variable according to `indices`. |
1069 | /// |
1070 | /// `ref` is a `Tensor` with rank `P` and `indices` is a `Tensor` of rank `Q`. |
1071 | /// |
1072 | /// `indices` must be integer tensor, containing indices into `ref`. |
1073 | /// It must be shape `[d_0, ..., d_{Q-2}, K]` where `0 < K <= P`. |
1074 | /// |
1075 | /// The innermost dimension of `indices` (with length `K`) corresponds to |
1076 | /// indices into elements (if `K = P`) or slices (if `K < P`) along the `K`th |
1077 | /// dimension of `ref`. |
1078 | /// |
1079 | /// `updates` is `Tensor` of rank `Q-1+P-K` with shape: |
1080 | /// |
1081 | /// ``` |
1082 | /// [d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]] |
1083 | /// ``` |
1084 | /// |
1085 | /// For example, say we want to subtract 4 scattered elements from a rank-1 tensor |
1086 | /// with 8 elements. In Python, that subtraction would look like this: |
1087 | /// |
1088 | /// ```python |
1089 | /// ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8]) |
1090 | /// indices = tf.constant([[4], [3], [1], [7]]) |
1091 | /// updates = tf.constant([9, 10, 11, 12]) |
1092 | /// sub = tf.scatter_nd_sub(ref, indices, updates) |
1093 | /// with tf.Session() as sess: |
1094 | /// print sess.run(sub) |
1095 | /// ``` |
1096 | /// |
1097 | /// The resulting update to ref would look like this: |
1098 | /// |
1099 | /// [1, -9, 3, -6, -4, 6, 7, -4] |
1100 | /// |
1101 | /// See `tf.scatter_nd` for more details about how to make updates to |
1102 | /// slices. |
1103 | /// |
1104 | /// Args: |
1105 | /// * scope: A Scope object |
1106 | /// * ref: A mutable Tensor. Should be from a Variable node. |
1107 | /// * indices: A Tensor. Must be one of the following types: int32, int64. |
1108 | /// A tensor of indices into ref. |
1109 | /// * updates: A Tensor. Must have the same type as ref. A tensor of updated values |
1110 | /// to subtract from ref. |
1111 | /// |
1112 | /// Optional attributes (see `Attrs`): |
1113 | /// * use_locking: An optional bool. Defaults to True. If True, the assignment will |
1114 | /// be protected by a lock; otherwise the behavior is undefined, |
1115 | /// but may exhibit less contention. |
1116 | /// |
1117 | /// Returns: |
1118 | /// * `Output`: Same as ref. Returned as a convenience for operations that want |
1119 | /// to use the updated values after the update is done. |
1120 | class ScatterNdSub { |
1121 | public: |
1122 | /// Optional attribute setters for ScatterNdSub |
1123 | struct Attrs { |
1124 | /// An optional bool. Defaults to True. If True, the assignment will |
1125 | /// be protected by a lock; otherwise the behavior is undefined, |
1126 | /// but may exhibit less contention. |
1127 | /// |
1128 | /// Defaults to false |
1129 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
1130 | Attrs ret = *this; |
1131 | ret.use_locking_ = x; |
1132 | return ret; |
1133 | } |
1134 | |
1135 | bool use_locking_ = false; |
1136 | }; |
1137 | ScatterNdSub(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
1138 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
1139 | ScatterNdSub(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
1140 | ::tensorflow::Input indices, ::tensorflow::Input updates, const |
1141 | ScatterNdSub::Attrs& attrs); |
1142 | operator ::tensorflow::Output() const { return output_ref; } |
1143 | operator ::tensorflow::Input() const { return output_ref; } |
1144 | ::tensorflow::Node* node() const { return output_ref.node(); } |
1145 | |
1146 | static Attrs UseLocking(bool x) { |
1147 | return Attrs().UseLocking(x); |
1148 | } |
1149 | |
1150 | Operation operation; |
1151 | ::tensorflow::Output output_ref; |
1152 | }; |
1153 | |
1154 | /// Applies sparse `updates` to individual values or slices within a given |
1155 | /// |
1156 | /// variable according to `indices`. |
1157 | /// |
1158 | /// `ref` is a `Tensor` with rank `P` and `indices` is a `Tensor` of rank `Q`. |
1159 | /// |
1160 | /// `indices` must be integer tensor, containing indices into `ref`. |
1161 | /// It must be shape \\([d_0, ..., d_{Q-2}, K]\\) where `0 < K <= P`. |
1162 | /// |
1163 | /// The innermost dimension of `indices` (with length `K`) corresponds to |
1164 | /// indices into elements (if `K = P`) or slices (if `K < P`) along the `K`th |
1165 | /// dimension of `ref`. |
1166 | /// |
1167 | /// `updates` is `Tensor` of rank `Q-1+P-K` with shape: |
1168 | /// |
1169 | /// $$[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]].$$ |
1170 | /// |
1171 | /// For example, say we want to update 4 scattered elements to a rank-1 tensor to |
1172 | /// 8 elements. In Python, that update would look like this: |
1173 | /// |
1174 | /// ```python |
1175 | /// ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8]) |
1176 | /// indices = tf.constant([[4], [3], [1] ,[7]]) |
1177 | /// updates = tf.constant([9, 10, 11, 12]) |
1178 | /// update = tf.scatter_nd_update(ref, indices, updates) |
1179 | /// with tf.Session() as sess: |
1180 | /// print sess.run(update) |
1181 | /// ``` |
1182 | /// |
1183 | /// The resulting update to ref would look like this: |
1184 | /// |
1185 | /// [1, 11, 3, 10, 9, 6, 7, 12] |
1186 | /// |
1187 | /// See `tf.scatter_nd` for more details about how to make updates to |
1188 | /// slices. |
1189 | /// |
1190 | /// See also `tf.scatter_update` and `tf.batch_scatter_update`. |
1191 | /// |
1192 | /// Args: |
1193 | /// * scope: A Scope object |
1194 | /// * ref: A mutable Tensor. Should be from a Variable node. |
1195 | /// * indices: A Tensor. Must be one of the following types: int32, int64. |
1196 | /// A tensor of indices into ref. |
1197 | /// * updates: A Tensor. Must have the same type as ref. A tensor of updated |
1198 | /// values to add to ref. |
1199 | /// |
1200 | /// Optional attributes (see `Attrs`): |
1201 | /// * use_locking: An optional bool. Defaults to True. If True, the assignment will |
1202 | /// be protected by a lock; otherwise the behavior is undefined, |
1203 | /// but may exhibit less contention. |
1204 | /// |
1205 | /// Returns: |
1206 | /// * `Output`: Same as ref. Returned as a convenience for operations that want to |
1207 | /// use the updated values after the update is done. |
1208 | class ScatterNdUpdate { |
1209 | public: |
1210 | /// Optional attribute setters for ScatterNdUpdate |
1211 | struct Attrs { |
1212 | /// An optional bool. Defaults to True. If True, the assignment will |
1213 | /// be protected by a lock; otherwise the behavior is undefined, |
1214 | /// but may exhibit less contention. |
1215 | /// |
1216 | /// Defaults to true |
1217 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
1218 | Attrs ret = *this; |
1219 | ret.use_locking_ = x; |
1220 | return ret; |
1221 | } |
1222 | |
1223 | bool use_locking_ = true; |
1224 | }; |
1225 | ScatterNdUpdate(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
1226 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
1227 | ScatterNdUpdate(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
1228 | ::tensorflow::Input indices, ::tensorflow::Input updates, const |
1229 | ScatterNdUpdate::Attrs& attrs); |
1230 | operator ::tensorflow::Output() const { return output_ref; } |
1231 | operator ::tensorflow::Input() const { return output_ref; } |
1232 | ::tensorflow::Node* node() const { return output_ref.node(); } |
1233 | |
1234 | static Attrs UseLocking(bool x) { |
1235 | return Attrs().UseLocking(x); |
1236 | } |
1237 | |
1238 | Operation operation; |
1239 | ::tensorflow::Output output_ref; |
1240 | }; |
1241 | |
1242 | /// Subtracts sparse updates to a variable reference. |
1243 | /// |
1244 | /// ```python |
1245 | /// # Scalar indices |
1246 | /// ref[indices, ...] -= updates[...] |
1247 | /// |
1248 | /// # Vector indices (for each i) |
1249 | /// ref[indices[i], ...] -= updates[i, ...] |
1250 | /// |
1251 | /// # High rank indices (for each i, ..., j) |
1252 | /// ref[indices[i, ..., j], ...] -= updates[i, ..., j, ...] |
1253 | /// ``` |
1254 | /// |
1255 | /// This operation outputs `ref` after the update is done. |
1256 | /// This makes it easier to chain operations that need to use the reset value. |
1257 | /// |
1258 | /// Duplicate entries are handled correctly: if multiple `indices` reference |
1259 | /// the same location, their (negated) contributions add. |
1260 | /// |
1261 | /// Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []`. |
1262 | /// |
1263 | /// <div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;"> |
1264 | /// <img style="width:100%" src="https://www.tensorflow.org/images/ScatterSub.png" alt> |
1265 | /// </div> |
1266 | /// |
1267 | /// Args: |
1268 | /// * scope: A Scope object |
1269 | /// * ref: Should be from a `Variable` node. |
1270 | /// * indices: A tensor of indices into the first dimension of `ref`. |
1271 | /// * updates: A tensor of updated values to subtract from `ref`. |
1272 | /// |
1273 | /// Optional attributes (see `Attrs`): |
1274 | /// * use_locking: If True, the subtraction will be protected by a lock; |
1275 | /// otherwise the behavior is undefined, but may exhibit less contention. |
1276 | /// |
1277 | /// Returns: |
1278 | /// * `Output`: = Same as `ref`. Returned as a convenience for operations that want |
1279 | /// to use the updated values after the update is done. |
1280 | class ScatterSub { |
1281 | public: |
1282 | /// Optional attribute setters for ScatterSub |
1283 | struct Attrs { |
1284 | /// If True, the subtraction will be protected by a lock; |
1285 | /// otherwise the behavior is undefined, but may exhibit less contention. |
1286 | /// |
1287 | /// Defaults to false |
1288 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
1289 | Attrs ret = *this; |
1290 | ret.use_locking_ = x; |
1291 | return ret; |
1292 | } |
1293 | |
1294 | bool use_locking_ = false; |
1295 | }; |
1296 | ScatterSub(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
1297 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
1298 | ScatterSub(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
1299 | ::tensorflow::Input indices, ::tensorflow::Input updates, const |
1300 | ScatterSub::Attrs& attrs); |
1301 | operator ::tensorflow::Output() const { return output_ref; } |
1302 | operator ::tensorflow::Input() const { return output_ref; } |
1303 | ::tensorflow::Node* node() const { return output_ref.node(); } |
1304 | |
1305 | static Attrs UseLocking(bool x) { |
1306 | return Attrs().UseLocking(x); |
1307 | } |
1308 | |
1309 | Operation operation; |
1310 | ::tensorflow::Output output_ref; |
1311 | }; |
1312 | |
1313 | /// Applies sparse updates to a variable reference. |
1314 | /// |
1315 | /// This operation computes |
1316 | /// |
1317 | /// ```python |
1318 | /// # Scalar indices |
1319 | /// ref[indices, ...] = updates[...] |
1320 | /// |
1321 | /// # Vector indices (for each i) |
1322 | /// ref[indices[i], ...] = updates[i, ...] |
1323 | /// |
1324 | /// # High rank indices (for each i, ..., j) |
1325 | /// ref[indices[i, ..., j], ...] = updates[i, ..., j, ...] |
1326 | /// ``` |
1327 | /// |
1328 | /// This operation outputs `ref` after the update is done. |
1329 | /// This makes it easier to chain operations that need to use the reset value. |
1330 | /// |
1331 | /// If values in `ref` is to be updated more than once, because there are |
1332 | /// duplicate entries in `indices`, the order at which the updates happen |
1333 | /// for each value is undefined. |
1334 | /// |
1335 | /// Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []`. |
1336 | /// |
1337 | /// <div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;"> |
1338 | /// <img style="width:100%" src="https://www.tensorflow.org/images/ScatterUpdate.png" alt> |
1339 | /// </div> |
1340 | /// |
1341 | /// See also `tf.batch_scatter_update` and `tf.scatter_nd_update`. |
1342 | /// |
1343 | /// Args: |
1344 | /// * scope: A Scope object |
1345 | /// * ref: Should be from a `Variable` node. |
1346 | /// * indices: A tensor of indices into the first dimension of `ref`. |
1347 | /// * updates: A tensor of updated values to store in `ref`. |
1348 | /// |
1349 | /// Optional attributes (see `Attrs`): |
1350 | /// * use_locking: If True, the assignment will be protected by a lock; |
1351 | /// otherwise the behavior is undefined, but may exhibit less contention. |
1352 | /// |
1353 | /// Returns: |
1354 | /// * `Output`: = Same as `ref`. Returned as a convenience for operations that want |
1355 | /// to use the updated values after the update is done. |
1356 | class ScatterUpdate { |
1357 | public: |
1358 | /// Optional attribute setters for ScatterUpdate |
1359 | struct Attrs { |
1360 | /// If True, the assignment will be protected by a lock; |
1361 | /// otherwise the behavior is undefined, but may exhibit less contention. |
1362 | /// |
1363 | /// Defaults to true |
1364 | TF_MUST_USE_RESULT Attrs UseLocking(bool x) { |
1365 | Attrs ret = *this; |
1366 | ret.use_locking_ = x; |
1367 | return ret; |
1368 | } |
1369 | |
1370 | bool use_locking_ = true; |
1371 | }; |
1372 | ScatterUpdate(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
1373 | ::tensorflow::Input indices, ::tensorflow::Input updates); |
1374 | ScatterUpdate(const ::tensorflow::Scope& scope, ::tensorflow::Input ref, |
1375 | ::tensorflow::Input indices, ::tensorflow::Input updates, const |
1376 | ScatterUpdate::Attrs& attrs); |
1377 | operator ::tensorflow::Output() const { return output_ref; } |
1378 | operator ::tensorflow::Input() const { return output_ref; } |
1379 | ::tensorflow::Node* node() const { return output_ref.node(); } |
1380 | |
1381 | static Attrs UseLocking(bool x) { |
1382 | return Attrs().UseLocking(x); |
1383 | } |
1384 | |
1385 | Operation operation; |
1386 | ::tensorflow::Output output_ref; |
1387 | }; |
1388 | |
1389 | /// Returns a tensor that may be mutated, but only persists within a single step. |
1390 | /// |
1391 | /// This is an experimental op for internal use only and it is possible to use this |
1392 | /// op in unsafe ways. DO NOT USE unless you fully understand the risks. |
1393 | /// |
1394 | /// It is the caller's responsibility to ensure that 'ref' is eventually passed to a |
1395 | /// matching 'DestroyTemporaryVariable' op after all other uses have completed. |
1396 | /// |
1397 | /// Outputs a ref to the tensor state so it may be read or modified. |
1398 | /// |
1399 | /// E.g. |
1400 | /// var = state_ops._temporary_variable([1, 2], types.float_) |
1401 | /// var_name = var.op.name |
1402 | /// var = state_ops.assign(var, [[4.0, 5.0]]) |
1403 | /// var = state_ops.assign_add(var, [[6.0, 7.0]]) |
1404 | /// final = state_ops._destroy_temporary_variable(var, var_name=var_name) |
1405 | /// |
1406 | /// Args: |
1407 | /// * scope: A Scope object |
1408 | /// * shape: The shape of the variable tensor. |
1409 | /// * dtype: The type of elements in the variable tensor. |
1410 | /// |
1411 | /// Optional attributes (see `Attrs`): |
1412 | /// * var_name: Overrides the name used for the temporary variable resource. Default |
1413 | /// value is the name of the 'TemporaryVariable' op (which is guaranteed unique). |
1414 | /// |
1415 | /// Returns: |
1416 | /// * `Output`: A reference to the variable tensor. |
1417 | class TemporaryVariable { |
1418 | public: |
1419 | /// Optional attribute setters for TemporaryVariable |
1420 | struct Attrs { |
1421 | /// Overrides the name used for the temporary variable resource. Default |
1422 | /// value is the name of the 'TemporaryVariable' op (which is guaranteed unique). |
1423 | /// |
1424 | /// Defaults to "" |
1425 | TF_MUST_USE_RESULT Attrs VarName(StringPiece x) { |
1426 | Attrs ret = *this; |
1427 | ret.var_name_ = x; |
1428 | return ret; |
1429 | } |
1430 | |
1431 | StringPiece var_name_ = "" ; |
1432 | }; |
1433 | TemporaryVariable(const ::tensorflow::Scope& scope, PartialTensorShape shape, |
1434 | DataType dtype); |
1435 | TemporaryVariable(const ::tensorflow::Scope& scope, PartialTensorShape shape, |
1436 | DataType dtype, const TemporaryVariable::Attrs& attrs); |
1437 | operator ::tensorflow::Output() const { return ref; } |
1438 | operator ::tensorflow::Input() const { return ref; } |
1439 | ::tensorflow::Node* node() const { return ref.node(); } |
1440 | |
1441 | static Attrs VarName(StringPiece x) { |
1442 | return Attrs().VarName(x); |
1443 | } |
1444 | |
1445 | Operation operation; |
1446 | ::tensorflow::Output ref; |
1447 | }; |
1448 | |
1449 | /// Holds state in the form of a tensor that persists across steps. |
1450 | /// |
1451 | /// Outputs a ref to the tensor state so it may be read or modified. |
1452 | /// TODO(zhifengc/mrry): Adds a pointer to a more detail document |
1453 | /// about sharing states in tensorflow. |
1454 | /// |
1455 | /// Args: |
1456 | /// * scope: A Scope object |
1457 | /// * shape: The shape of the variable tensor. |
1458 | /// * dtype: The type of elements in the variable tensor. |
1459 | /// |
1460 | /// Optional attributes (see `Attrs`): |
1461 | /// * container: If non-empty, this variable is placed in the given container. |
1462 | /// Otherwise, a default container is used. |
1463 | /// * shared_name: If non-empty, this variable is named in the given bucket |
1464 | /// with this shared_name. Otherwise, the node name is used instead. |
1465 | /// |
1466 | /// Returns: |
1467 | /// * `Output`: A reference to the variable tensor. |
1468 | class Variable { |
1469 | public: |
1470 | /// Optional attribute setters for Variable |
1471 | struct Attrs { |
1472 | /// If non-empty, this variable is placed in the given container. |
1473 | /// Otherwise, a default container is used. |
1474 | /// |
1475 | /// Defaults to "" |
1476 | TF_MUST_USE_RESULT Attrs Container(StringPiece x) { |
1477 | Attrs ret = *this; |
1478 | ret.container_ = x; |
1479 | return ret; |
1480 | } |
1481 | |
1482 | /// If non-empty, this variable is named in the given bucket |
1483 | /// with this shared_name. Otherwise, the node name is used instead. |
1484 | /// |
1485 | /// Defaults to "" |
1486 | TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) { |
1487 | Attrs ret = *this; |
1488 | ret.shared_name_ = x; |
1489 | return ret; |
1490 | } |
1491 | |
1492 | StringPiece container_ = "" ; |
1493 | StringPiece shared_name_ = "" ; |
1494 | }; |
1495 | Variable(const ::tensorflow::Scope& scope, PartialTensorShape shape, DataType |
1496 | dtype); |
1497 | Variable(const ::tensorflow::Scope& scope, PartialTensorShape shape, DataType |
1498 | dtype, const Variable::Attrs& attrs); |
1499 | operator ::tensorflow::Output() const { return ref; } |
1500 | operator ::tensorflow::Input() const { return ref; } |
1501 | ::tensorflow::Node* node() const { return ref.node(); } |
1502 | |
1503 | static Attrs Container(StringPiece x) { |
1504 | return Attrs().Container(x); |
1505 | } |
1506 | static Attrs SharedName(StringPiece x) { |
1507 | return Attrs().SharedName(x); |
1508 | } |
1509 | |
1510 | Operation operation; |
1511 | ::tensorflow::Output ref; |
1512 | }; |
1513 | |
1514 | /// @} |
1515 | |
1516 | } // namespace ops |
1517 | } // namespace tensorflow |
1518 | |
1519 | #endif // TENSORFLOW_CC_OPS_STATE_OPS_H_ |
1520 | |