jasonfan commited on
Commit
56bfe2d
·
verified ·
1 Parent(s): 4fa1554

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/no_op.h +41 -0
  2. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/no_op_internal.h +28 -0
  3. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/parsing_ops.h +1285 -0
  4. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/parsing_ops_internal.h +28 -0
  5. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/random_ops.h +663 -0
  6. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/random_ops_internal.h +47 -0
  7. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/resource_variable_ops.h +587 -0
  8. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/sparse_ops.h +1814 -0
  9. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/sparse_ops_internal.h +28 -0
  10. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/standard_ops.h +40 -0
  11. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/state_ops.h +1519 -0
  12. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/state_ops_internal.h +132 -0
  13. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/string_ops.h +1284 -0
  14. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/string_ops_internal.h +483 -0
  15. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/training_ops.h +0 -0
  16. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/training_ops_internal.h +426 -0
  17. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/user_ops.h +44 -0
  18. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/user_ops_internal.h +28 -0
  19. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/while_loop.h +77 -0
  20. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/bundle_v2.h +89 -0
  21. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/constants.h +82 -0
  22. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/fingerprinting.h +47 -0
  23. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/loader.h +147 -0
  24. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/loader_util.h +39 -0
  25. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/metrics.h +133 -0
  26. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/reader.h +49 -0
  27. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/util.h +56 -0
  28. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/tools/freeze_saved_model.h +43 -0
  29. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/training/coordinator.h +132 -0
  30. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/training/queue_runner.h +140 -0
  31. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/build_xla_ops_pass.h +45 -0
  32. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/clone_constants_for_better_clustering.h +62 -0
  33. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/cluster_scoping_pass.h +38 -0
  34. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/compilability_check_util.h +338 -0
  35. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/deadness_analysis.h +99 -0
  36. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/deadness_analysis_internal.h +34 -0
  37. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/defs.h +49 -0
  38. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_compilation_cache.h +257 -0
  39. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_compilation_cluster_signature.h +56 -0
  40. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_compilation_profiler.h +100 -0
  41. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_compiler.h +500 -0
  42. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_compiler_client.h +75 -0
  43. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_executable_persistor.h +408 -0
  44. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_util.h +213 -0
  45. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/encapsulate_subgraphs_pass.h +108 -0
  46. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/encapsulate_util.h +154 -0
  47. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/encapsulate_xla_computations_pass.h +84 -0
  48. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/extract_outside_compilation_pass.h +111 -0
  49. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/flags.h +357 -0
  50. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/force_xla_constants_on_host_pass.h +36 -0
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/no_op.h ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_NO_OP_H_
4
+ #define TENSORFLOW_CC_OPS_NO_OP_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 no_op No Op
19
+ /// @{
20
+
21
+ /// Does nothing. Only useful as a placeholder for control edges.
22
+ ///
23
+ /// Args:
24
+ /// * scope: A Scope object
25
+ ///
26
+ /// Returns:
27
+ /// * the created `Operation`
28
+ class NoOp {
29
+ public:
30
+ NoOp(const ::tensorflow::Scope& scope);
31
+ operator ::tensorflow::Operation() const { return operation; }
32
+
33
+ Operation operation;
34
+ };
35
+
36
+ /// @}
37
+
38
+ } // namespace ops
39
+ } // namespace tensorflow
40
+
41
+ #endif // TENSORFLOW_CC_OPS_NO_OP_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/no_op_internal.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_NO_OP_INTERNAL_H_
4
+ #define TENSORFLOW_CC_OPS_NO_OP_INTERNAL_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
+ namespace internal {
18
+ // NOTE: This namespace has internal TensorFlow details that
19
+ // are not part of TensorFlow's public API.
20
+
21
+ /// @defgroup no_op_internal No Op Internal
22
+ /// @{
23
+
24
+ } // namespace internal
25
+ } // namespace ops
26
+ } // namespace tensorflow
27
+
28
+ #endif // TENSORFLOW_CC_OPS_NO_OP_INTERNAL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/parsing_ops.h ADDED
@@ -0,0 +1,1285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_PARSING_OPS_H_
4
+ #define TENSORFLOW_CC_OPS_PARSING_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 parsing_ops Parsing Ops
19
+ /// @{
20
+
21
+ /// Convert CSV records to tensors. Each column maps to one tensor.
22
+ ///
23
+ /// RFC 4180 format is expected for the CSV records.
24
+ /// (https://tools.ietf.org/html/rfc4180)
25
+ /// Note that we allow leading and trailing spaces with int or float field.
26
+ ///
27
+ /// Args:
28
+ /// * scope: A Scope object
29
+ /// * records: Each string is a record/row in the csv and all records should have
30
+ /// the same format.
31
+ /// * record_defaults: One tensor per column of the input record, with either a
32
+ /// scalar default value for that column or an empty vector if the column is
33
+ /// required.
34
+ ///
35
+ /// Optional attributes (see `Attrs`):
36
+ /// * field_delim: char delimiter to separate fields in a record.
37
+ /// * use_quote_delim: If false, treats double quotation marks as regular
38
+ /// characters inside of the string fields (ignoring RFC 4180, Section 2,
39
+ /// Bullet 5).
40
+ /// * na_value: Additional string to recognize as NA/NaN.
41
+ ///
42
+ /// Returns:
43
+ /// * `OutputList`: Each tensor will have the same shape as records.
44
+ class DecodeCSV {
45
+ public:
46
+ /// Optional attribute setters for DecodeCSV
47
+ struct Attrs {
48
+ /// char delimiter to separate fields in a record.
49
+ ///
50
+ /// Defaults to ","
51
+ TF_MUST_USE_RESULT Attrs FieldDelim(StringPiece x) {
52
+ Attrs ret = *this;
53
+ ret.field_delim_ = x;
54
+ return ret;
55
+ }
56
+
57
+ /// If false, treats double quotation marks as regular
58
+ /// characters inside of the string fields (ignoring RFC 4180, Section 2,
59
+ /// Bullet 5).
60
+ ///
61
+ /// Defaults to true
62
+ TF_MUST_USE_RESULT Attrs UseQuoteDelim(bool x) {
63
+ Attrs ret = *this;
64
+ ret.use_quote_delim_ = x;
65
+ return ret;
66
+ }
67
+
68
+ /// Additional string to recognize as NA/NaN.
69
+ ///
70
+ /// Defaults to ""
71
+ TF_MUST_USE_RESULT Attrs NaValue(StringPiece x) {
72
+ Attrs ret = *this;
73
+ ret.na_value_ = x;
74
+ return ret;
75
+ }
76
+
77
+ /// Defaults to []
78
+ TF_MUST_USE_RESULT Attrs SelectCols(const gtl::ArraySlice<int>& x) {
79
+ Attrs ret = *this;
80
+ ret.select_cols_ = x;
81
+ return ret;
82
+ }
83
+
84
+ StringPiece field_delim_ = ",";
85
+ bool use_quote_delim_ = true;
86
+ StringPiece na_value_ = "";
87
+ gtl::ArraySlice<int> select_cols_ = {};
88
+ };
89
+ DecodeCSV(const ::tensorflow::Scope& scope, ::tensorflow::Input records,
90
+ ::tensorflow::InputList record_defaults);
91
+ DecodeCSV(const ::tensorflow::Scope& scope, ::tensorflow::Input records,
92
+ ::tensorflow::InputList record_defaults, const DecodeCSV::Attrs&
93
+ attrs);
94
+ ::tensorflow::Output operator[](size_t index) const { return output[index]; }
95
+
96
+
97
+ static Attrs FieldDelim(StringPiece x) {
98
+ return Attrs().FieldDelim(x);
99
+ }
100
+ static Attrs UseQuoteDelim(bool x) {
101
+ return Attrs().UseQuoteDelim(x);
102
+ }
103
+ static Attrs NaValue(StringPiece x) {
104
+ return Attrs().NaValue(x);
105
+ }
106
+ static Attrs SelectCols(const gtl::ArraySlice<int>& x) {
107
+ return Attrs().SelectCols(x);
108
+ }
109
+
110
+ Operation operation;
111
+ ::tensorflow::OutputList output;
112
+ };
113
+
114
+ /// Decompress strings.
115
+ ///
116
+ /// This op decompresses each element of the `bytes` input `Tensor`, which
117
+ /// is assumed to be compressed using the given `compression_type`.
118
+ ///
119
+ /// The `output` is a string `Tensor` of the same shape as `bytes`,
120
+ /// each element containing the decompressed data from the corresponding
121
+ /// element in `bytes`.
122
+ ///
123
+ /// Args:
124
+ /// * scope: A Scope object
125
+ /// * bytes: A Tensor of string which is compressed.
126
+ ///
127
+ /// Optional attributes (see `Attrs`):
128
+ /// * compression_type: A scalar containing either (i) the empty string (no
129
+ /// compression), (ii) "ZLIB", or (iii) "GZIP".
130
+ ///
131
+ /// Returns:
132
+ /// * `Output`: A Tensor with the same shape as input `bytes`, uncompressed
133
+ /// from bytes.
134
+ class DecodeCompressed {
135
+ public:
136
+ /// Optional attribute setters for DecodeCompressed
137
+ struct Attrs {
138
+ /// A scalar containing either (i) the empty string (no
139
+ /// compression), (ii) "ZLIB", or (iii) "GZIP".
140
+ ///
141
+ /// Defaults to ""
142
+ TF_MUST_USE_RESULT Attrs CompressionType(StringPiece x) {
143
+ Attrs ret = *this;
144
+ ret.compression_type_ = x;
145
+ return ret;
146
+ }
147
+
148
+ StringPiece compression_type_ = "";
149
+ };
150
+ DecodeCompressed(const ::tensorflow::Scope& scope, ::tensorflow::Input bytes);
151
+ DecodeCompressed(const ::tensorflow::Scope& scope, ::tensorflow::Input bytes,
152
+ const DecodeCompressed::Attrs& attrs);
153
+ operator ::tensorflow::Output() const { return output; }
154
+ operator ::tensorflow::Input() const { return output; }
155
+ ::tensorflow::Node* node() const { return output.node(); }
156
+
157
+ static Attrs CompressionType(StringPiece x) {
158
+ return Attrs().CompressionType(x);
159
+ }
160
+
161
+ Operation operation;
162
+ ::tensorflow::Output output;
163
+ };
164
+
165
+ /// Convert JSON-encoded Example records to binary protocol buffer strings.
166
+ ///
167
+ ///
168
+ /// Note: This is **not** a general purpose JSON parsing op.
169
+ ///
170
+ /// This op converts JSON-serialized
171
+ /// `tf.train.Example` (created with `json_format.MessageToJson`, following the
172
+ /// [standard JSON mapping](https://developers.google.com/protocol-buffers/docs/proto3#json))
173
+ /// to a binary-serialized `tf.train.Example` (equivalent to
174
+ /// `Example.SerializeToString()`) suitable for conversion to tensors with
175
+ /// `tf.io.parse_example`.
176
+ ///
177
+ /// Args:
178
+ /// * scope: A Scope object
179
+ /// * json_examples: Each string is a JSON object serialized according to the JSON
180
+ /// mapping of the Example proto.
181
+ ///
182
+ /// Returns:
183
+ /// * `Output`: Each string is a binary Example protocol buffer corresponding
184
+ /// to the respective element of `json_examples`.
185
+ class DecodeJSONExample {
186
+ public:
187
+ DecodeJSONExample(const ::tensorflow::Scope& scope, ::tensorflow::Input
188
+ json_examples);
189
+ operator ::tensorflow::Output() const { return binary_examples; }
190
+ operator ::tensorflow::Input() const { return binary_examples; }
191
+ ::tensorflow::Node* node() const { return binary_examples.node(); }
192
+
193
+ Operation operation;
194
+ ::tensorflow::Output binary_examples;
195
+ };
196
+
197
+ /// Reinterpret the bytes of a string as a vector of numbers.
198
+ ///
199
+ /// Args:
200
+ /// * scope: A Scope object
201
+ /// * input_bytes: Tensor of string to be decoded.
202
+ /// * fixed_length: Length in bytes for each element of the decoded output. Must be a multiple
203
+ /// of the size of the output type.
204
+ ///
205
+ /// Optional attributes (see `Attrs`):
206
+ /// * little_endian: Whether the input `input_bytes` is in little-endian order. Ignored for
207
+ /// `out_type` values that are stored in a single byte, like `uint8`
208
+ ///
209
+ /// Returns:
210
+ /// * `Output`: A Tensor with one more dimension than the input `bytes`. The added dimension
211
+ /// will have size equal to the length of the elements of `bytes` divided by the
212
+ /// number of bytes to represent `out_type`.
213
+ class DecodePaddedRaw {
214
+ public:
215
+ /// Optional attribute setters for DecodePaddedRaw
216
+ struct Attrs {
217
+ /// Whether the input `input_bytes` is in little-endian order. Ignored for
218
+ /// `out_type` values that are stored in a single byte, like `uint8`
219
+ ///
220
+ /// Defaults to true
221
+ TF_MUST_USE_RESULT Attrs LittleEndian(bool x) {
222
+ Attrs ret = *this;
223
+ ret.little_endian_ = x;
224
+ return ret;
225
+ }
226
+
227
+ bool little_endian_ = true;
228
+ };
229
+ DecodePaddedRaw(const ::tensorflow::Scope& scope, ::tensorflow::Input
230
+ input_bytes, ::tensorflow::Input fixed_length, DataType
231
+ out_type);
232
+ DecodePaddedRaw(const ::tensorflow::Scope& scope, ::tensorflow::Input
233
+ input_bytes, ::tensorflow::Input fixed_length, DataType
234
+ out_type, const DecodePaddedRaw::Attrs& attrs);
235
+ operator ::tensorflow::Output() const { return output; }
236
+ operator ::tensorflow::Input() const { return output; }
237
+ ::tensorflow::Node* node() const { return output.node(); }
238
+
239
+ static Attrs LittleEndian(bool x) {
240
+ return Attrs().LittleEndian(x);
241
+ }
242
+
243
+ Operation operation;
244
+ ::tensorflow::Output output;
245
+ };
246
+
247
+ /// Reinterpret the bytes of a string as a vector of numbers.
248
+ ///
249
+ /// Args:
250
+ /// * scope: A Scope object
251
+ /// * bytes: All the elements must have the same length.
252
+ ///
253
+ /// Optional attributes (see `Attrs`):
254
+ /// * little_endian: Whether the input `bytes` are in little-endian order.
255
+ /// Ignored for `out_type` values that are stored in a single byte like
256
+ /// `uint8`.
257
+ ///
258
+ /// Returns:
259
+ /// * `Output`: A Tensor with one more dimension than the input `bytes`. The
260
+ /// added dimension will have size equal to the length of the elements
261
+ /// of `bytes` divided by the number of bytes to represent `out_type`.
262
+ class DecodeRaw {
263
+ public:
264
+ /// Optional attribute setters for DecodeRaw
265
+ struct Attrs {
266
+ /// Whether the input `bytes` are in little-endian order.
267
+ /// Ignored for `out_type` values that are stored in a single byte like
268
+ /// `uint8`.
269
+ ///
270
+ /// Defaults to true
271
+ TF_MUST_USE_RESULT Attrs LittleEndian(bool x) {
272
+ Attrs ret = *this;
273
+ ret.little_endian_ = x;
274
+ return ret;
275
+ }
276
+
277
+ bool little_endian_ = true;
278
+ };
279
+ DecodeRaw(const ::tensorflow::Scope& scope, ::tensorflow::Input bytes, DataType
280
+ out_type);
281
+ DecodeRaw(const ::tensorflow::Scope& scope, ::tensorflow::Input bytes, DataType
282
+ out_type, const DecodeRaw::Attrs& attrs);
283
+ operator ::tensorflow::Output() const { return output; }
284
+ operator ::tensorflow::Input() const { return output; }
285
+ ::tensorflow::Node* node() const { return output.node(); }
286
+
287
+ static Attrs LittleEndian(bool x) {
288
+ return Attrs().LittleEndian(x);
289
+ }
290
+
291
+ Operation operation;
292
+ ::tensorflow::Output output;
293
+ };
294
+
295
+ /// Transforms a vector of brain.Example protos (as strings) into typed tensors.
296
+ ///
297
+ /// Args:
298
+ /// * scope: A Scope object
299
+ /// * serialized: A vector containing a batch of binary serialized Example protos.
300
+ /// * names: A vector containing the names of the serialized protos.
301
+ /// May contain, for example, table key (descriptive) names for the
302
+ /// corresponding serialized protos. These are purely useful for debugging
303
+ /// purposes, and the presence of values here has no effect on the output.
304
+ /// May also be an empty vector if no names are available.
305
+ /// If non-empty, this vector must be the same length as "serialized".
306
+ /// * sparse_keys: A list of Nsparse string Tensors (scalars).
307
+ /// The keys expected in the Examples' features associated with sparse values.
308
+ /// * dense_keys: A list of Ndense string Tensors (scalars).
309
+ /// The keys expected in the Examples' features associated with dense values.
310
+ /// * dense_defaults: A list of Ndense Tensors (some may be empty).
311
+ /// dense_defaults[j] provides default values
312
+ /// when the example's feature_map lacks dense_key[j]. If an empty Tensor is
313
+ /// provided for dense_defaults[j], then the Feature dense_keys[j] is required.
314
+ /// The input type is inferred from dense_defaults[j], even when it's empty.
315
+ /// If dense_defaults[j] is not empty, and dense_shapes[j] is fully defined,
316
+ /// then the shape of dense_defaults[j] must match that of dense_shapes[j].
317
+ /// If dense_shapes[j] has an undefined major dimension (variable strides dense
318
+ /// feature), dense_defaults[j] must contain a single element:
319
+ /// the padding element.
320
+ /// * sparse_types: A list of Nsparse types; the data types of data in each Feature
321
+ /// given in sparse_keys.
322
+ /// Currently the ParseExample supports DT_FLOAT (FloatList),
323
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
324
+ /// * dense_shapes: A list of Ndense shapes; the shapes of data in each Feature
325
+ /// given in dense_keys.
326
+ /// The number of elements in the Feature corresponding to dense_key[j]
327
+ /// must always equal dense_shapes[j].NumEntries().
328
+ /// If dense_shapes[j] == (D0, D1, ..., DN) then the shape of output
329
+ /// Tensor dense_values[j] will be (|serialized|, D0, D1, ..., DN):
330
+ /// The dense outputs are just the inputs row-stacked by batch.
331
+ /// This works for dense_shapes[j] = (-1, D1, ..., DN). In this case
332
+ /// the shape of the output Tensor dense_values[j] will be
333
+ /// (|serialized|, M, D1, .., DN), where M is the maximum number of blocks
334
+ /// of elements of length D1 * .... * DN, across all minibatch entries
335
+ /// in the input. Any minibatch entry with less than M blocks of elements of
336
+ /// length D1 * ... * DN will be padded with the corresponding default_value
337
+ /// scalar element along the second dimension.
338
+ ///
339
+ /// Returns:
340
+ /// * `OutputList` sparse_indices
341
+ /// * `OutputList` sparse_values
342
+ /// * `OutputList` sparse_shapes
343
+ /// * `OutputList` dense_values
344
+ class ParseExample {
345
+ public:
346
+ ParseExample(const ::tensorflow::Scope& scope, ::tensorflow::Input serialized,
347
+ ::tensorflow::Input names, ::tensorflow::InputList sparse_keys,
348
+ ::tensorflow::InputList dense_keys, ::tensorflow::InputList
349
+ dense_defaults, const DataTypeSlice& sparse_types, const
350
+ gtl::ArraySlice<PartialTensorShape>& dense_shapes);
351
+
352
+ Operation operation;
353
+ ::tensorflow::OutputList sparse_indices;
354
+ ::tensorflow::OutputList sparse_values;
355
+ ::tensorflow::OutputList sparse_shapes;
356
+ ::tensorflow::OutputList dense_values;
357
+ };
358
+
359
+ /// Transforms a vector of tf.Example protos (as strings) into typed tensors.
360
+ ///
361
+ /// Args:
362
+ /// * scope: A Scope object
363
+ /// * serialized: A scalar or vector containing binary serialized Example protos.
364
+ /// * names: A tensor containing the names of the serialized protos.
365
+ /// Corresponds 1:1 with the `serialized` tensor.
366
+ /// May contain, for example, table key (descriptive) names for the
367
+ /// corresponding serialized protos. These are purely useful for debugging
368
+ /// purposes, and the presence of values here has no effect on the output.
369
+ /// May also be an empty vector if no names are available.
370
+ /// If non-empty, this tensor must have the same shape as "serialized".
371
+ /// * sparse_keys: Vector of strings.
372
+ /// The keys expected in the Examples' features associated with sparse values.
373
+ /// * dense_keys: Vector of strings.
374
+ /// The keys expected in the Examples' features associated with dense values.
375
+ /// * ragged_keys: Vector of strings.
376
+ /// The keys expected in the Examples' features associated with ragged values.
377
+ /// * dense_defaults: A list of Tensors (some may be empty). Corresponds 1:1 with `dense_keys`.
378
+ /// dense_defaults[j] provides default values
379
+ /// when the example's feature_map lacks dense_key[j]. If an empty Tensor is
380
+ /// provided for dense_defaults[j], then the Feature dense_keys[j] is required.
381
+ /// The input type is inferred from dense_defaults[j], even when it's empty.
382
+ /// If dense_defaults[j] is not empty, and dense_shapes[j] is fully defined,
383
+ /// then the shape of dense_defaults[j] must match that of dense_shapes[j].
384
+ /// If dense_shapes[j] has an undefined major dimension (variable strides dense
385
+ /// feature), dense_defaults[j] must contain a single element:
386
+ /// the padding element.
387
+ /// * num_sparse: The number of sparse keys.
388
+ /// * sparse_types: A list of `num_sparse` types; the data types of data in each Feature
389
+ /// given in sparse_keys.
390
+ /// Currently the ParseExample supports DT_FLOAT (FloatList),
391
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
392
+ /// * ragged_value_types: A list of `num_ragged` types; the data types of data in each Feature
393
+ /// given in ragged_keys (where `num_ragged = sparse_keys.size()`).
394
+ /// Currently the ParseExample supports DT_FLOAT (FloatList),
395
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
396
+ /// * ragged_split_types: A list of `num_ragged` types; the data types of row_splits in each Feature
397
+ /// given in ragged_keys (where `num_ragged = sparse_keys.size()`).
398
+ /// May be DT_INT32 or DT_INT64.
399
+ /// * dense_shapes: A list of `num_dense` shapes; the shapes of data in each Feature
400
+ /// given in dense_keys (where `num_dense = dense_keys.size()`).
401
+ /// The number of elements in the Feature corresponding to dense_key[j]
402
+ /// must always equal dense_shapes[j].NumEntries().
403
+ /// If dense_shapes[j] == (D0, D1, ..., DN) then the shape of output
404
+ /// Tensor dense_values[j] will be (|serialized|, D0, D1, ..., DN):
405
+ /// The dense outputs are just the inputs row-stacked by batch.
406
+ /// This works for dense_shapes[j] = (-1, D1, ..., DN). In this case
407
+ /// the shape of the output Tensor dense_values[j] will be
408
+ /// (|serialized|, M, D1, .., DN), where M is the maximum number of blocks
409
+ /// of elements of length D1 * .... * DN, across all minibatch entries
410
+ /// in the input. Any minibatch entry with less than M blocks of elements of
411
+ /// length D1 * ... * DN will be padded with the corresponding default_value
412
+ /// scalar element along the second dimension.
413
+ ///
414
+ /// Returns:
415
+ /// * `OutputList` sparse_indices
416
+ /// * `OutputList` sparse_values
417
+ /// * `OutputList` sparse_shapes
418
+ /// * `OutputList` dense_values
419
+ /// * `OutputList` ragged_values
420
+ /// * `OutputList` ragged_row_splits
421
+ class ParseExampleV2 {
422
+ public:
423
+ ParseExampleV2(const ::tensorflow::Scope& scope, ::tensorflow::Input
424
+ serialized, ::tensorflow::Input names, ::tensorflow::Input
425
+ sparse_keys, ::tensorflow::Input dense_keys, ::tensorflow::Input
426
+ ragged_keys, ::tensorflow::InputList dense_defaults, int64
427
+ num_sparse, const DataTypeSlice& sparse_types, const
428
+ DataTypeSlice& ragged_value_types, const DataTypeSlice&
429
+ ragged_split_types, const gtl::ArraySlice<PartialTensorShape>&
430
+ dense_shapes);
431
+
432
+ Operation operation;
433
+ ::tensorflow::OutputList sparse_indices;
434
+ ::tensorflow::OutputList sparse_values;
435
+ ::tensorflow::OutputList sparse_shapes;
436
+ ::tensorflow::OutputList dense_values;
437
+ ::tensorflow::OutputList ragged_values;
438
+ ::tensorflow::OutputList ragged_row_splits;
439
+ };
440
+
441
+ /// Transforms a vector of brain.SequenceExample protos (as strings) into typed tensors.
442
+ ///
443
+ /// Args:
444
+ /// * scope: A Scope object
445
+ /// * serialized: A vector containing binary serialized SequenceExample protos.
446
+ /// * debug_name: A vector containing the names of the serialized protos.
447
+ /// May contain, for example, table key (descriptive) name for the
448
+ /// corresponding serialized proto. This is purely useful for debugging
449
+ /// purposes, and the presence of values here has no effect on the output.
450
+ /// May also be an empty vector if no name is available.
451
+ /// * context_dense_defaults: A list of Ncontext_dense Tensors (some may be empty).
452
+ /// context_dense_defaults[j] provides default values
453
+ /// when the SequenceExample's context map lacks context_dense_key[j].
454
+ /// If an empty Tensor is provided for context_dense_defaults[j],
455
+ /// then the Feature context_dense_keys[j] is required.
456
+ /// The input type is inferred from context_dense_defaults[j], even when it's
457
+ /// empty. If context_dense_defaults[j] is not empty, its shape must match
458
+ /// context_dense_shapes[j].
459
+ /// * feature_list_dense_missing_assumed_empty: A vector listing the
460
+ /// FeatureList keys which may be missing from the SequenceExamples. If the
461
+ /// associated FeatureList is missing, it is treated as empty. By default,
462
+ /// any FeatureList not listed in this vector must exist in the SequenceExamples.
463
+ /// * context_sparse_keys: A list of Ncontext_sparse string Tensors (scalars).
464
+ /// The keys expected in the Examples' features associated with context_sparse
465
+ /// values.
466
+ /// * context_dense_keys: A list of Ncontext_dense string Tensors (scalars).
467
+ /// The keys expected in the SequenceExamples' context features associated with
468
+ /// dense values.
469
+ /// * feature_list_sparse_keys: A list of Nfeature_list_sparse string Tensors
470
+ /// (scalars). The keys expected in the FeatureLists associated with sparse
471
+ /// values.
472
+ /// * feature_list_dense_keys: A list of Nfeature_list_dense string Tensors (scalars).
473
+ /// The keys expected in the SequenceExamples' feature_lists associated
474
+ /// with lists of dense values.
475
+ ///
476
+ /// Optional attributes (see `Attrs`):
477
+ /// * context_sparse_types: A list of Ncontext_sparse types; the data types of data in
478
+ /// each context Feature given in context_sparse_keys.
479
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
480
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
481
+ /// * context_dense_shapes: A list of Ncontext_dense shapes; the shapes of data in
482
+ /// each context Feature given in context_dense_keys.
483
+ /// The number of elements in the Feature corresponding to context_dense_key[j]
484
+ /// must always equal context_dense_shapes[j].NumEntries().
485
+ /// The shape of context_dense_values[j] will match context_dense_shapes[j].
486
+ /// * feature_list_sparse_types: A list of Nfeature_list_sparse types; the data types
487
+ /// of data in each FeatureList given in feature_list_sparse_keys.
488
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
489
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
490
+ /// * feature_list_dense_shapes: A list of Nfeature_list_dense shapes; the shapes of
491
+ /// data in each FeatureList given in feature_list_dense_keys.
492
+ /// The shape of each Feature in the FeatureList corresponding to
493
+ /// feature_list_dense_key[j] must always equal
494
+ /// feature_list_dense_shapes[j].NumEntries().
495
+ ///
496
+ /// Returns:
497
+ /// * `OutputList` context_sparse_indices
498
+ /// * `OutputList` context_sparse_values
499
+ /// * `OutputList` context_sparse_shapes
500
+ /// * `OutputList` context_dense_values
501
+ /// * `OutputList` feature_list_sparse_indices
502
+ /// * `OutputList` feature_list_sparse_values
503
+ /// * `OutputList` feature_list_sparse_shapes
504
+ /// * `OutputList` feature_list_dense_values
505
+ /// * `OutputList` feature_list_dense_lengths
506
+ class ParseSequenceExample {
507
+ public:
508
+ /// Optional attribute setters for ParseSequenceExample
509
+ struct Attrs {
510
+ /// Defaults to 0
511
+ TF_MUST_USE_RESULT Attrs NcontextSparse(int64 x) {
512
+ Attrs ret = *this;
513
+ ret.Ncontext_sparse_ = x;
514
+ return ret;
515
+ }
516
+
517
+ /// Defaults to 0
518
+ TF_MUST_USE_RESULT Attrs NcontextDense(int64 x) {
519
+ Attrs ret = *this;
520
+ ret.Ncontext_dense_ = x;
521
+ return ret;
522
+ }
523
+
524
+ /// Defaults to 0
525
+ TF_MUST_USE_RESULT Attrs NfeatureListSparse(int64 x) {
526
+ Attrs ret = *this;
527
+ ret.Nfeature_list_sparse_ = x;
528
+ return ret;
529
+ }
530
+
531
+ /// Defaults to 0
532
+ TF_MUST_USE_RESULT Attrs NfeatureListDense(int64 x) {
533
+ Attrs ret = *this;
534
+ ret.Nfeature_list_dense_ = x;
535
+ return ret;
536
+ }
537
+
538
+ /// A list of Ncontext_sparse types; the data types of data in
539
+ /// each context Feature given in context_sparse_keys.
540
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
541
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
542
+ ///
543
+ /// Defaults to []
544
+ TF_MUST_USE_RESULT Attrs ContextSparseTypes(const DataTypeSlice& x) {
545
+ Attrs ret = *this;
546
+ ret.context_sparse_types_ = x;
547
+ return ret;
548
+ }
549
+
550
+ /// Defaults to []
551
+ TF_MUST_USE_RESULT Attrs FeatureListDenseTypes(const DataTypeSlice& x) {
552
+ Attrs ret = *this;
553
+ ret.feature_list_dense_types_ = x;
554
+ return ret;
555
+ }
556
+
557
+ /// A list of Ncontext_dense shapes; the shapes of data in
558
+ /// each context Feature given in context_dense_keys.
559
+ /// The number of elements in the Feature corresponding to context_dense_key[j]
560
+ /// must always equal context_dense_shapes[j].NumEntries().
561
+ /// The shape of context_dense_values[j] will match context_dense_shapes[j].
562
+ ///
563
+ /// Defaults to []
564
+ TF_MUST_USE_RESULT Attrs ContextDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
565
+ Attrs ret = *this;
566
+ ret.context_dense_shapes_ = x;
567
+ return ret;
568
+ }
569
+
570
+ /// A list of Nfeature_list_sparse types; the data types
571
+ /// of data in each FeatureList given in feature_list_sparse_keys.
572
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
573
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
574
+ ///
575
+ /// Defaults to []
576
+ TF_MUST_USE_RESULT Attrs FeatureListSparseTypes(const DataTypeSlice& x) {
577
+ Attrs ret = *this;
578
+ ret.feature_list_sparse_types_ = x;
579
+ return ret;
580
+ }
581
+
582
+ /// A list of Nfeature_list_dense shapes; the shapes of
583
+ /// data in each FeatureList given in feature_list_dense_keys.
584
+ /// The shape of each Feature in the FeatureList corresponding to
585
+ /// feature_list_dense_key[j] must always equal
586
+ /// feature_list_dense_shapes[j].NumEntries().
587
+ ///
588
+ /// Defaults to []
589
+ TF_MUST_USE_RESULT Attrs FeatureListDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
590
+ Attrs ret = *this;
591
+ ret.feature_list_dense_shapes_ = x;
592
+ return ret;
593
+ }
594
+
595
+ int64 Ncontext_sparse_ = 0;
596
+ int64 Ncontext_dense_ = 0;
597
+ int64 Nfeature_list_sparse_ = 0;
598
+ int64 Nfeature_list_dense_ = 0;
599
+ DataTypeSlice context_sparse_types_ = {};
600
+ DataTypeSlice feature_list_dense_types_ = {};
601
+ gtl::ArraySlice<PartialTensorShape> context_dense_shapes_ = {};
602
+ DataTypeSlice feature_list_sparse_types_ = {};
603
+ gtl::ArraySlice<PartialTensorShape> feature_list_dense_shapes_ = {};
604
+ };
605
+ ParseSequenceExample(const ::tensorflow::Scope& scope, ::tensorflow::Input
606
+ serialized, ::tensorflow::Input debug_name,
607
+ ::tensorflow::InputList context_dense_defaults, const
608
+ gtl::ArraySlice<::tensorflow::tstring>&
609
+ feature_list_dense_missing_assumed_empty, const
610
+ gtl::ArraySlice<::tensorflow::tstring>&
611
+ context_sparse_keys, const
612
+ gtl::ArraySlice<::tensorflow::tstring>&
613
+ context_dense_keys, const
614
+ gtl::ArraySlice<::tensorflow::tstring>&
615
+ feature_list_sparse_keys, const
616
+ gtl::ArraySlice<::tensorflow::tstring>&
617
+ feature_list_dense_keys);
618
+ ParseSequenceExample(const ::tensorflow::Scope& scope, ::tensorflow::Input
619
+ serialized, ::tensorflow::Input debug_name,
620
+ ::tensorflow::InputList context_dense_defaults, const
621
+ gtl::ArraySlice<::tensorflow::tstring>&
622
+ feature_list_dense_missing_assumed_empty, const
623
+ gtl::ArraySlice<::tensorflow::tstring>&
624
+ context_sparse_keys, const
625
+ gtl::ArraySlice<::tensorflow::tstring>&
626
+ context_dense_keys, const
627
+ gtl::ArraySlice<::tensorflow::tstring>&
628
+ feature_list_sparse_keys, const
629
+ gtl::ArraySlice<::tensorflow::tstring>&
630
+ feature_list_dense_keys, const
631
+ ParseSequenceExample::Attrs& attrs);
632
+
633
+ static Attrs NcontextSparse(int64 x) {
634
+ return Attrs().NcontextSparse(x);
635
+ }
636
+ static Attrs NcontextDense(int64 x) {
637
+ return Attrs().NcontextDense(x);
638
+ }
639
+ static Attrs NfeatureListSparse(int64 x) {
640
+ return Attrs().NfeatureListSparse(x);
641
+ }
642
+ static Attrs NfeatureListDense(int64 x) {
643
+ return Attrs().NfeatureListDense(x);
644
+ }
645
+ static Attrs ContextSparseTypes(const DataTypeSlice& x) {
646
+ return Attrs().ContextSparseTypes(x);
647
+ }
648
+ static Attrs FeatureListDenseTypes(const DataTypeSlice& x) {
649
+ return Attrs().FeatureListDenseTypes(x);
650
+ }
651
+ static Attrs ContextDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
652
+ return Attrs().ContextDenseShapes(x);
653
+ }
654
+ static Attrs FeatureListSparseTypes(const DataTypeSlice& x) {
655
+ return Attrs().FeatureListSparseTypes(x);
656
+ }
657
+ static Attrs FeatureListDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
658
+ return Attrs().FeatureListDenseShapes(x);
659
+ }
660
+
661
+ Operation operation;
662
+ ::tensorflow::OutputList context_sparse_indices;
663
+ ::tensorflow::OutputList context_sparse_values;
664
+ ::tensorflow::OutputList context_sparse_shapes;
665
+ ::tensorflow::OutputList context_dense_values;
666
+ ::tensorflow::OutputList feature_list_sparse_indices;
667
+ ::tensorflow::OutputList feature_list_sparse_values;
668
+ ::tensorflow::OutputList feature_list_sparse_shapes;
669
+ ::tensorflow::OutputList feature_list_dense_values;
670
+ ::tensorflow::OutputList feature_list_dense_lengths;
671
+ };
672
+
673
+ /// Transforms a vector of tf.io.SequenceExample protos (as strings) into
674
+ /// typed tensors.
675
+ ///
676
+ /// Args:
677
+ /// * scope: A Scope object
678
+ /// * serialized: A scalar or vector containing binary serialized SequenceExample protos.
679
+ /// * debug_name: A scalar or vector containing the names of the serialized protos.
680
+ /// May contain, for example, table key (descriptive) name for the
681
+ /// corresponding serialized proto. This is purely useful for debugging
682
+ /// purposes, and the presence of values here has no effect on the output.
683
+ /// May also be an empty vector if no name is available.
684
+ /// * context_sparse_keys: The keys expected in the Examples' features associated with context_sparse
685
+ /// values.
686
+ /// * context_dense_keys: The keys expected in the SequenceExamples' context features associated with
687
+ /// dense values.
688
+ /// * context_ragged_keys: The keys expected in the Examples' features associated with context_ragged
689
+ /// values.
690
+ /// * feature_list_sparse_keys: The keys expected in the FeatureLists associated with sparse values.
691
+ /// * feature_list_dense_keys: The keys expected in the SequenceExamples' feature_lists associated
692
+ /// with lists of dense values.
693
+ /// * feature_list_ragged_keys: The keys expected in the FeatureLists associated with ragged values.
694
+ /// * feature_list_dense_missing_assumed_empty: A vector corresponding 1:1 with feature_list_dense_keys, indicating which
695
+ /// features may be missing from the SequenceExamples. If the associated
696
+ /// FeatureList is missing, it is treated as empty.
697
+ /// * context_dense_defaults: A list of Ncontext_dense Tensors (some may be empty).
698
+ /// context_dense_defaults[j] provides default values
699
+ /// when the SequenceExample's context map lacks context_dense_key[j].
700
+ /// If an empty Tensor is provided for context_dense_defaults[j],
701
+ /// then the Feature context_dense_keys[j] is required.
702
+ /// The input type is inferred from context_dense_defaults[j], even when it's
703
+ /// empty. If context_dense_defaults[j] is not empty, its shape must match
704
+ /// context_dense_shapes[j].
705
+ ///
706
+ /// Optional attributes (see `Attrs`):
707
+ /// * context_sparse_types: A list of Ncontext_sparse types; the data types of data in
708
+ /// each context Feature given in context_sparse_keys.
709
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
710
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
711
+ /// * context_ragged_value_types: RaggedTensor.value dtypes for the ragged context features.
712
+ /// * context_ragged_split_types: RaggedTensor.row_split dtypes for the ragged context features.
713
+ /// * context_dense_shapes: A list of Ncontext_dense shapes; the shapes of data in
714
+ /// each context Feature given in context_dense_keys.
715
+ /// The number of elements in the Feature corresponding to context_dense_key[j]
716
+ /// must always equal context_dense_shapes[j].NumEntries().
717
+ /// The shape of context_dense_values[j] will match context_dense_shapes[j].
718
+ /// * feature_list_sparse_types: A list of Nfeature_list_sparse types; the data types
719
+ /// of data in each FeatureList given in feature_list_sparse_keys.
720
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
721
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
722
+ /// * feature_list_ragged_value_types: RaggedTensor.value dtypes for the ragged FeatureList features.
723
+ /// * feature_list_ragged_split_types: RaggedTensor.row_split dtypes for the ragged FeatureList features.
724
+ /// * feature_list_dense_shapes: A list of Nfeature_list_dense shapes; the shapes of
725
+ /// data in each FeatureList given in feature_list_dense_keys.
726
+ /// The shape of each Feature in the FeatureList corresponding to
727
+ /// feature_list_dense_key[j] must always equal
728
+ /// feature_list_dense_shapes[j].NumEntries().
729
+ ///
730
+ /// Returns:
731
+ /// * `OutputList` context_sparse_indices
732
+ /// * `OutputList` context_sparse_values
733
+ /// * `OutputList` context_sparse_shapes
734
+ /// * `OutputList` context_dense_values
735
+ /// * `OutputList` context_ragged_values
736
+ /// * `OutputList` context_ragged_row_splits
737
+ /// * `OutputList` feature_list_sparse_indices
738
+ /// * `OutputList` feature_list_sparse_values
739
+ /// * `OutputList` feature_list_sparse_shapes
740
+ /// * `OutputList` feature_list_dense_values
741
+ /// * `OutputList` feature_list_dense_lengths
742
+ /// * `OutputList` feature_list_ragged_values
743
+ /// * `OutputList` feature_list_ragged_outer_splits
744
+ /// * `OutputList` feature_list_ragged_inner_splits
745
+ class ParseSequenceExampleV2 {
746
+ public:
747
+ /// Optional attribute setters for ParseSequenceExampleV2
748
+ struct Attrs {
749
+ /// Defaults to 0
750
+ TF_MUST_USE_RESULT Attrs NcontextSparse(int64 x) {
751
+ Attrs ret = *this;
752
+ ret.Ncontext_sparse_ = x;
753
+ return ret;
754
+ }
755
+
756
+ /// A list of Ncontext_sparse types; the data types of data in
757
+ /// each context Feature given in context_sparse_keys.
758
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
759
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
760
+ ///
761
+ /// Defaults to []
762
+ TF_MUST_USE_RESULT Attrs ContextSparseTypes(const DataTypeSlice& x) {
763
+ Attrs ret = *this;
764
+ ret.context_sparse_types_ = x;
765
+ return ret;
766
+ }
767
+
768
+ /// RaggedTensor.value dtypes for the ragged context features.
769
+ ///
770
+ /// Defaults to []
771
+ TF_MUST_USE_RESULT Attrs ContextRaggedValueTypes(const DataTypeSlice& x) {
772
+ Attrs ret = *this;
773
+ ret.context_ragged_value_types_ = x;
774
+ return ret;
775
+ }
776
+
777
+ /// RaggedTensor.row_split dtypes for the ragged context features.
778
+ ///
779
+ /// Defaults to []
780
+ TF_MUST_USE_RESULT Attrs ContextRaggedSplitTypes(const DataTypeSlice& x) {
781
+ Attrs ret = *this;
782
+ ret.context_ragged_split_types_ = x;
783
+ return ret;
784
+ }
785
+
786
+ /// A list of Ncontext_dense shapes; the shapes of data in
787
+ /// each context Feature given in context_dense_keys.
788
+ /// The number of elements in the Feature corresponding to context_dense_key[j]
789
+ /// must always equal context_dense_shapes[j].NumEntries().
790
+ /// The shape of context_dense_values[j] will match context_dense_shapes[j].
791
+ ///
792
+ /// Defaults to []
793
+ TF_MUST_USE_RESULT Attrs ContextDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
794
+ Attrs ret = *this;
795
+ ret.context_dense_shapes_ = x;
796
+ return ret;
797
+ }
798
+
799
+ /// Defaults to 0
800
+ TF_MUST_USE_RESULT Attrs NfeatureListSparse(int64 x) {
801
+ Attrs ret = *this;
802
+ ret.Nfeature_list_sparse_ = x;
803
+ return ret;
804
+ }
805
+
806
+ /// Defaults to 0
807
+ TF_MUST_USE_RESULT Attrs NfeatureListDense(int64 x) {
808
+ Attrs ret = *this;
809
+ ret.Nfeature_list_dense_ = x;
810
+ return ret;
811
+ }
812
+
813
+ /// Defaults to []
814
+ TF_MUST_USE_RESULT Attrs FeatureListDenseTypes(const DataTypeSlice& x) {
815
+ Attrs ret = *this;
816
+ ret.feature_list_dense_types_ = x;
817
+ return ret;
818
+ }
819
+
820
+ /// A list of Nfeature_list_sparse types; the data types
821
+ /// of data in each FeatureList given in feature_list_sparse_keys.
822
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
823
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
824
+ ///
825
+ /// Defaults to []
826
+ TF_MUST_USE_RESULT Attrs FeatureListSparseTypes(const DataTypeSlice& x) {
827
+ Attrs ret = *this;
828
+ ret.feature_list_sparse_types_ = x;
829
+ return ret;
830
+ }
831
+
832
+ /// RaggedTensor.value dtypes for the ragged FeatureList features.
833
+ ///
834
+ /// Defaults to []
835
+ TF_MUST_USE_RESULT Attrs FeatureListRaggedValueTypes(const DataTypeSlice& x) {
836
+ Attrs ret = *this;
837
+ ret.feature_list_ragged_value_types_ = x;
838
+ return ret;
839
+ }
840
+
841
+ /// RaggedTensor.row_split dtypes for the ragged FeatureList features.
842
+ ///
843
+ /// Defaults to []
844
+ TF_MUST_USE_RESULT Attrs FeatureListRaggedSplitTypes(const DataTypeSlice& x) {
845
+ Attrs ret = *this;
846
+ ret.feature_list_ragged_split_types_ = x;
847
+ return ret;
848
+ }
849
+
850
+ /// A list of Nfeature_list_dense shapes; the shapes of
851
+ /// data in each FeatureList given in feature_list_dense_keys.
852
+ /// The shape of each Feature in the FeatureList corresponding to
853
+ /// feature_list_dense_key[j] must always equal
854
+ /// feature_list_dense_shapes[j].NumEntries().
855
+ ///
856
+ /// Defaults to []
857
+ TF_MUST_USE_RESULT Attrs FeatureListDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
858
+ Attrs ret = *this;
859
+ ret.feature_list_dense_shapes_ = x;
860
+ return ret;
861
+ }
862
+
863
+ int64 Ncontext_sparse_ = 0;
864
+ DataTypeSlice context_sparse_types_ = {};
865
+ DataTypeSlice context_ragged_value_types_ = {};
866
+ DataTypeSlice context_ragged_split_types_ = {};
867
+ gtl::ArraySlice<PartialTensorShape> context_dense_shapes_ = {};
868
+ int64 Nfeature_list_sparse_ = 0;
869
+ int64 Nfeature_list_dense_ = 0;
870
+ DataTypeSlice feature_list_dense_types_ = {};
871
+ DataTypeSlice feature_list_sparse_types_ = {};
872
+ DataTypeSlice feature_list_ragged_value_types_ = {};
873
+ DataTypeSlice feature_list_ragged_split_types_ = {};
874
+ gtl::ArraySlice<PartialTensorShape> feature_list_dense_shapes_ = {};
875
+ };
876
+ ParseSequenceExampleV2(const ::tensorflow::Scope& scope, ::tensorflow::Input
877
+ serialized, ::tensorflow::Input debug_name,
878
+ ::tensorflow::Input context_sparse_keys,
879
+ ::tensorflow::Input context_dense_keys,
880
+ ::tensorflow::Input context_ragged_keys,
881
+ ::tensorflow::Input feature_list_sparse_keys,
882
+ ::tensorflow::Input feature_list_dense_keys,
883
+ ::tensorflow::Input feature_list_ragged_keys,
884
+ ::tensorflow::Input
885
+ feature_list_dense_missing_assumed_empty,
886
+ ::tensorflow::InputList context_dense_defaults);
887
+ ParseSequenceExampleV2(const ::tensorflow::Scope& scope, ::tensorflow::Input
888
+ serialized, ::tensorflow::Input debug_name,
889
+ ::tensorflow::Input context_sparse_keys,
890
+ ::tensorflow::Input context_dense_keys,
891
+ ::tensorflow::Input context_ragged_keys,
892
+ ::tensorflow::Input feature_list_sparse_keys,
893
+ ::tensorflow::Input feature_list_dense_keys,
894
+ ::tensorflow::Input feature_list_ragged_keys,
895
+ ::tensorflow::Input
896
+ feature_list_dense_missing_assumed_empty,
897
+ ::tensorflow::InputList context_dense_defaults, const
898
+ ParseSequenceExampleV2::Attrs& attrs);
899
+
900
+ static Attrs NcontextSparse(int64 x) {
901
+ return Attrs().NcontextSparse(x);
902
+ }
903
+ static Attrs ContextSparseTypes(const DataTypeSlice& x) {
904
+ return Attrs().ContextSparseTypes(x);
905
+ }
906
+ static Attrs ContextRaggedValueTypes(const DataTypeSlice& x) {
907
+ return Attrs().ContextRaggedValueTypes(x);
908
+ }
909
+ static Attrs ContextRaggedSplitTypes(const DataTypeSlice& x) {
910
+ return Attrs().ContextRaggedSplitTypes(x);
911
+ }
912
+ static Attrs ContextDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
913
+ return Attrs().ContextDenseShapes(x);
914
+ }
915
+ static Attrs NfeatureListSparse(int64 x) {
916
+ return Attrs().NfeatureListSparse(x);
917
+ }
918
+ static Attrs NfeatureListDense(int64 x) {
919
+ return Attrs().NfeatureListDense(x);
920
+ }
921
+ static Attrs FeatureListDenseTypes(const DataTypeSlice& x) {
922
+ return Attrs().FeatureListDenseTypes(x);
923
+ }
924
+ static Attrs FeatureListSparseTypes(const DataTypeSlice& x) {
925
+ return Attrs().FeatureListSparseTypes(x);
926
+ }
927
+ static Attrs FeatureListRaggedValueTypes(const DataTypeSlice& x) {
928
+ return Attrs().FeatureListRaggedValueTypes(x);
929
+ }
930
+ static Attrs FeatureListRaggedSplitTypes(const DataTypeSlice& x) {
931
+ return Attrs().FeatureListRaggedSplitTypes(x);
932
+ }
933
+ static Attrs FeatureListDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
934
+ return Attrs().FeatureListDenseShapes(x);
935
+ }
936
+
937
+ Operation operation;
938
+ ::tensorflow::OutputList context_sparse_indices;
939
+ ::tensorflow::OutputList context_sparse_values;
940
+ ::tensorflow::OutputList context_sparse_shapes;
941
+ ::tensorflow::OutputList context_dense_values;
942
+ ::tensorflow::OutputList context_ragged_values;
943
+ ::tensorflow::OutputList context_ragged_row_splits;
944
+ ::tensorflow::OutputList feature_list_sparse_indices;
945
+ ::tensorflow::OutputList feature_list_sparse_values;
946
+ ::tensorflow::OutputList feature_list_sparse_shapes;
947
+ ::tensorflow::OutputList feature_list_dense_values;
948
+ ::tensorflow::OutputList feature_list_dense_lengths;
949
+ ::tensorflow::OutputList feature_list_ragged_values;
950
+ ::tensorflow::OutputList feature_list_ragged_outer_splits;
951
+ ::tensorflow::OutputList feature_list_ragged_inner_splits;
952
+ };
953
+
954
+ /// Transforms a tf.Example proto (as a string) into typed tensors.
955
+ ///
956
+ /// Args:
957
+ /// * scope: A Scope object
958
+ /// * serialized: A vector containing a batch of binary serialized Example protos.
959
+ /// * dense_defaults: A list of Tensors (some may be empty), whose length matches
960
+ /// the length of `dense_keys`. dense_defaults[j] provides default values
961
+ /// when the example's feature_map lacks dense_key[j]. If an empty Tensor is
962
+ /// provided for dense_defaults[j], then the Feature dense_keys[j] is required.
963
+ /// The input type is inferred from dense_defaults[j], even when it's empty.
964
+ /// If dense_defaults[j] is not empty, and dense_shapes[j] is fully defined,
965
+ /// then the shape of dense_defaults[j] must match that of dense_shapes[j].
966
+ /// If dense_shapes[j] has an undefined major dimension (variable strides dense
967
+ /// feature), dense_defaults[j] must contain a single element:
968
+ /// the padding element.
969
+ /// * num_sparse: The number of sparse features to be parsed from the example. This
970
+ /// must match the lengths of `sparse_keys` and `sparse_types`.
971
+ /// * sparse_keys: A list of `num_sparse` strings.
972
+ /// The keys expected in the Examples' features associated with sparse values.
973
+ /// * dense_keys: The keys expected in the Examples' features associated with dense
974
+ /// values.
975
+ /// * sparse_types: A list of `num_sparse` types; the data types of data in each
976
+ /// Feature given in sparse_keys.
977
+ /// Currently the ParseSingleExample op supports DT_FLOAT (FloatList),
978
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
979
+ /// * dense_shapes: The shapes of data in each Feature given in dense_keys.
980
+ /// The length of this list must match the length of `dense_keys`. The
981
+ /// number of elements in the Feature corresponding to dense_key[j] must
982
+ /// always equal dense_shapes[j].NumEntries(). If dense_shapes[j] ==
983
+ /// (D0, D1, ..., DN) then the shape of output Tensor dense_values[j]
984
+ /// will be (D0, D1, ..., DN): In the case dense_shapes[j] = (-1, D1,
985
+ /// ..., DN), the shape of the output Tensor dense_values[j] will be (M,
986
+ /// D1, .., DN), where M is the number of blocks of elements of length
987
+ /// D1 * .... * DN, in the input.
988
+ ///
989
+ /// Returns:
990
+ /// * `OutputList` sparse_indices
991
+ /// * `OutputList` sparse_values
992
+ /// * `OutputList` sparse_shapes
993
+ /// * `OutputList` dense_values
994
+ class ParseSingleExample {
995
+ public:
996
+ ParseSingleExample(const ::tensorflow::Scope& scope, ::tensorflow::Input
997
+ serialized, ::tensorflow::InputList dense_defaults, int64
998
+ num_sparse, const gtl::ArraySlice<::tensorflow::tstring>&
999
+ sparse_keys, const gtl::ArraySlice<::tensorflow::tstring>&
1000
+ dense_keys, const DataTypeSlice& sparse_types, const
1001
+ gtl::ArraySlice<PartialTensorShape>& dense_shapes);
1002
+
1003
+ Operation operation;
1004
+ ::tensorflow::OutputList sparse_indices;
1005
+ ::tensorflow::OutputList sparse_values;
1006
+ ::tensorflow::OutputList sparse_shapes;
1007
+ ::tensorflow::OutputList dense_values;
1008
+ };
1009
+
1010
+ /// Transforms a scalar brain.SequenceExample proto (as strings) into typed tensors.
1011
+ ///
1012
+ /// Args:
1013
+ /// * scope: A Scope object
1014
+ /// * serialized: A scalar containing a binary serialized SequenceExample proto.
1015
+ /// * feature_list_dense_missing_assumed_empty: A vector listing the
1016
+ /// FeatureList keys which may be missing from the SequenceExample. If the
1017
+ /// associated FeatureList is missing, it is treated as empty. By default,
1018
+ /// any FeatureList not listed in this vector must exist in the SequenceExample.
1019
+ /// * context_sparse_keys: A list of Ncontext_sparse string Tensors (scalars).
1020
+ /// The keys expected in the Examples' features associated with context_sparse
1021
+ /// values.
1022
+ /// * context_dense_keys: A list of Ncontext_dense string Tensors (scalars).
1023
+ /// The keys expected in the SequenceExamples' context features associated with
1024
+ /// dense values.
1025
+ /// * feature_list_sparse_keys: A list of Nfeature_list_sparse string Tensors
1026
+ /// (scalars). The keys expected in the FeatureLists associated with sparse
1027
+ /// values.
1028
+ /// * feature_list_dense_keys: A list of Nfeature_list_dense string Tensors (scalars).
1029
+ /// The keys expected in the SequenceExamples' feature_lists associated
1030
+ /// with lists of dense values.
1031
+ /// * context_dense_defaults: A list of Ncontext_dense Tensors (some may be empty).
1032
+ /// context_dense_defaults[j] provides default values
1033
+ /// when the SequenceExample's context map lacks context_dense_key[j].
1034
+ /// If an empty Tensor is provided for context_dense_defaults[j],
1035
+ /// then the Feature context_dense_keys[j] is required.
1036
+ /// The input type is inferred from context_dense_defaults[j], even when it's
1037
+ /// empty. If context_dense_defaults[j] is not empty, its shape must match
1038
+ /// context_dense_shapes[j].
1039
+ /// * debug_name: A scalar containing the name of the serialized proto.
1040
+ /// May contain, for example, table key (descriptive) name for the
1041
+ /// corresponding serialized proto. This is purely useful for debugging
1042
+ /// purposes, and the presence of values here has no effect on the output.
1043
+ /// May also be an empty scalar if no name is available.
1044
+ ///
1045
+ /// Optional attributes (see `Attrs`):
1046
+ /// * context_sparse_types: A list of Ncontext_sparse types; the data types of data in
1047
+ /// each context Feature given in context_sparse_keys.
1048
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
1049
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
1050
+ /// * context_dense_shapes: A list of Ncontext_dense shapes; the shapes of data in
1051
+ /// each context Feature given in context_dense_keys.
1052
+ /// The number of elements in the Feature corresponding to context_dense_key[j]
1053
+ /// must always equal context_dense_shapes[j].NumEntries().
1054
+ /// The shape of context_dense_values[j] will match context_dense_shapes[j].
1055
+ /// * feature_list_sparse_types: A list of Nfeature_list_sparse types; the data types
1056
+ /// of data in each FeatureList given in feature_list_sparse_keys.
1057
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
1058
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
1059
+ /// * feature_list_dense_shapes: A list of Nfeature_list_dense shapes; the shapes of
1060
+ /// data in each FeatureList given in feature_list_dense_keys.
1061
+ /// The shape of each Feature in the FeatureList corresponding to
1062
+ /// feature_list_dense_key[j] must always equal
1063
+ /// feature_list_dense_shapes[j].NumEntries().
1064
+ ///
1065
+ /// Returns:
1066
+ /// * `OutputList` context_sparse_indices
1067
+ /// * `OutputList` context_sparse_values
1068
+ /// * `OutputList` context_sparse_shapes
1069
+ /// * `OutputList` context_dense_values
1070
+ /// * `OutputList` feature_list_sparse_indices
1071
+ /// * `OutputList` feature_list_sparse_values
1072
+ /// * `OutputList` feature_list_sparse_shapes
1073
+ /// * `OutputList` feature_list_dense_values
1074
+ class ParseSingleSequenceExample {
1075
+ public:
1076
+ /// Optional attribute setters for ParseSingleSequenceExample
1077
+ struct Attrs {
1078
+ /// A list of Ncontext_sparse types; the data types of data in
1079
+ /// each context Feature given in context_sparse_keys.
1080
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
1081
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
1082
+ ///
1083
+ /// Defaults to []
1084
+ TF_MUST_USE_RESULT Attrs ContextSparseTypes(const DataTypeSlice& x) {
1085
+ Attrs ret = *this;
1086
+ ret.context_sparse_types_ = x;
1087
+ return ret;
1088
+ }
1089
+
1090
+ /// Defaults to []
1091
+ TF_MUST_USE_RESULT Attrs FeatureListDenseTypes(const DataTypeSlice& x) {
1092
+ Attrs ret = *this;
1093
+ ret.feature_list_dense_types_ = x;
1094
+ return ret;
1095
+ }
1096
+
1097
+ /// A list of Ncontext_dense shapes; the shapes of data in
1098
+ /// each context Feature given in context_dense_keys.
1099
+ /// The number of elements in the Feature corresponding to context_dense_key[j]
1100
+ /// must always equal context_dense_shapes[j].NumEntries().
1101
+ /// The shape of context_dense_values[j] will match context_dense_shapes[j].
1102
+ ///
1103
+ /// Defaults to []
1104
+ TF_MUST_USE_RESULT Attrs ContextDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
1105
+ Attrs ret = *this;
1106
+ ret.context_dense_shapes_ = x;
1107
+ return ret;
1108
+ }
1109
+
1110
+ /// A list of Nfeature_list_sparse types; the data types
1111
+ /// of data in each FeatureList given in feature_list_sparse_keys.
1112
+ /// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
1113
+ /// DT_INT64 (Int64List), and DT_STRING (BytesList).
1114
+ ///
1115
+ /// Defaults to []
1116
+ TF_MUST_USE_RESULT Attrs FeatureListSparseTypes(const DataTypeSlice& x) {
1117
+ Attrs ret = *this;
1118
+ ret.feature_list_sparse_types_ = x;
1119
+ return ret;
1120
+ }
1121
+
1122
+ /// A list of Nfeature_list_dense shapes; the shapes of
1123
+ /// data in each FeatureList given in feature_list_dense_keys.
1124
+ /// The shape of each Feature in the FeatureList corresponding to
1125
+ /// feature_list_dense_key[j] must always equal
1126
+ /// feature_list_dense_shapes[j].NumEntries().
1127
+ ///
1128
+ /// Defaults to []
1129
+ TF_MUST_USE_RESULT Attrs FeatureListDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
1130
+ Attrs ret = *this;
1131
+ ret.feature_list_dense_shapes_ = x;
1132
+ return ret;
1133
+ }
1134
+
1135
+ DataTypeSlice context_sparse_types_ = {};
1136
+ DataTypeSlice feature_list_dense_types_ = {};
1137
+ gtl::ArraySlice<PartialTensorShape> context_dense_shapes_ = {};
1138
+ DataTypeSlice feature_list_sparse_types_ = {};
1139
+ gtl::ArraySlice<PartialTensorShape> feature_list_dense_shapes_ = {};
1140
+ };
1141
+ ParseSingleSequenceExample(const ::tensorflow::Scope& scope,
1142
+ ::tensorflow::Input serialized, ::tensorflow::Input
1143
+ feature_list_dense_missing_assumed_empty,
1144
+ ::tensorflow::InputList context_sparse_keys,
1145
+ ::tensorflow::InputList context_dense_keys,
1146
+ ::tensorflow::InputList feature_list_sparse_keys,
1147
+ ::tensorflow::InputList feature_list_dense_keys,
1148
+ ::tensorflow::InputList context_dense_defaults,
1149
+ ::tensorflow::Input debug_name);
1150
+ ParseSingleSequenceExample(const ::tensorflow::Scope& scope,
1151
+ ::tensorflow::Input serialized, ::tensorflow::Input
1152
+ feature_list_dense_missing_assumed_empty,
1153
+ ::tensorflow::InputList context_sparse_keys,
1154
+ ::tensorflow::InputList context_dense_keys,
1155
+ ::tensorflow::InputList feature_list_sparse_keys,
1156
+ ::tensorflow::InputList feature_list_dense_keys,
1157
+ ::tensorflow::InputList context_dense_defaults,
1158
+ ::tensorflow::Input debug_name, const
1159
+ ParseSingleSequenceExample::Attrs& attrs);
1160
+
1161
+ static Attrs ContextSparseTypes(const DataTypeSlice& x) {
1162
+ return Attrs().ContextSparseTypes(x);
1163
+ }
1164
+ static Attrs FeatureListDenseTypes(const DataTypeSlice& x) {
1165
+ return Attrs().FeatureListDenseTypes(x);
1166
+ }
1167
+ static Attrs ContextDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
1168
+ return Attrs().ContextDenseShapes(x);
1169
+ }
1170
+ static Attrs FeatureListSparseTypes(const DataTypeSlice& x) {
1171
+ return Attrs().FeatureListSparseTypes(x);
1172
+ }
1173
+ static Attrs FeatureListDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
1174
+ return Attrs().FeatureListDenseShapes(x);
1175
+ }
1176
+
1177
+ Operation operation;
1178
+ ::tensorflow::OutputList context_sparse_indices;
1179
+ ::tensorflow::OutputList context_sparse_values;
1180
+ ::tensorflow::OutputList context_sparse_shapes;
1181
+ ::tensorflow::OutputList context_dense_values;
1182
+ ::tensorflow::OutputList feature_list_sparse_indices;
1183
+ ::tensorflow::OutputList feature_list_sparse_values;
1184
+ ::tensorflow::OutputList feature_list_sparse_shapes;
1185
+ ::tensorflow::OutputList feature_list_dense_values;
1186
+ };
1187
+
1188
+ /// Transforms a serialized tensorflow.TensorProto proto into a Tensor.
1189
+ ///
1190
+ /// Args:
1191
+ /// * scope: A Scope object
1192
+ /// * serialized: A scalar string containing a serialized TensorProto proto.
1193
+ /// * out_type: The type of the serialized tensor. The provided type must match the
1194
+ /// type of the serialized tensor and no implicit conversion will take place.
1195
+ ///
1196
+ /// Returns:
1197
+ /// * `Output`: A Tensor of type `out_type`.
1198
+ class ParseTensor {
1199
+ public:
1200
+ ParseTensor(const ::tensorflow::Scope& scope, ::tensorflow::Input serialized,
1201
+ DataType out_type);
1202
+ operator ::tensorflow::Output() const { return output; }
1203
+ operator ::tensorflow::Input() const { return output; }
1204
+ ::tensorflow::Node* node() const { return output.node(); }
1205
+
1206
+ Operation operation;
1207
+ ::tensorflow::Output output;
1208
+ };
1209
+
1210
+ /// Transforms a Tensor into a serialized TensorProto proto.
1211
+ ///
1212
+ /// Args:
1213
+ /// * scope: A Scope object
1214
+ /// * tensor: A Tensor of type `T`.
1215
+ ///
1216
+ /// Returns:
1217
+ /// * `Output`: A serialized TensorProto proto of the input tensor.
1218
+ class SerializeTensor {
1219
+ public:
1220
+ SerializeTensor(const ::tensorflow::Scope& scope, ::tensorflow::Input tensor);
1221
+ operator ::tensorflow::Output() const { return serialized; }
1222
+ operator ::tensorflow::Input() const { return serialized; }
1223
+ ::tensorflow::Node* node() const { return serialized.node(); }
1224
+
1225
+ Operation operation;
1226
+ ::tensorflow::Output serialized;
1227
+ };
1228
+
1229
+ /// Converts each string in the input Tensor to the specified numeric type.
1230
+ ///
1231
+ /// (Note that int32 overflow results in an error while float overflow
1232
+ /// results in a rounded value.)
1233
+ ///
1234
+ /// Example:
1235
+ ///
1236
+ /// >>> strings = ["5.0", "3.0", "7.0"]
1237
+ /// >>> tf.strings.to_number(strings)
1238
+ /// <tf.Tensor: shape=(3,), dtype=float32, numpy=array([5., 3., 7.], dtype=float32)>
1239
+ ///
1240
+ ///
1241
+ /// Args:
1242
+ /// * scope: A Scope object
1243
+ ///
1244
+ /// Optional attributes (see `Attrs`):
1245
+ /// * out_type: The numeric type to interpret each string in `string_tensor` as.
1246
+ ///
1247
+ /// Returns:
1248
+ /// * `Output`: A Tensor of the same shape as the input `string_tensor`.
1249
+ class StringToNumber {
1250
+ public:
1251
+ /// Optional attribute setters for StringToNumber
1252
+ struct Attrs {
1253
+ /// The numeric type to interpret each string in `string_tensor` as.
1254
+ ///
1255
+ /// Defaults to DT_FLOAT
1256
+ TF_MUST_USE_RESULT Attrs OutType(DataType x) {
1257
+ Attrs ret = *this;
1258
+ ret.out_type_ = x;
1259
+ return ret;
1260
+ }
1261
+
1262
+ DataType out_type_ = DT_FLOAT;
1263
+ };
1264
+ StringToNumber(const ::tensorflow::Scope& scope, ::tensorflow::Input
1265
+ string_tensor);
1266
+ StringToNumber(const ::tensorflow::Scope& scope, ::tensorflow::Input
1267
+ string_tensor, const StringToNumber::Attrs& attrs);
1268
+ operator ::tensorflow::Output() const { return output; }
1269
+ operator ::tensorflow::Input() const { return output; }
1270
+ ::tensorflow::Node* node() const { return output.node(); }
1271
+
1272
+ static Attrs OutType(DataType x) {
1273
+ return Attrs().OutType(x);
1274
+ }
1275
+
1276
+ Operation operation;
1277
+ ::tensorflow::Output output;
1278
+ };
1279
+
1280
+ /// @}
1281
+
1282
+ } // namespace ops
1283
+ } // namespace tensorflow
1284
+
1285
+ #endif // TENSORFLOW_CC_OPS_PARSING_OPS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/parsing_ops_internal.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_PARSING_OPS_INTERNAL_H_
4
+ #define TENSORFLOW_CC_OPS_PARSING_OPS_INTERNAL_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
+ namespace internal {
18
+ // NOTE: This namespace has internal TensorFlow details that
19
+ // are not part of TensorFlow's public API.
20
+
21
+ /// @defgroup parsing_ops_internal Parsing Ops Internal
22
+ /// @{
23
+
24
+ } // namespace internal
25
+ } // namespace ops
26
+ } // namespace tensorflow
27
+
28
+ #endif // TENSORFLOW_CC_OPS_PARSING_OPS_INTERNAL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/random_ops.h ADDED
@@ -0,0 +1,663 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_RANDOM_OPS_H_
4
+ #define TENSORFLOW_CC_OPS_RANDOM_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 random_ops Random Ops
19
+ /// @{
20
+
21
+ /// Draws samples from a multinomial distribution.
22
+ ///
23
+ /// Args:
24
+ /// * scope: A Scope object
25
+ /// * logits: 2-D Tensor with shape `[batch_size, num_classes]`. Each slice `[i, :]`
26
+ /// represents the unnormalized log probabilities for all classes.
27
+ /// * num_samples: 0-D. Number of independent samples to draw for each row slice.
28
+ ///
29
+ /// Optional attributes (see `Attrs`):
30
+ /// * seed: If either seed or seed2 is set to be non-zero, the internal random number
31
+ /// generator is seeded by the given seed. Otherwise, a random seed is used.
32
+ /// * seed2: A second seed to avoid seed collision.
33
+ ///
34
+ /// Returns:
35
+ /// * `Output`: 2-D Tensor with shape `[batch_size, num_samples]`. Each slice `[i, :]`
36
+ /// contains the drawn class labels with range `[0, num_classes)`.
37
+ class Multinomial {
38
+ public:
39
+ /// Optional attribute setters for Multinomial
40
+ struct Attrs {
41
+ /// If either seed or seed2 is set to be non-zero, the internal random number
42
+ /// generator is seeded by the given seed. Otherwise, a random seed is used.
43
+ ///
44
+ /// Defaults to 0
45
+ TF_MUST_USE_RESULT Attrs Seed(int64 x) {
46
+ Attrs ret = *this;
47
+ ret.seed_ = x;
48
+ return ret;
49
+ }
50
+
51
+ /// A second seed to avoid seed collision.
52
+ ///
53
+ /// Defaults to 0
54
+ TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
55
+ Attrs ret = *this;
56
+ ret.seed2_ = x;
57
+ return ret;
58
+ }
59
+
60
+ /// Defaults to DT_INT64
61
+ TF_MUST_USE_RESULT Attrs OutputDtype(DataType x) {
62
+ Attrs ret = *this;
63
+ ret.output_dtype_ = x;
64
+ return ret;
65
+ }
66
+
67
+ int64 seed_ = 0;
68
+ int64 seed2_ = 0;
69
+ DataType output_dtype_ = DT_INT64;
70
+ };
71
+ Multinomial(const ::tensorflow::Scope& scope, ::tensorflow::Input logits,
72
+ ::tensorflow::Input num_samples);
73
+ Multinomial(const ::tensorflow::Scope& scope, ::tensorflow::Input logits,
74
+ ::tensorflow::Input num_samples, const Multinomial::Attrs& attrs);
75
+ operator ::tensorflow::Output() const { return output; }
76
+ operator ::tensorflow::Input() const { return output; }
77
+ ::tensorflow::Node* node() const { return output.node(); }
78
+
79
+ static Attrs Seed(int64 x) {
80
+ return Attrs().Seed(x);
81
+ }
82
+ static Attrs Seed2(int64 x) {
83
+ return Attrs().Seed2(x);
84
+ }
85
+ static Attrs OutputDtype(DataType x) {
86
+ return Attrs().OutputDtype(x);
87
+ }
88
+
89
+ Operation operation;
90
+ ::tensorflow::Output output;
91
+ };
92
+
93
+ /// Outputs random values from a normal distribution. The parameters may each be a
94
+ ///
95
+ /// scalar which applies to the entire output, or a vector of length shape[0] which
96
+ /// stores the parameters for each batch.
97
+ ///
98
+ /// Args:
99
+ /// * scope: A Scope object
100
+ /// * shape: The shape of the output tensor. Batches are indexed by the 0th dimension.
101
+ /// * means: The mean parameter of each batch.
102
+ /// * stdevs: The standard deviation parameter of each batch. Must be greater than 0.
103
+ /// * minvals: The minimum cutoff. May be -infinity.
104
+ /// * maxvals: The maximum cutoff. May be +infinity, and must be more than the minval
105
+ /// for each batch.
106
+ ///
107
+ /// Optional attributes (see `Attrs`):
108
+ /// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
109
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
110
+ /// random seed.
111
+ /// * seed2: A second seed to avoid seed collision.
112
+ ///
113
+ /// Returns:
114
+ /// * `Output`: A matrix of shape num_batches x samples_per_batch, filled with random
115
+ /// truncated normal values using the parameters for each row.
116
+ class ParameterizedTruncatedNormal {
117
+ public:
118
+ /// Optional attribute setters for ParameterizedTruncatedNormal
119
+ struct Attrs {
120
+ /// If either `seed` or `seed2` are set to be non-zero, the random number
121
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
122
+ /// random seed.
123
+ ///
124
+ /// Defaults to 0
125
+ TF_MUST_USE_RESULT Attrs Seed(int64 x) {
126
+ Attrs ret = *this;
127
+ ret.seed_ = x;
128
+ return ret;
129
+ }
130
+
131
+ /// A second seed to avoid seed collision.
132
+ ///
133
+ /// Defaults to 0
134
+ TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
135
+ Attrs ret = *this;
136
+ ret.seed2_ = x;
137
+ return ret;
138
+ }
139
+
140
+ int64 seed_ = 0;
141
+ int64 seed2_ = 0;
142
+ };
143
+ ParameterizedTruncatedNormal(const ::tensorflow::Scope& scope,
144
+ ::tensorflow::Input shape, ::tensorflow::Input
145
+ means, ::tensorflow::Input stdevs,
146
+ ::tensorflow::Input minvals, ::tensorflow::Input
147
+ maxvals);
148
+ ParameterizedTruncatedNormal(const ::tensorflow::Scope& scope,
149
+ ::tensorflow::Input shape, ::tensorflow::Input
150
+ means, ::tensorflow::Input stdevs,
151
+ ::tensorflow::Input minvals, ::tensorflow::Input
152
+ maxvals, const
153
+ ParameterizedTruncatedNormal::Attrs& attrs);
154
+ operator ::tensorflow::Output() const { return output; }
155
+ operator ::tensorflow::Input() const { return output; }
156
+ ::tensorflow::Node* node() const { return output.node(); }
157
+
158
+ static Attrs Seed(int64 x) {
159
+ return Attrs().Seed(x);
160
+ }
161
+ static Attrs Seed2(int64 x) {
162
+ return Attrs().Seed2(x);
163
+ }
164
+
165
+ Operation operation;
166
+ ::tensorflow::Output output;
167
+ };
168
+
169
+ /// Outputs random values from the Gamma distribution(s) described by alpha.
170
+ ///
171
+ /// This op uses the algorithm by Marsaglia et al. to acquire samples via
172
+ /// transformation-rejection from pairs of uniform and normal random variables.
173
+ /// See http://dl.acm.org/citation.cfm?id=358414
174
+ ///
175
+ /// Args:
176
+ /// * scope: A Scope object
177
+ /// * shape: 1-D integer tensor. Shape of independent samples to draw from each
178
+ /// distribution described by the shape parameters given in alpha.
179
+ /// * alpha: A tensor in which each scalar is a "shape" parameter describing the
180
+ /// associated gamma distribution.
181
+ ///
182
+ /// Optional attributes (see `Attrs`):
183
+ /// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
184
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
185
+ /// random seed.
186
+ /// * seed2: A second seed to avoid seed collision.
187
+ ///
188
+ /// Returns:
189
+ /// * `Output`: A tensor with shape `shape + shape(alpha)`. Each slice
190
+ /// `[:, ..., :, i0, i1, ...iN]` contains the samples drawn for
191
+ /// `alpha[i0, i1, ...iN]`. The dtype of the output matches the dtype of alpha.
192
+ class RandomGamma {
193
+ public:
194
+ /// Optional attribute setters for RandomGamma
195
+ struct Attrs {
196
+ /// If either `seed` or `seed2` are set to be non-zero, the random number
197
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
198
+ /// random seed.
199
+ ///
200
+ /// Defaults to 0
201
+ TF_MUST_USE_RESULT Attrs Seed(int64 x) {
202
+ Attrs ret = *this;
203
+ ret.seed_ = x;
204
+ return ret;
205
+ }
206
+
207
+ /// A second seed to avoid seed collision.
208
+ ///
209
+ /// Defaults to 0
210
+ TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
211
+ Attrs ret = *this;
212
+ ret.seed2_ = x;
213
+ return ret;
214
+ }
215
+
216
+ int64 seed_ = 0;
217
+ int64 seed2_ = 0;
218
+ };
219
+ RandomGamma(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
220
+ ::tensorflow::Input alpha);
221
+ RandomGamma(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
222
+ ::tensorflow::Input alpha, const RandomGamma::Attrs& attrs);
223
+ operator ::tensorflow::Output() const { return output; }
224
+ operator ::tensorflow::Input() const { return output; }
225
+ ::tensorflow::Node* node() const { return output.node(); }
226
+
227
+ static Attrs Seed(int64 x) {
228
+ return Attrs().Seed(x);
229
+ }
230
+ static Attrs Seed2(int64 x) {
231
+ return Attrs().Seed2(x);
232
+ }
233
+
234
+ Operation operation;
235
+ ::tensorflow::Output output;
236
+ };
237
+
238
+ /// Outputs random values from the Poisson distribution(s) described by rate.
239
+ ///
240
+ /// This op uses two algorithms, depending on rate. If rate >= 10, then
241
+ /// the algorithm by Hormann is used to acquire samples via
242
+ /// transformation-rejection.
243
+ /// See http://www.sciencedirect.com/science/article/pii/0167668793909974.
244
+ ///
245
+ /// Otherwise, Knuth's algorithm is used to acquire samples via multiplying uniform
246
+ /// random variables.
247
+ /// See Donald E. Knuth (1969). Seminumerical Algorithms. The Art of Computer
248
+ /// Programming, Volume 2. Addison Wesley
249
+ ///
250
+ /// Args:
251
+ /// * scope: A Scope object
252
+ /// * shape: 1-D integer tensor. Shape of independent samples to draw from each
253
+ /// distribution described by the shape parameters given in rate.
254
+ /// * rate: A tensor in which each scalar is a "rate" parameter describing the
255
+ /// associated poisson distribution.
256
+ ///
257
+ /// Optional attributes (see `Attrs`):
258
+ /// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
259
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
260
+ /// random seed.
261
+ /// * seed2: A second seed to avoid seed collision.
262
+ ///
263
+ /// Returns:
264
+ /// * `Output`: A tensor with shape `shape + shape(rate)`. Each slice
265
+ /// `[:, ..., :, i0, i1, ...iN]` contains the samples drawn for
266
+ /// `rate[i0, i1, ...iN]`.
267
+ class RandomPoissonV2 {
268
+ public:
269
+ /// Optional attribute setters for RandomPoissonV2
270
+ struct Attrs {
271
+ /// If either `seed` or `seed2` are set to be non-zero, the random number
272
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
273
+ /// random seed.
274
+ ///
275
+ /// Defaults to 0
276
+ TF_MUST_USE_RESULT Attrs Seed(int64 x) {
277
+ Attrs ret = *this;
278
+ ret.seed_ = x;
279
+ return ret;
280
+ }
281
+
282
+ /// A second seed to avoid seed collision.
283
+ ///
284
+ /// Defaults to 0
285
+ TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
286
+ Attrs ret = *this;
287
+ ret.seed2_ = x;
288
+ return ret;
289
+ }
290
+
291
+ /// Defaults to DT_INT64
292
+ TF_MUST_USE_RESULT Attrs Dtype(DataType x) {
293
+ Attrs ret = *this;
294
+ ret.dtype_ = x;
295
+ return ret;
296
+ }
297
+
298
+ int64 seed_ = 0;
299
+ int64 seed2_ = 0;
300
+ DataType dtype_ = DT_INT64;
301
+ };
302
+ RandomPoissonV2(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
303
+ ::tensorflow::Input rate);
304
+ RandomPoissonV2(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
305
+ ::tensorflow::Input rate, const RandomPoissonV2::Attrs& attrs);
306
+ operator ::tensorflow::Output() const { return output; }
307
+ operator ::tensorflow::Input() const { return output; }
308
+ ::tensorflow::Node* node() const { return output.node(); }
309
+
310
+ static Attrs Seed(int64 x) {
311
+ return Attrs().Seed(x);
312
+ }
313
+ static Attrs Seed2(int64 x) {
314
+ return Attrs().Seed2(x);
315
+ }
316
+ static Attrs Dtype(DataType x) {
317
+ return Attrs().Dtype(x);
318
+ }
319
+
320
+ Operation operation;
321
+ ::tensorflow::Output output;
322
+ };
323
+
324
+ /// Randomly shuffles a tensor along its first dimension.
325
+ ///
326
+ /// The tensor is shuffled along dimension 0, such that each `value[j]` is mapped
327
+ /// to one and only one `output[i]`. For example, a mapping that might occur for a
328
+ /// 3x2 tensor is:
329
+ ///
330
+ /// ```
331
+ /// [[1, 2], [[5, 6],
332
+ /// [3, 4], ==> [1, 2],
333
+ /// [5, 6]] [3, 4]]
334
+ /// ```
335
+ ///
336
+ /// Args:
337
+ /// * scope: A Scope object
338
+ /// * value: The tensor to be shuffled.
339
+ ///
340
+ /// Optional attributes (see `Attrs`):
341
+ /// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
342
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
343
+ /// random seed.
344
+ /// * seed2: A second seed to avoid seed collision.
345
+ ///
346
+ /// Returns:
347
+ /// * `Output`: A tensor of same shape and type as `value`, shuffled along its first
348
+ /// dimension.
349
+ class RandomShuffle {
350
+ public:
351
+ /// Optional attribute setters for RandomShuffle
352
+ struct Attrs {
353
+ /// If either `seed` or `seed2` are set to be non-zero, the random number
354
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
355
+ /// random seed.
356
+ ///
357
+ /// Defaults to 0
358
+ TF_MUST_USE_RESULT Attrs Seed(int64 x) {
359
+ Attrs ret = *this;
360
+ ret.seed_ = x;
361
+ return ret;
362
+ }
363
+
364
+ /// A second seed to avoid seed collision.
365
+ ///
366
+ /// Defaults to 0
367
+ TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
368
+ Attrs ret = *this;
369
+ ret.seed2_ = x;
370
+ return ret;
371
+ }
372
+
373
+ int64 seed_ = 0;
374
+ int64 seed2_ = 0;
375
+ };
376
+ RandomShuffle(const ::tensorflow::Scope& scope, ::tensorflow::Input value);
377
+ RandomShuffle(const ::tensorflow::Scope& scope, ::tensorflow::Input value,
378
+ const RandomShuffle::Attrs& attrs);
379
+ operator ::tensorflow::Output() const { return output; }
380
+ operator ::tensorflow::Input() const { return output; }
381
+ ::tensorflow::Node* node() const { return output.node(); }
382
+
383
+ static Attrs Seed(int64 x) {
384
+ return Attrs().Seed(x);
385
+ }
386
+ static Attrs Seed2(int64 x) {
387
+ return Attrs().Seed2(x);
388
+ }
389
+
390
+ Operation operation;
391
+ ::tensorflow::Output output;
392
+ };
393
+
394
+ /// Outputs random values from a normal distribution.
395
+ ///
396
+ /// The generated values will have mean 0 and standard deviation 1.
397
+ ///
398
+ /// Args:
399
+ /// * scope: A Scope object
400
+ /// * shape: The shape of the output tensor.
401
+ /// * dtype: The type of the output.
402
+ ///
403
+ /// Optional attributes (see `Attrs`):
404
+ /// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
405
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
406
+ /// random seed.
407
+ /// * seed2: A second seed to avoid seed collision.
408
+ ///
409
+ /// Returns:
410
+ /// * `Output`: A tensor of the specified shape filled with random normal values.
411
+ class RandomNormal {
412
+ public:
413
+ /// Optional attribute setters for RandomNormal
414
+ struct Attrs {
415
+ /// If either `seed` or `seed2` are set to be non-zero, the random number
416
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
417
+ /// random seed.
418
+ ///
419
+ /// Defaults to 0
420
+ TF_MUST_USE_RESULT Attrs Seed(int64 x) {
421
+ Attrs ret = *this;
422
+ ret.seed_ = x;
423
+ return ret;
424
+ }
425
+
426
+ /// A second seed to avoid seed collision.
427
+ ///
428
+ /// Defaults to 0
429
+ TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
430
+ Attrs ret = *this;
431
+ ret.seed2_ = x;
432
+ return ret;
433
+ }
434
+
435
+ int64 seed_ = 0;
436
+ int64 seed2_ = 0;
437
+ };
438
+ RandomNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
439
+ DataType dtype);
440
+ RandomNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
441
+ DataType dtype, const RandomNormal::Attrs& attrs);
442
+ operator ::tensorflow::Output() const { return output; }
443
+ operator ::tensorflow::Input() const { return output; }
444
+ ::tensorflow::Node* node() const { return output.node(); }
445
+
446
+ static Attrs Seed(int64 x) {
447
+ return Attrs().Seed(x);
448
+ }
449
+ static Attrs Seed2(int64 x) {
450
+ return Attrs().Seed2(x);
451
+ }
452
+
453
+ Operation operation;
454
+ ::tensorflow::Output output;
455
+ };
456
+
457
+ /// Outputs random values from a uniform distribution.
458
+ ///
459
+ /// The generated values follow a uniform distribution in the range `[0, 1)`. The
460
+ /// lower bound 0 is included in the range, while the upper bound 1 is excluded.
461
+ ///
462
+ /// Args:
463
+ /// * scope: A Scope object
464
+ /// * shape: The shape of the output tensor.
465
+ /// * dtype: The type of the output.
466
+ ///
467
+ /// Optional attributes (see `Attrs`):
468
+ /// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
469
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
470
+ /// random seed.
471
+ /// * seed2: A second seed to avoid seed collision.
472
+ ///
473
+ /// Returns:
474
+ /// * `Output`: A tensor of the specified shape filled with uniform random values.
475
+ class RandomUniform {
476
+ public:
477
+ /// Optional attribute setters for RandomUniform
478
+ struct Attrs {
479
+ /// If either `seed` or `seed2` are set to be non-zero, the random number
480
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
481
+ /// random seed.
482
+ ///
483
+ /// Defaults to 0
484
+ TF_MUST_USE_RESULT Attrs Seed(int64 x) {
485
+ Attrs ret = *this;
486
+ ret.seed_ = x;
487
+ return ret;
488
+ }
489
+
490
+ /// A second seed to avoid seed collision.
491
+ ///
492
+ /// Defaults to 0
493
+ TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
494
+ Attrs ret = *this;
495
+ ret.seed2_ = x;
496
+ return ret;
497
+ }
498
+
499
+ int64 seed_ = 0;
500
+ int64 seed2_ = 0;
501
+ };
502
+ RandomUniform(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
503
+ DataType dtype);
504
+ RandomUniform(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
505
+ DataType dtype, const RandomUniform::Attrs& attrs);
506
+ operator ::tensorflow::Output() const { return output; }
507
+ operator ::tensorflow::Input() const { return output; }
508
+ ::tensorflow::Node* node() const { return output.node(); }
509
+
510
+ static Attrs Seed(int64 x) {
511
+ return Attrs().Seed(x);
512
+ }
513
+ static Attrs Seed2(int64 x) {
514
+ return Attrs().Seed2(x);
515
+ }
516
+
517
+ Operation operation;
518
+ ::tensorflow::Output output;
519
+ };
520
+
521
+ /// Outputs random integers from a uniform distribution.
522
+ ///
523
+ /// The generated values are uniform integers in the range `[minval, maxval)`.
524
+ /// The lower bound `minval` is included in the range, while the upper bound
525
+ /// `maxval` is excluded.
526
+ ///
527
+ /// The random integers are slightly biased unless `maxval - minval` is an exact
528
+ /// power of two. The bias is small for values of `maxval - minval` significantly
529
+ /// smaller than the range of the output (either `2^32` or `2^64`).
530
+ ///
531
+ /// Args:
532
+ /// * scope: A Scope object
533
+ /// * shape: The shape of the output tensor.
534
+ /// * minval: 0-D. Inclusive lower bound on the generated integers.
535
+ /// * maxval: 0-D. Exclusive upper bound on the generated integers.
536
+ ///
537
+ /// Optional attributes (see `Attrs`):
538
+ /// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
539
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
540
+ /// random seed.
541
+ /// * seed2: A second seed to avoid seed collision.
542
+ ///
543
+ /// Returns:
544
+ /// * `Output`: A tensor of the specified shape filled with uniform random integers.
545
+ class RandomUniformInt {
546
+ public:
547
+ /// Optional attribute setters for RandomUniformInt
548
+ struct Attrs {
549
+ /// If either `seed` or `seed2` are set to be non-zero, the random number
550
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
551
+ /// random seed.
552
+ ///
553
+ /// Defaults to 0
554
+ TF_MUST_USE_RESULT Attrs Seed(int64 x) {
555
+ Attrs ret = *this;
556
+ ret.seed_ = x;
557
+ return ret;
558
+ }
559
+
560
+ /// A second seed to avoid seed collision.
561
+ ///
562
+ /// Defaults to 0
563
+ TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
564
+ Attrs ret = *this;
565
+ ret.seed2_ = x;
566
+ return ret;
567
+ }
568
+
569
+ int64 seed_ = 0;
570
+ int64 seed2_ = 0;
571
+ };
572
+ RandomUniformInt(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
573
+ ::tensorflow::Input minval, ::tensorflow::Input maxval);
574
+ RandomUniformInt(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
575
+ ::tensorflow::Input minval, ::tensorflow::Input maxval, const
576
+ RandomUniformInt::Attrs& attrs);
577
+ operator ::tensorflow::Output() const { return output; }
578
+ operator ::tensorflow::Input() const { return output; }
579
+ ::tensorflow::Node* node() const { return output.node(); }
580
+
581
+ static Attrs Seed(int64 x) {
582
+ return Attrs().Seed(x);
583
+ }
584
+ static Attrs Seed2(int64 x) {
585
+ return Attrs().Seed2(x);
586
+ }
587
+
588
+ Operation operation;
589
+ ::tensorflow::Output output;
590
+ };
591
+
592
+ /// Outputs random values from a truncated normal distribution.
593
+ ///
594
+ /// The generated values follow a normal distribution with mean 0 and standard
595
+ /// deviation 1, except that values whose magnitude is more than 2 standard
596
+ /// deviations from the mean are dropped and re-picked.
597
+ ///
598
+ /// Args:
599
+ /// * scope: A Scope object
600
+ /// * shape: The shape of the output tensor.
601
+ /// * dtype: The type of the output.
602
+ ///
603
+ /// Optional attributes (see `Attrs`):
604
+ /// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
605
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
606
+ /// random seed.
607
+ /// * seed2: A second seed to avoid seed collision.
608
+ ///
609
+ /// Returns:
610
+ /// * `Output`: A tensor of the specified shape filled with random truncated normal
611
+ /// values.
612
+ class TruncatedNormal {
613
+ public:
614
+ /// Optional attribute setters for TruncatedNormal
615
+ struct Attrs {
616
+ /// If either `seed` or `seed2` are set to be non-zero, the random number
617
+ /// generator is seeded by the given seed. Otherwise, it is seeded by a
618
+ /// random seed.
619
+ ///
620
+ /// Defaults to 0
621
+ TF_MUST_USE_RESULT Attrs Seed(int64 x) {
622
+ Attrs ret = *this;
623
+ ret.seed_ = x;
624
+ return ret;
625
+ }
626
+
627
+ /// A second seed to avoid seed collision.
628
+ ///
629
+ /// Defaults to 0
630
+ TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
631
+ Attrs ret = *this;
632
+ ret.seed2_ = x;
633
+ return ret;
634
+ }
635
+
636
+ int64 seed_ = 0;
637
+ int64 seed2_ = 0;
638
+ };
639
+ TruncatedNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
640
+ DataType dtype);
641
+ TruncatedNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
642
+ DataType dtype, const TruncatedNormal::Attrs& attrs);
643
+ operator ::tensorflow::Output() const { return output; }
644
+ operator ::tensorflow::Input() const { return output; }
645
+ ::tensorflow::Node* node() const { return output.node(); }
646
+
647
+ static Attrs Seed(int64 x) {
648
+ return Attrs().Seed(x);
649
+ }
650
+ static Attrs Seed2(int64 x) {
651
+ return Attrs().Seed2(x);
652
+ }
653
+
654
+ Operation operation;
655
+ ::tensorflow::Output output;
656
+ };
657
+
658
+ /// @}
659
+
660
+ } // namespace ops
661
+ } // namespace tensorflow
662
+
663
+ #endif // TENSORFLOW_CC_OPS_RANDOM_OPS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/random_ops_internal.h ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_RANDOM_OPS_INTERNAL_H_
4
+ #define TENSORFLOW_CC_OPS_RANDOM_OPS_INTERNAL_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
+ namespace internal {
18
+ // NOTE: This namespace has internal TensorFlow details that
19
+ // are not part of TensorFlow's public API.
20
+
21
+ /// @defgroup random_ops_internal Random Ops Internal
22
+ /// @{
23
+
24
+ /// Computes the derivative of a Gamma random sample w.r.t. `alpha`.
25
+ ///
26
+ /// Args:
27
+ /// * scope: A Scope object
28
+ ///
29
+ /// Returns:
30
+ /// * `Output`: The output tensor.
31
+ class RandomGammaGrad {
32
+ public:
33
+ RandomGammaGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input alpha,
34
+ ::tensorflow::Input sample);
35
+ operator ::tensorflow::Output() const { return output; }
36
+ operator ::tensorflow::Input() const { return output; }
37
+ ::tensorflow::Node* node() const { return output.node(); }
38
+
39
+ Operation operation;
40
+ ::tensorflow::Output output;
41
+ };
42
+
43
+ } // namespace internal
44
+ } // namespace ops
45
+ } // namespace tensorflow
46
+
47
+ #endif // TENSORFLOW_CC_OPS_RANDOM_OPS_INTERNAL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/resource_variable_ops.h ADDED
@@ -0,0 +1,587 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_RESOURCE_VARIABLE_OPS_H_
4
+ #define TENSORFLOW_CC_OPS_RESOURCE_VARIABLE_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 resource_variable_ops Resource Variable Ops
19
+ /// @{
20
+
21
+ /// TODO: add doc.
22
+ ///
23
+ /// Args:
24
+ /// * scope: A Scope object
25
+ ///
26
+ /// Returns:
27
+ /// * the created `Operation`
28
+ class AssignAddVariableOp {
29
+ public:
30
+ AssignAddVariableOp(const ::tensorflow::Scope& scope, ::tensorflow::Input
31
+ resource, ::tensorflow::Input value);
32
+ operator ::tensorflow::Operation() const { return operation; }
33
+
34
+ Operation operation;
35
+ };
36
+
37
+ /// TODO: add doc.
38
+ ///
39
+ /// Args:
40
+ /// * scope: A Scope object
41
+ ///
42
+ /// Returns:
43
+ /// * the created `Operation`
44
+ class AssignSubVariableOp {
45
+ public:
46
+ AssignSubVariableOp(const ::tensorflow::Scope& scope, ::tensorflow::Input
47
+ resource, ::tensorflow::Input value);
48
+ operator ::tensorflow::Operation() const { return operation; }
49
+
50
+ Operation operation;
51
+ };
52
+
53
+ /// TODO: add doc.
54
+ ///
55
+ /// Args:
56
+ /// * scope: A Scope object
57
+ ///
58
+ /// Returns:
59
+ /// * the created `Operation`
60
+ class AssignVariableOp {
61
+ public:
62
+ /// Optional attribute setters for AssignVariableOp
63
+ struct Attrs {
64
+ /// Defaults to false
65
+ TF_MUST_USE_RESULT Attrs ValidateShape(bool x) {
66
+ Attrs ret = *this;
67
+ ret.validate_shape_ = x;
68
+ return ret;
69
+ }
70
+
71
+ bool validate_shape_ = false;
72
+ };
73
+ AssignVariableOp(const ::tensorflow::Scope& scope, ::tensorflow::Input
74
+ resource, ::tensorflow::Input value);
75
+ AssignVariableOp(const ::tensorflow::Scope& scope, ::tensorflow::Input
76
+ resource, ::tensorflow::Input value, const
77
+ AssignVariableOp::Attrs& attrs);
78
+ operator ::tensorflow::Operation() const { return operation; }
79
+
80
+ static Attrs ValidateShape(bool x) {
81
+ return Attrs().ValidateShape(x);
82
+ }
83
+
84
+ Operation operation;
85
+ };
86
+
87
+ /// TODO: add doc.
88
+ ///
89
+ /// Args:
90
+ /// * scope: A Scope object
91
+ ///
92
+ /// Returns:
93
+ /// * the created `Operation`
94
+ class ConsumeMutexLock {
95
+ public:
96
+ ConsumeMutexLock(const ::tensorflow::Scope& scope, ::tensorflow::Input
97
+ mutex_lock);
98
+ operator ::tensorflow::Operation() const { return operation; }
99
+
100
+ Operation operation;
101
+ };
102
+
103
+ /// TODO: add doc.
104
+ ///
105
+ /// Args:
106
+ /// * scope: A Scope object
107
+ ///
108
+ /// Returns:
109
+ /// * the created `Operation`
110
+ class DestroyResourceOp {
111
+ public:
112
+ /// Optional attribute setters for DestroyResourceOp
113
+ struct Attrs {
114
+ /// Defaults to true
115
+ TF_MUST_USE_RESULT Attrs IgnoreLookupError(bool x) {
116
+ Attrs ret = *this;
117
+ ret.ignore_lookup_error_ = x;
118
+ return ret;
119
+ }
120
+
121
+ bool ignore_lookup_error_ = true;
122
+ };
123
+ DestroyResourceOp(const ::tensorflow::Scope& scope, ::tensorflow::Input
124
+ resource);
125
+ DestroyResourceOp(const ::tensorflow::Scope& scope, ::tensorflow::Input
126
+ resource, const DestroyResourceOp::Attrs& attrs);
127
+ operator ::tensorflow::Operation() const { return operation; }
128
+
129
+ static Attrs IgnoreLookupError(bool x) {
130
+ return Attrs().IgnoreLookupError(x);
131
+ }
132
+
133
+ Operation operation;
134
+ };
135
+
136
+ /// TODO: add doc.
137
+ ///
138
+ /// Args:
139
+ /// * scope: A Scope object
140
+ ///
141
+ /// Returns:
142
+ /// * the created `Operation`
143
+ class DisableCopyOnRead {
144
+ public:
145
+ DisableCopyOnRead(const ::tensorflow::Scope& scope, ::tensorflow::Input
146
+ resource);
147
+ operator ::tensorflow::Operation() const { return operation; }
148
+
149
+ Operation operation;
150
+ };
151
+
152
+ /// TODO: add doc.
153
+ ///
154
+ /// Args:
155
+ /// * scope: A Scope object
156
+ ///
157
+ /// Returns:
158
+ /// * `Output`: The mutex_lock tensor.
159
+ class MutexLock {
160
+ public:
161
+ MutexLock(const ::tensorflow::Scope& scope, ::tensorflow::Input mutex);
162
+ operator ::tensorflow::Output() const { return mutex_lock; }
163
+ operator ::tensorflow::Input() const { return mutex_lock; }
164
+ ::tensorflow::Node* node() const { return mutex_lock.node(); }
165
+
166
+ Operation operation;
167
+ ::tensorflow::Output mutex_lock;
168
+ };
169
+
170
+ /// TODO: add doc.
171
+ ///
172
+ /// Args:
173
+ /// * scope: A Scope object
174
+ ///
175
+ /// Returns:
176
+ /// * `Output`: The resource tensor.
177
+ class MutexV2 {
178
+ public:
179
+ /// Optional attribute setters for MutexV2
180
+ struct Attrs {
181
+ /// Defaults to ""
182
+ TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
183
+ Attrs ret = *this;
184
+ ret.container_ = x;
185
+ return ret;
186
+ }
187
+
188
+ /// Defaults to ""
189
+ TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
190
+ Attrs ret = *this;
191
+ ret.shared_name_ = x;
192
+ return ret;
193
+ }
194
+
195
+ StringPiece container_ = "";
196
+ StringPiece shared_name_ = "";
197
+ };
198
+ MutexV2(const ::tensorflow::Scope& scope);
199
+ MutexV2(const ::tensorflow::Scope& scope, const MutexV2::Attrs& attrs);
200
+ operator ::tensorflow::Output() const { return resource; }
201
+ operator ::tensorflow::Input() const { return resource; }
202
+ ::tensorflow::Node* node() const { return resource.node(); }
203
+
204
+ static Attrs Container(StringPiece x) {
205
+ return Attrs().Container(x);
206
+ }
207
+ static Attrs SharedName(StringPiece x) {
208
+ return Attrs().SharedName(x);
209
+ }
210
+
211
+ Operation operation;
212
+ ::tensorflow::Output resource;
213
+ };
214
+
215
+ /// TODO: add doc.
216
+ ///
217
+ /// Args:
218
+ /// * scope: A Scope object
219
+ ///
220
+ /// Returns:
221
+ /// * `Output`: The value tensor.
222
+ class ReadVariableOp {
223
+ public:
224
+ ReadVariableOp(const ::tensorflow::Scope& scope, ::tensorflow::Input resource,
225
+ DataType dtype);
226
+ operator ::tensorflow::Output() const { return value; }
227
+ operator ::tensorflow::Input() const { return value; }
228
+ ::tensorflow::Node* node() const { return value.node(); }
229
+
230
+ Operation operation;
231
+ ::tensorflow::Output value;
232
+ };
233
+
234
+ /// TODO: add doc.
235
+ ///
236
+ /// Args:
237
+ /// * scope: A Scope object
238
+ ///
239
+ /// Returns:
240
+ /// * `Output`: The output tensor.
241
+ class ResourceGather {
242
+ public:
243
+ /// Optional attribute setters for ResourceGather
244
+ struct Attrs {
245
+ /// Defaults to 0
246
+ TF_MUST_USE_RESULT Attrs BatchDims(int64 x) {
247
+ Attrs ret = *this;
248
+ ret.batch_dims_ = x;
249
+ return ret;
250
+ }
251
+
252
+ /// Defaults to true
253
+ TF_MUST_USE_RESULT Attrs ValidateIndices(bool x) {
254
+ Attrs ret = *this;
255
+ ret.validate_indices_ = x;
256
+ return ret;
257
+ }
258
+
259
+ int64 batch_dims_ = 0;
260
+ bool validate_indices_ = true;
261
+ };
262
+ ResourceGather(const ::tensorflow::Scope& scope, ::tensorflow::Input resource,
263
+ ::tensorflow::Input indices, DataType dtype);
264
+ ResourceGather(const ::tensorflow::Scope& scope, ::tensorflow::Input resource,
265
+ ::tensorflow::Input indices, DataType dtype, const
266
+ ResourceGather::Attrs& attrs);
267
+ operator ::tensorflow::Output() const { return output; }
268
+ operator ::tensorflow::Input() const { return output; }
269
+ ::tensorflow::Node* node() const { return output.node(); }
270
+
271
+ static Attrs BatchDims(int64 x) {
272
+ return Attrs().BatchDims(x);
273
+ }
274
+ static Attrs ValidateIndices(bool x) {
275
+ return Attrs().ValidateIndices(x);
276
+ }
277
+
278
+ Operation operation;
279
+ ::tensorflow::Output output;
280
+ };
281
+
282
+ /// TODO: add doc.
283
+ ///
284
+ /// Args:
285
+ /// * scope: A Scope object
286
+ ///
287
+ /// Returns:
288
+ /// * `Output`: The output tensor.
289
+ class ResourceGatherNd {
290
+ public:
291
+ ResourceGatherNd(const ::tensorflow::Scope& scope, ::tensorflow::Input
292
+ resource, ::tensorflow::Input indices, DataType dtype);
293
+ operator ::tensorflow::Output() const { return output; }
294
+ operator ::tensorflow::Input() const { return output; }
295
+ ::tensorflow::Node* node() const { return output.node(); }
296
+
297
+ Operation operation;
298
+ ::tensorflow::Output output;
299
+ };
300
+
301
+ /// TODO: add doc.
302
+ ///
303
+ /// Args:
304
+ /// * scope: A Scope object
305
+ ///
306
+ /// Returns:
307
+ /// * the created `Operation`
308
+ class ResourceScatterAdd {
309
+ public:
310
+ ResourceScatterAdd(const ::tensorflow::Scope& scope, ::tensorflow::Input
311
+ resource, ::tensorflow::Input indices, ::tensorflow::Input
312
+ updates);
313
+ operator ::tensorflow::Operation() const { return operation; }
314
+
315
+ Operation operation;
316
+ };
317
+
318
+ /// TODO: add doc.
319
+ ///
320
+ /// Args:
321
+ /// * scope: A Scope object
322
+ ///
323
+ /// Returns:
324
+ /// * the created `Operation`
325
+ class ResourceScatterDiv {
326
+ public:
327
+ ResourceScatterDiv(const ::tensorflow::Scope& scope, ::tensorflow::Input
328
+ resource, ::tensorflow::Input indices, ::tensorflow::Input
329
+ updates);
330
+ operator ::tensorflow::Operation() const { return operation; }
331
+
332
+ Operation operation;
333
+ };
334
+
335
+ /// TODO: add doc.
336
+ ///
337
+ /// Args:
338
+ /// * scope: A Scope object
339
+ ///
340
+ /// Returns:
341
+ /// * the created `Operation`
342
+ class ResourceScatterMax {
343
+ public:
344
+ ResourceScatterMax(const ::tensorflow::Scope& scope, ::tensorflow::Input
345
+ resource, ::tensorflow::Input indices, ::tensorflow::Input
346
+ updates);
347
+ operator ::tensorflow::Operation() const { return operation; }
348
+
349
+ Operation operation;
350
+ };
351
+
352
+ /// TODO: add doc.
353
+ ///
354
+ /// Args:
355
+ /// * scope: A Scope object
356
+ ///
357
+ /// Returns:
358
+ /// * the created `Operation`
359
+ class ResourceScatterMin {
360
+ public:
361
+ ResourceScatterMin(const ::tensorflow::Scope& scope, ::tensorflow::Input
362
+ resource, ::tensorflow::Input indices, ::tensorflow::Input
363
+ updates);
364
+ operator ::tensorflow::Operation() const { return operation; }
365
+
366
+ Operation operation;
367
+ };
368
+
369
+ /// TODO: add doc.
370
+ ///
371
+ /// Args:
372
+ /// * scope: A Scope object
373
+ ///
374
+ /// Returns:
375
+ /// * the created `Operation`
376
+ class ResourceScatterMul {
377
+ public:
378
+ ResourceScatterMul(const ::tensorflow::Scope& scope, ::tensorflow::Input
379
+ resource, ::tensorflow::Input indices, ::tensorflow::Input
380
+ updates);
381
+ operator ::tensorflow::Operation() const { return operation; }
382
+
383
+ Operation operation;
384
+ };
385
+
386
+ /// TODO: add doc.
387
+ ///
388
+ /// Args:
389
+ /// * scope: A Scope object
390
+ ///
391
+ /// Returns:
392
+ /// * the created `Operation`
393
+ class ResourceScatterSub {
394
+ public:
395
+ ResourceScatterSub(const ::tensorflow::Scope& scope, ::tensorflow::Input
396
+ resource, ::tensorflow::Input indices, ::tensorflow::Input
397
+ updates);
398
+ operator ::tensorflow::Operation() const { return operation; }
399
+
400
+ Operation operation;
401
+ };
402
+
403
+ /// TODO: add doc.
404
+ ///
405
+ /// Args:
406
+ /// * scope: A Scope object
407
+ ///
408
+ /// Returns:
409
+ /// * the created `Operation`
410
+ class ResourceScatterUpdate {
411
+ public:
412
+ ResourceScatterUpdate(const ::tensorflow::Scope& scope, ::tensorflow::Input
413
+ resource, ::tensorflow::Input indices,
414
+ ::tensorflow::Input updates);
415
+ operator ::tensorflow::Operation() const { return operation; }
416
+
417
+ Operation operation;
418
+ };
419
+
420
+ /// TODO: add doc.
421
+ ///
422
+ /// Args:
423
+ /// * scope: A Scope object
424
+ ///
425
+ /// Returns:
426
+ /// * `Output`: The resource tensor.
427
+ class VarHandleOp {
428
+ public:
429
+ /// Optional attribute setters for VarHandleOp
430
+ struct Attrs {
431
+ /// Defaults to ""
432
+ TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
433
+ Attrs ret = *this;
434
+ ret.container_ = x;
435
+ return ret;
436
+ }
437
+
438
+ /// Defaults to ""
439
+ TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
440
+ Attrs ret = *this;
441
+ ret.shared_name_ = x;
442
+ return ret;
443
+ }
444
+
445
+ /// Defaults to ""
446
+ TF_MUST_USE_RESULT Attrs DebugName(StringPiece x) {
447
+ Attrs ret = *this;
448
+ ret.debug_name_ = x;
449
+ return ret;
450
+ }
451
+
452
+ /// Defaults to []
453
+ TF_MUST_USE_RESULT Attrs AllowedDevices(const gtl::ArraySlice<::tensorflow::tstring>& x) {
454
+ Attrs ret = *this;
455
+ ret.allowed_devices_ = x;
456
+ return ret;
457
+ }
458
+
459
+ StringPiece container_ = "";
460
+ StringPiece shared_name_ = "";
461
+ StringPiece debug_name_ = "";
462
+ gtl::ArraySlice<::tensorflow::tstring> allowed_devices_ = {};
463
+ };
464
+ VarHandleOp(const ::tensorflow::Scope& scope, DataType dtype,
465
+ PartialTensorShape shape);
466
+ VarHandleOp(const ::tensorflow::Scope& scope, DataType dtype,
467
+ PartialTensorShape shape, const VarHandleOp::Attrs& attrs);
468
+ operator ::tensorflow::Output() const { return resource; }
469
+ operator ::tensorflow::Input() const { return resource; }
470
+ ::tensorflow::Node* node() const { return resource.node(); }
471
+
472
+ static Attrs Container(StringPiece x) {
473
+ return Attrs().Container(x);
474
+ }
475
+ static Attrs SharedName(StringPiece x) {
476
+ return Attrs().SharedName(x);
477
+ }
478
+ static Attrs DebugName(StringPiece x) {
479
+ return Attrs().DebugName(x);
480
+ }
481
+ static Attrs AllowedDevices(const gtl::ArraySlice<::tensorflow::tstring>& x) {
482
+ return Attrs().AllowedDevices(x);
483
+ }
484
+
485
+ Operation operation;
486
+ ::tensorflow::Output resource;
487
+ };
488
+
489
+ /// TODO: add doc.
490
+ ///
491
+ /// Args:
492
+ /// * scope: A Scope object
493
+ ///
494
+ /// Returns:
495
+ /// * `Output`: The is_initialized tensor.
496
+ class VarIsInitializedOp {
497
+ public:
498
+ VarIsInitializedOp(const ::tensorflow::Scope& scope, ::tensorflow::Input
499
+ resource);
500
+ operator ::tensorflow::Output() const { return is_initialized; }
501
+ operator ::tensorflow::Input() const { return is_initialized; }
502
+ ::tensorflow::Node* node() const { return is_initialized.node(); }
503
+
504
+ Operation operation;
505
+ ::tensorflow::Output is_initialized;
506
+ };
507
+
508
+ /// TODO: add doc.
509
+ ///
510
+ /// Args:
511
+ /// * scope: A Scope object
512
+ ///
513
+ /// Returns:
514
+ /// * `Output`: The output tensor.
515
+ class VariableShape {
516
+ public:
517
+ /// Optional attribute setters for VariableShape
518
+ struct Attrs {
519
+ /// Defaults to DT_INT32
520
+ TF_MUST_USE_RESULT Attrs OutType(DataType x) {
521
+ Attrs ret = *this;
522
+ ret.out_type_ = x;
523
+ return ret;
524
+ }
525
+
526
+ DataType out_type_ = DT_INT32;
527
+ };
528
+ VariableShape(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
529
+ VariableShape(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
530
+ const VariableShape::Attrs& attrs);
531
+ operator ::tensorflow::Output() const { return output; }
532
+ operator ::tensorflow::Input() const { return output; }
533
+ ::tensorflow::Node* node() const { return output.node(); }
534
+
535
+ static Attrs OutType(DataType x) {
536
+ return Attrs().OutType(x);
537
+ }
538
+
539
+ Operation operation;
540
+ ::tensorflow::Output output;
541
+ };
542
+
543
+ /// TODO: add doc.
544
+ ///
545
+ /// Args:
546
+ /// * scope: A Scope object
547
+ ///
548
+ /// Returns:
549
+ /// * `OutputList`: The values tensor.
550
+ class _ReadVariablesOp {
551
+ public:
552
+ _ReadVariablesOp(const ::tensorflow::Scope& scope, ::tensorflow::InputList
553
+ resources, const DataTypeSlice& dtypes);
554
+ ::tensorflow::Output operator[](size_t index) const { return values[index]; }
555
+
556
+
557
+ Operation operation;
558
+ ::tensorflow::OutputList values;
559
+ };
560
+
561
+ /// TODO: add doc.
562
+ ///
563
+ /// Args:
564
+ /// * scope: A Scope object
565
+ ///
566
+ /// Returns:
567
+ /// * `OutputList`: The resources tensor.
568
+ class _VarHandlesOp {
569
+ public:
570
+ _VarHandlesOp(const ::tensorflow::Scope& scope, const
571
+ gtl::ArraySlice<::tensorflow::tstring>& containers, const
572
+ gtl::ArraySlice<::tensorflow::tstring>& shared_names, int64 N,
573
+ const DataTypeSlice& dtypes, const
574
+ gtl::ArraySlice<PartialTensorShape>& shapes);
575
+ ::tensorflow::Output operator[](size_t index) const { return resources[index]; }
576
+
577
+
578
+ Operation operation;
579
+ ::tensorflow::OutputList resources;
580
+ };
581
+
582
+ /// @}
583
+
584
+ } // namespace ops
585
+ } // namespace tensorflow
586
+
587
+ #endif // TENSORFLOW_CC_OPS_RESOURCE_VARIABLE_OPS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/sparse_ops.h ADDED
@@ -0,0 +1,1814 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
15
+ namespace tensorflow {
16
+ namespace 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]`.
62
+ class 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`.
141
+ class 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
243
+ class 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
308
+ class 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.
341
+ class 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.
390
+ class 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
456
+ class 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.
490
+ class 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`.
557
+ class 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`.
626
+ class 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`.
695
+ class 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`.
761
+ class 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.
795
+ class 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.
823
+ class 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.
855
+ class 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.
922
+ class 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.
954
+ class 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.
992
+ class 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
1057
+ class 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.
1120
+ class 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
1185
+ class 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`.
1242
+ class 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.
1284
+ class 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.
1329
+ class 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`.
1357
+ class 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`.
1398
+ class 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.
1427
+ class 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.
1456
+ class 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.
1505
+ class 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.
1530
+ class 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.
1570
+ class 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`.
1657
+ class 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`.
1761
+ class 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_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/sparse_ops_internal.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_SPARSE_OPS_INTERNAL_H_
4
+ #define TENSORFLOW_CC_OPS_SPARSE_OPS_INTERNAL_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
+ namespace internal {
18
+ // NOTE: This namespace has internal TensorFlow details that
19
+ // are not part of TensorFlow's public API.
20
+
21
+ /// @defgroup sparse_ops_internal Sparse Ops Internal
22
+ /// @{
23
+
24
+ } // namespace internal
25
+ } // namespace ops
26
+ } // namespace tensorflow
27
+
28
+ #endif // TENSORFLOW_CC_OPS_SPARSE_OPS_INTERNAL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/standard_ops.h ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_CC_OPS_STANDARD_OPS_H_
17
+ #define TENSORFLOW_CC_OPS_STANDARD_OPS_H_
18
+
19
+ #include "tensorflow/cc/ops/array_ops.h"
20
+ #include "tensorflow/cc/ops/candidate_sampling_ops.h"
21
+ #include "tensorflow/cc/ops/const_op.h"
22
+ #include "tensorflow/cc/ops/control_flow_ops.h"
23
+ #include "tensorflow/cc/ops/data_flow_ops.h"
24
+ #include "tensorflow/cc/ops/image_ops.h"
25
+ #include "tensorflow/cc/ops/io_ops.h"
26
+ #include "tensorflow/cc/ops/linalg_ops.h"
27
+ #include "tensorflow/cc/ops/logging_ops.h"
28
+ #include "tensorflow/cc/ops/lookup_ops.h"
29
+ #include "tensorflow/cc/ops/math_ops.h"
30
+ #include "tensorflow/cc/ops/nn_ops.h"
31
+ #include "tensorflow/cc/ops/no_op.h"
32
+ #include "tensorflow/cc/ops/parsing_ops.h"
33
+ #include "tensorflow/cc/ops/random_ops.h"
34
+ #include "tensorflow/cc/ops/sparse_ops.h"
35
+ #include "tensorflow/cc/ops/state_ops.h"
36
+ #include "tensorflow/cc/ops/string_ops.h"
37
+ #include "tensorflow/cc/ops/training_ops.h"
38
+ #include "tensorflow/cc/ops/user_ops.h"
39
+
40
+ #endif // TENSORFLOW_CC_OPS_STANDARD_OPS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/state_ops.h ADDED
@@ -0,0 +1,1519 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/state_ops_internal.h ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_STATE_OPS_INTERNAL_H_
4
+ #define TENSORFLOW_CC_OPS_STATE_OPS_INTERNAL_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
+ namespace internal {
18
+ // NOTE: This namespace has internal TensorFlow details that
19
+ // are not part of TensorFlow's public API.
20
+
21
+ /// @defgroup state_ops_internal State Ops Internal
22
+ /// @{
23
+
24
+ /// Computes element-wise maximum.
25
+ ///
26
+ /// Args:
27
+ /// * scope: A Scope object
28
+ /// * ref: A mutable Tensor. Should be from a Variable node.
29
+ /// * indices: A Tensor. Must be one of the following types: int32, int64.
30
+ /// A tensor of indices into ref.
31
+ /// * updates: A Tensor. Must have the same type as ref. A tensor of updated values
32
+ /// to add to ref.
33
+ ///
34
+ /// Optional attributes (see `Attrs`):
35
+ /// * use_locking: An optional bool. Defaults to True. If True, the assignment will
36
+ /// be protected by a lock; otherwise the behavior is undefined,
37
+ /// but may exhibit less contention.
38
+ ///
39
+ /// Returns:
40
+ /// * `Output`: Same as ref. Returned as a convenience for operations that want
41
+ /// to use the updated values after the update is done.
42
+ class ScatterNdMax {
43
+ public:
44
+ /// Optional attribute setters for ScatterNdMax
45
+ struct Attrs {
46
+ /// An optional bool. Defaults to True. If True, the assignment will
47
+ /// be protected by a lock; otherwise the behavior is undefined,
48
+ /// but may exhibit less contention.
49
+ ///
50
+ /// Defaults to false
51
+ TF_MUST_USE_RESULT Attrs UseLocking(bool x) {
52
+ Attrs ret = *this;
53
+ ret.use_locking_ = x;
54
+ return ret;
55
+ }
56
+
57
+ bool use_locking_ = false;
58
+ };
59
+ ScatterNdMax(const ::tensorflow::Scope& scope, ::tensorflow::Input ref,
60
+ ::tensorflow::Input indices, ::tensorflow::Input updates);
61
+ ScatterNdMax(const ::tensorflow::Scope& scope, ::tensorflow::Input ref,
62
+ ::tensorflow::Input indices, ::tensorflow::Input updates, const
63
+ ScatterNdMax::Attrs& attrs);
64
+ operator ::tensorflow::Output() const { return output_ref; }
65
+ operator ::tensorflow::Input() const { return output_ref; }
66
+ ::tensorflow::Node* node() const { return output_ref.node(); }
67
+
68
+ static Attrs UseLocking(bool x) {
69
+ return Attrs().UseLocking(x);
70
+ }
71
+
72
+ Operation operation;
73
+ ::tensorflow::Output output_ref;
74
+ };
75
+
76
+ /// Computes element-wise minimum.
77
+ ///
78
+ /// Args:
79
+ /// * scope: A Scope object
80
+ /// * ref: A mutable Tensor. Should be from a Variable node.
81
+ /// * indices: A Tensor. Must be one of the following types: int32, int64.
82
+ /// A tensor of indices into ref.
83
+ /// * updates: A Tensor. Must have the same type as ref. A tensor of updated values
84
+ /// to add to ref.
85
+ ///
86
+ /// Optional attributes (see `Attrs`):
87
+ /// * use_locking: An optional bool. Defaults to True. If True, the assignment will
88
+ /// be protected by a lock; otherwise the behavior is undefined,
89
+ /// but may exhibit less contention.
90
+ ///
91
+ /// Returns:
92
+ /// * `Output`: Same as ref. Returned as a convenience for operations that want
93
+ /// to use the updated values after the update is done.
94
+ class ScatterNdMin {
95
+ public:
96
+ /// Optional attribute setters for ScatterNdMin
97
+ struct Attrs {
98
+ /// An optional bool. Defaults to True. If True, the assignment will
99
+ /// be protected by a lock; otherwise the behavior is undefined,
100
+ /// but may exhibit less contention.
101
+ ///
102
+ /// Defaults to false
103
+ TF_MUST_USE_RESULT Attrs UseLocking(bool x) {
104
+ Attrs ret = *this;
105
+ ret.use_locking_ = x;
106
+ return ret;
107
+ }
108
+
109
+ bool use_locking_ = false;
110
+ };
111
+ ScatterNdMin(const ::tensorflow::Scope& scope, ::tensorflow::Input ref,
112
+ ::tensorflow::Input indices, ::tensorflow::Input updates);
113
+ ScatterNdMin(const ::tensorflow::Scope& scope, ::tensorflow::Input ref,
114
+ ::tensorflow::Input indices, ::tensorflow::Input updates, const
115
+ ScatterNdMin::Attrs& attrs);
116
+ operator ::tensorflow::Output() const { return output_ref; }
117
+ operator ::tensorflow::Input() const { return output_ref; }
118
+ ::tensorflow::Node* node() const { return output_ref.node(); }
119
+
120
+ static Attrs UseLocking(bool x) {
121
+ return Attrs().UseLocking(x);
122
+ }
123
+
124
+ Operation operation;
125
+ ::tensorflow::Output output_ref;
126
+ };
127
+
128
+ } // namespace internal
129
+ } // namespace ops
130
+ } // namespace tensorflow
131
+
132
+ #endif // TENSORFLOW_CC_OPS_STATE_OPS_INTERNAL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/string_ops.h ADDED
@@ -0,0 +1,1284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_STRING_OPS_H_
4
+ #define TENSORFLOW_CC_OPS_STRING_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 string_ops String Ops
19
+ /// @{
20
+
21
+ /// Converts each entry in the given tensor to strings.
22
+ ///
23
+ /// Supports many numeric types and boolean.
24
+ ///
25
+ /// For Unicode, see the
26
+ /// [https://www.tensorflow.org/tutorials/representation/unicode](Working with Unicode text)
27
+ /// tutorial.
28
+ ///
29
+ /// Examples:
30
+ ///
31
+ /// >>> tf.strings.as_string([3, 2])
32
+ /// <tf.Tensor: shape=(2,), dtype=string, numpy=array([b'3', b'2'], dtype=object)>
33
+ /// >>> tf.strings.as_string([3.1415926, 2.71828], precision=2).numpy()
34
+ /// array([b'3.14', b'2.72'], dtype=object)
35
+ ///
36
+ /// Args:
37
+ /// * scope: A Scope object
38
+ ///
39
+ /// Optional attributes (see `Attrs`):
40
+ /// * precision: The post-decimal precision to use for floating point numbers.
41
+ /// Only used if precision > -1.
42
+ /// * scientific: Use scientific notation for floating point numbers.
43
+ /// * shortest: Use shortest representation (either scientific or standard) for
44
+ /// floating point numbers.
45
+ /// * width: Pad pre-decimal numbers to this width.
46
+ /// Applies to both floating point and integer numbers.
47
+ /// Only used if width > -1.
48
+ /// * fill: The value to pad if width > -1. If empty, pads with spaces.
49
+ /// Another typical value is '0'. String cannot be longer than 1 character.
50
+ ///
51
+ /// Returns:
52
+ /// * `Output`: The output tensor.
53
+ class AsString {
54
+ public:
55
+ /// Optional attribute setters for AsString
56
+ struct Attrs {
57
+ /// The post-decimal precision to use for floating point numbers.
58
+ /// Only used if precision > -1.
59
+ ///
60
+ /// Defaults to -1
61
+ TF_MUST_USE_RESULT Attrs Precision(int64 x) {
62
+ Attrs ret = *this;
63
+ ret.precision_ = x;
64
+ return ret;
65
+ }
66
+
67
+ /// Use scientific notation for floating point numbers.
68
+ ///
69
+ /// Defaults to false
70
+ TF_MUST_USE_RESULT Attrs Scientific(bool x) {
71
+ Attrs ret = *this;
72
+ ret.scientific_ = x;
73
+ return ret;
74
+ }
75
+
76
+ /// Use shortest representation (either scientific or standard) for
77
+ /// floating point numbers.
78
+ ///
79
+ /// Defaults to false
80
+ TF_MUST_USE_RESULT Attrs Shortest(bool x) {
81
+ Attrs ret = *this;
82
+ ret.shortest_ = x;
83
+ return ret;
84
+ }
85
+
86
+ /// Pad pre-decimal numbers to this width.
87
+ /// Applies to both floating point and integer numbers.
88
+ /// Only used if width > -1.
89
+ ///
90
+ /// Defaults to -1
91
+ TF_MUST_USE_RESULT Attrs Width(int64 x) {
92
+ Attrs ret = *this;
93
+ ret.width_ = x;
94
+ return ret;
95
+ }
96
+
97
+ /// The value to pad if width > -1. If empty, pads with spaces.
98
+ /// Another typical value is '0'. String cannot be longer than 1 character.
99
+ ///
100
+ /// Defaults to ""
101
+ TF_MUST_USE_RESULT Attrs Fill(StringPiece x) {
102
+ Attrs ret = *this;
103
+ ret.fill_ = x;
104
+ return ret;
105
+ }
106
+
107
+ int64 precision_ = -1;
108
+ bool scientific_ = false;
109
+ bool shortest_ = false;
110
+ int64 width_ = -1;
111
+ StringPiece fill_ = "";
112
+ };
113
+ AsString(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
114
+ AsString(const ::tensorflow::Scope& scope, ::tensorflow::Input input, const
115
+ AsString::Attrs& attrs);
116
+ operator ::tensorflow::Output() const { return output; }
117
+ operator ::tensorflow::Input() const { return output; }
118
+ ::tensorflow::Node* node() const { return output.node(); }
119
+
120
+ static Attrs Precision(int64 x) {
121
+ return Attrs().Precision(x);
122
+ }
123
+ static Attrs Scientific(bool x) {
124
+ return Attrs().Scientific(x);
125
+ }
126
+ static Attrs Shortest(bool x) {
127
+ return Attrs().Shortest(x);
128
+ }
129
+ static Attrs Width(int64 x) {
130
+ return Attrs().Width(x);
131
+ }
132
+ static Attrs Fill(StringPiece x) {
133
+ return Attrs().Fill(x);
134
+ }
135
+
136
+ Operation operation;
137
+ ::tensorflow::Output output;
138
+ };
139
+
140
+ /// Decode web-safe base64-encoded strings.
141
+ ///
142
+ /// Input may or may not have padding at the end. See
143
+ /// [EncodeBase64](https://www.tensorflow.org/api_docs/python/tf/io/encode_base64)
144
+ /// for padding. Web-safe means that input must use - and _ instead of + and /.
145
+ ///
146
+ /// Args:
147
+ /// * scope: A Scope object
148
+ /// * input: Base64 strings to decode.
149
+ ///
150
+ /// Returns:
151
+ /// * `Output`: Decoded strings.
152
+ class DecodeBase64 {
153
+ public:
154
+ DecodeBase64(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
155
+ operator ::tensorflow::Output() const { return output; }
156
+ operator ::tensorflow::Input() const { return output; }
157
+ ::tensorflow::Node* node() const { return output.node(); }
158
+
159
+ Operation operation;
160
+ ::tensorflow::Output output;
161
+ };
162
+
163
+ /// Encode strings into web-safe base64 format.
164
+ ///
165
+ /// Refer to [this article](https://en.wikipedia.org/wiki/Base64) for more information on
166
+ /// base64 format. Base64 strings may have padding with '=' at the
167
+ /// end so that the encoded has length multiple of 4. See Padding section of the
168
+ /// link above.
169
+ ///
170
+ /// Web-safe means that the encoder uses - and _ instead of + and /.
171
+ ///
172
+ /// Args:
173
+ /// * scope: A Scope object
174
+ /// * input: Strings to be encoded.
175
+ ///
176
+ /// Optional attributes (see `Attrs`):
177
+ /// * pad: Bool whether padding is applied at the ends.
178
+ ///
179
+ /// Returns:
180
+ /// * `Output`: Input strings encoded in base64.
181
+ class EncodeBase64 {
182
+ public:
183
+ /// Optional attribute setters for EncodeBase64
184
+ struct Attrs {
185
+ /// Bool whether padding is applied at the ends.
186
+ ///
187
+ /// Defaults to false
188
+ TF_MUST_USE_RESULT Attrs Pad(bool x) {
189
+ Attrs ret = *this;
190
+ ret.pad_ = x;
191
+ return ret;
192
+ }
193
+
194
+ bool pad_ = false;
195
+ };
196
+ EncodeBase64(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
197
+ EncodeBase64(const ::tensorflow::Scope& scope, ::tensorflow::Input input, const
198
+ EncodeBase64::Attrs& attrs);
199
+ operator ::tensorflow::Output() const { return output; }
200
+ operator ::tensorflow::Input() const { return output; }
201
+ ::tensorflow::Node* node() const { return output.node(); }
202
+
203
+ static Attrs Pad(bool x) {
204
+ return Attrs().Pad(x);
205
+ }
206
+
207
+ Operation operation;
208
+ ::tensorflow::Output output;
209
+ };
210
+
211
+ /// Joins a string Tensor across the given dimensions.
212
+ ///
213
+ /// Computes the string join across dimensions in the given string Tensor of shape
214
+ /// `[\\(d_0, d_1, ..., d_{n-1}\\)]`. Returns a new Tensor created by joining the input
215
+ /// strings with the given separator (default: empty string). Negative indices are
216
+ /// counted backwards from the end, with `-1` being equivalent to `n - 1`. If
217
+ /// indices are not specified, joins across all dimensions beginning from `n - 1`
218
+ /// through `0`.
219
+ ///
220
+ /// For example:
221
+ ///
222
+ /// ```python
223
+ /// # tensor `a` is [["a", "b"], ["c", "d"]]
224
+ /// tf.reduce_join(a, 0) ==> ["ac", "bd"]
225
+ /// tf.reduce_join(a, 1) ==> ["ab", "cd"]
226
+ /// tf.reduce_join(a, -2) = tf.reduce_join(a, 0) ==> ["ac", "bd"]
227
+ /// tf.reduce_join(a, -1) = tf.reduce_join(a, 1) ==> ["ab", "cd"]
228
+ /// tf.reduce_join(a, 0, keep_dims=True) ==> [["ac", "bd"]]
229
+ /// tf.reduce_join(a, 1, keep_dims=True) ==> [["ab"], ["cd"]]
230
+ /// tf.reduce_join(a, 0, separator=".") ==> ["a.c", "b.d"]
231
+ /// tf.reduce_join(a, [0, 1]) ==> "acbd"
232
+ /// tf.reduce_join(a, [1, 0]) ==> "abcd"
233
+ /// tf.reduce_join(a, []) ==> [["a", "b"], ["c", "d"]]
234
+ /// tf.reduce_join(a) = tf.reduce_join(a, [1, 0]) ==> "abcd"
235
+ /// ```
236
+ ///
237
+ /// Args:
238
+ /// * scope: A Scope object
239
+ /// * inputs: The input to be joined. All reduced indices must have non-zero size.
240
+ /// * reduction_indices: The dimensions to reduce over. Dimensions are reduced in the
241
+ /// order specified. Omitting `reduction_indices` is equivalent to passing
242
+ /// `[n-1, n-2, ..., 0]`. Negative indices from `-n` to `-1` are supported.
243
+ ///
244
+ /// Optional attributes (see `Attrs`):
245
+ /// * keep_dims: If `True`, retain reduced dimensions with length `1`.
246
+ /// * separator: The separator to use when joining.
247
+ ///
248
+ /// Returns:
249
+ /// * `Output`: Has shape equal to that of the input with reduced dimensions removed or
250
+ /// set to `1` depending on `keep_dims`.
251
+ class ReduceJoin {
252
+ public:
253
+ /// Optional attribute setters for ReduceJoin
254
+ struct Attrs {
255
+ /// If `True`, retain reduced dimensions with length `1`.
256
+ ///
257
+ /// Defaults to false
258
+ TF_MUST_USE_RESULT Attrs KeepDims(bool x) {
259
+ Attrs ret = *this;
260
+ ret.keep_dims_ = x;
261
+ return ret;
262
+ }
263
+
264
+ /// The separator to use when joining.
265
+ ///
266
+ /// Defaults to ""
267
+ TF_MUST_USE_RESULT Attrs Separator(StringPiece x) {
268
+ Attrs ret = *this;
269
+ ret.separator_ = x;
270
+ return ret;
271
+ }
272
+
273
+ bool keep_dims_ = false;
274
+ StringPiece separator_ = "";
275
+ };
276
+ ReduceJoin(const ::tensorflow::Scope& scope, ::tensorflow::Input inputs,
277
+ ::tensorflow::Input reduction_indices);
278
+ ReduceJoin(const ::tensorflow::Scope& scope, ::tensorflow::Input inputs,
279
+ ::tensorflow::Input reduction_indices, const ReduceJoin::Attrs&
280
+ attrs);
281
+ operator ::tensorflow::Output() const { return output; }
282
+ operator ::tensorflow::Input() const { return output; }
283
+ ::tensorflow::Node* node() const { return output.node(); }
284
+
285
+ static Attrs KeepDims(bool x) {
286
+ return Attrs().KeepDims(x);
287
+ }
288
+ static Attrs Separator(StringPiece x) {
289
+ return Attrs().Separator(x);
290
+ }
291
+
292
+ Operation operation;
293
+ ::tensorflow::Output output;
294
+ };
295
+
296
+ /// Check if the input matches the regex pattern.
297
+ ///
298
+ /// The input is a string tensor of any shape. The pattern is a scalar
299
+ /// string tensor which is applied to every element of the input tensor.
300
+ /// The boolean values (True or False) of the output tensor indicate
301
+ /// if the input matches the regex pattern provided.
302
+ ///
303
+ /// The pattern follows the re2 syntax (https://github.com/google/re2/wiki/Syntax)
304
+ ///
305
+ /// Examples:
306
+ ///
307
+ /// >>> tf.strings.regex_full_match(["TF lib", "lib TF"], ".*lib$")
308
+ /// <tf.Tensor: shape=(2,), dtype=bool, numpy=array([ True, False])>
309
+ /// >>> tf.strings.regex_full_match(["TF lib", "lib TF"], ".*TF$")
310
+ /// <tf.Tensor: shape=(2,), dtype=bool, numpy=array([False, True])>
311
+ ///
312
+ /// Args:
313
+ /// * scope: A Scope object
314
+ /// * input: A string tensor of the text to be processed.
315
+ /// * pattern: A scalar string tensor containing the regular expression to match the input.
316
+ ///
317
+ /// Returns:
318
+ /// * `Output`: A bool tensor with the same shape as `input`.
319
+ class RegexFullMatch {
320
+ public:
321
+ RegexFullMatch(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
322
+ ::tensorflow::Input pattern);
323
+ operator ::tensorflow::Output() const { return output; }
324
+ operator ::tensorflow::Input() const { return output; }
325
+ ::tensorflow::Node* node() const { return output.node(); }
326
+
327
+ Operation operation;
328
+ ::tensorflow::Output output;
329
+ };
330
+
331
+ /// Replaces matches of the `pattern` regular expression in `input` with the
332
+ /// replacement string provided in `rewrite`.
333
+ ///
334
+ /// It follows the re2 syntax (https://github.com/google/re2/wiki/Syntax)
335
+ ///
336
+ /// Args:
337
+ /// * scope: A Scope object
338
+ /// * input: The text to be processed.
339
+ /// * pattern: The regular expression to be matched in the `input` strings.
340
+ /// * rewrite: The rewrite string to be substituted for the `pattern` expression where it is
341
+ /// matched in the `input` strings.
342
+ ///
343
+ /// Optional attributes (see `Attrs`):
344
+ /// * replace_global: If True, the replacement is global (that is, all matches of the `pattern` regular
345
+ /// expression in each input string are rewritten), otherwise the `rewrite`
346
+ /// substitution is only made for the first `pattern` match.
347
+ ///
348
+ /// Returns:
349
+ /// * `Output`: The text after applying pattern match and rewrite substitution.
350
+ class RegexReplace {
351
+ public:
352
+ /// Optional attribute setters for RegexReplace
353
+ struct Attrs {
354
+ /// If True, the replacement is global (that is, all matches of the `pattern` regular
355
+ /// expression in each input string are rewritten), otherwise the `rewrite`
356
+ /// substitution is only made for the first `pattern` match.
357
+ ///
358
+ /// Defaults to true
359
+ TF_MUST_USE_RESULT Attrs ReplaceGlobal(bool x) {
360
+ Attrs ret = *this;
361
+ ret.replace_global_ = x;
362
+ return ret;
363
+ }
364
+
365
+ bool replace_global_ = true;
366
+ };
367
+ RegexReplace(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
368
+ ::tensorflow::Input pattern, ::tensorflow::Input rewrite);
369
+ RegexReplace(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
370
+ ::tensorflow::Input pattern, ::tensorflow::Input rewrite, const
371
+ RegexReplace::Attrs& attrs);
372
+ operator ::tensorflow::Output() const { return output; }
373
+ operator ::tensorflow::Input() const { return output; }
374
+ ::tensorflow::Node* node() const { return output.node(); }
375
+
376
+ static Attrs ReplaceGlobal(bool x) {
377
+ return Attrs().ReplaceGlobal(x);
378
+ }
379
+
380
+ Operation operation;
381
+ ::tensorflow::Output output;
382
+ };
383
+
384
+ /// Formats a string template using a list of tensors.
385
+ ///
386
+ /// Formats a string template using a list of tensors, pretty-printing tensor summaries.
387
+ ///
388
+ /// Args:
389
+ /// * scope: A Scope object
390
+ /// * inputs: The list of tensors to format into the placeholder string.
391
+ ///
392
+ /// Optional attributes (see `Attrs`):
393
+ /// * template_: A string, the template to format tensor summaries into.
394
+ /// * placeholder: A string, at each placeholder in the template a subsequent tensor summary will be inserted.
395
+ /// * summarize: When formatting the tensor summaries print the first and last summarize entries of each tensor dimension.
396
+ ///
397
+ /// Returns:
398
+ /// * `Output`: = The resulting string scalar.
399
+ class StringFormat {
400
+ public:
401
+ /// Optional attribute setters for StringFormat
402
+ struct Attrs {
403
+ /// A string, the template to format tensor summaries into.
404
+ ///
405
+ /// Defaults to "%s"
406
+ TF_MUST_USE_RESULT Attrs Template(StringPiece x) {
407
+ Attrs ret = *this;
408
+ ret.template_ = x;
409
+ return ret;
410
+ }
411
+
412
+ /// A string, at each placeholder in the template a subsequent tensor summary will be inserted.
413
+ ///
414
+ /// Defaults to "%s"
415
+ TF_MUST_USE_RESULT Attrs Placeholder(StringPiece x) {
416
+ Attrs ret = *this;
417
+ ret.placeholder_ = x;
418
+ return ret;
419
+ }
420
+
421
+ /// When formatting the tensor summaries print the first and last summarize entries of each tensor dimension.
422
+ ///
423
+ /// Defaults to 3
424
+ TF_MUST_USE_RESULT Attrs Summarize(int64 x) {
425
+ Attrs ret = *this;
426
+ ret.summarize_ = x;
427
+ return ret;
428
+ }
429
+
430
+ StringPiece template_ = "%s";
431
+ StringPiece placeholder_ = "%s";
432
+ int64 summarize_ = 3;
433
+ };
434
+ StringFormat(const ::tensorflow::Scope& scope, ::tensorflow::InputList inputs);
435
+ StringFormat(const ::tensorflow::Scope& scope, ::tensorflow::InputList inputs,
436
+ const StringFormat::Attrs& attrs);
437
+ operator ::tensorflow::Output() const { return output; }
438
+ operator ::tensorflow::Input() const { return output; }
439
+ ::tensorflow::Node* node() const { return output.node(); }
440
+
441
+ static Attrs Template(StringPiece x) {
442
+ return Attrs().Template(x);
443
+ }
444
+ static Attrs Placeholder(StringPiece x) {
445
+ return Attrs().Placeholder(x);
446
+ }
447
+ static Attrs Summarize(int64 x) {
448
+ return Attrs().Summarize(x);
449
+ }
450
+
451
+ Operation operation;
452
+ ::tensorflow::Output output;
453
+ };
454
+
455
+ /// Joins the strings in the given list of string tensors into one tensor;
456
+ ///
457
+ /// with the given separator (default is an empty separator).
458
+ ///
459
+ /// Examples:
460
+ ///
461
+ /// >>> s = ["hello", "world", "tensorflow"]
462
+ /// >>> tf.strings.join(s, " ")
463
+ /// <tf.Tensor: shape=(), dtype=string, numpy=b'hello world tensorflow'>
464
+ ///
465
+ /// Args:
466
+ /// * scope: A Scope object
467
+ /// * inputs: A list of string tensors. The tensors must all have the same shape,
468
+ /// or be scalars. Scalars may be mixed in; these will be broadcast to the shape
469
+ /// of non-scalar inputs.
470
+ ///
471
+ /// Optional attributes (see `Attrs`):
472
+ /// * separator: string, an optional join separator.
473
+ ///
474
+ /// Returns:
475
+ /// * `Output`: The output tensor.
476
+ class StringJoin {
477
+ public:
478
+ /// Optional attribute setters for StringJoin
479
+ struct Attrs {
480
+ /// string, an optional join separator.
481
+ ///
482
+ /// Defaults to ""
483
+ TF_MUST_USE_RESULT Attrs Separator(StringPiece x) {
484
+ Attrs ret = *this;
485
+ ret.separator_ = x;
486
+ return ret;
487
+ }
488
+
489
+ StringPiece separator_ = "";
490
+ };
491
+ StringJoin(const ::tensorflow::Scope& scope, ::tensorflow::InputList inputs);
492
+ StringJoin(const ::tensorflow::Scope& scope, ::tensorflow::InputList inputs,
493
+ const StringJoin::Attrs& attrs);
494
+ operator ::tensorflow::Output() const { return output; }
495
+ operator ::tensorflow::Input() const { return output; }
496
+ ::tensorflow::Node* node() const { return output.node(); }
497
+
498
+ static Attrs Separator(StringPiece x) {
499
+ return Attrs().Separator(x);
500
+ }
501
+
502
+ Operation operation;
503
+ ::tensorflow::Output output;
504
+ };
505
+
506
+ /// String lengths of `input`.
507
+ ///
508
+ /// Computes the length of each string given in the input tensor.
509
+ ///
510
+ /// >>> strings = tf.constant(['Hello','TensorFlow', '\U0001F642'])
511
+ /// >>> tf.strings.length(strings).numpy() # default counts bytes
512
+ /// array([ 5, 10, 4], dtype=int32)
513
+ /// >>> tf.strings.length(strings, unit="UTF8_CHAR").numpy()
514
+ /// array([ 5, 10, 1], dtype=int32)
515
+ ///
516
+ ///
517
+ /// Args:
518
+ /// * scope: A Scope object
519
+ /// * input: The strings for which to compute the length for each element.
520
+ ///
521
+ /// Optional attributes (see `Attrs`):
522
+ /// * unit: The unit that is counted to compute string length. One of: `"BYTE"` (for
523
+ /// the number of bytes in each string) or `"UTF8_CHAR"` (for the number of UTF-8
524
+ /// encoded Unicode code points in each string). Results are undefined
525
+ /// if `unit=UTF8_CHAR` and the `input` strings do not contain structurally
526
+ /// valid UTF-8.
527
+ ///
528
+ /// Returns:
529
+ /// * `Output`: Integer tensor that has the same shape as `input`. The output contains the
530
+ /// element-wise string lengths of `input`.
531
+ class StringLength {
532
+ public:
533
+ /// Optional attribute setters for StringLength
534
+ struct Attrs {
535
+ /// The unit that is counted to compute string length. One of: `"BYTE"` (for
536
+ /// the number of bytes in each string) or `"UTF8_CHAR"` (for the number of UTF-8
537
+ /// encoded Unicode code points in each string). Results are undefined
538
+ /// if `unit=UTF8_CHAR` and the `input` strings do not contain structurally
539
+ /// valid UTF-8.
540
+ ///
541
+ /// Defaults to "BYTE"
542
+ TF_MUST_USE_RESULT Attrs Unit(StringPiece x) {
543
+ Attrs ret = *this;
544
+ ret.unit_ = x;
545
+ return ret;
546
+ }
547
+
548
+ StringPiece unit_ = "BYTE";
549
+ };
550
+ StringLength(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
551
+ StringLength(const ::tensorflow::Scope& scope, ::tensorflow::Input input, const
552
+ StringLength::Attrs& attrs);
553
+ operator ::tensorflow::Output() const { return output; }
554
+ operator ::tensorflow::Input() const { return output; }
555
+ ::tensorflow::Node* node() const { return output.node(); }
556
+
557
+ static Attrs Unit(StringPiece x) {
558
+ return Attrs().Unit(x);
559
+ }
560
+
561
+ Operation operation;
562
+ ::tensorflow::Output output;
563
+ };
564
+
565
+ /// Converts all uppercase characters into their respective lowercase replacements.
566
+ ///
567
+ /// Example:
568
+ ///
569
+ /// >>> tf.strings.lower("CamelCase string and ALL CAPS")
570
+ /// <tf.Tensor: shape=(), dtype=string, numpy=b'camelcase string and all caps'>
571
+ ///
572
+ ///
573
+ /// Args:
574
+ /// * scope: A Scope object
575
+ /// * input: The input to be lower-cased.
576
+ ///
577
+ /// Optional attributes (see `Attrs`):
578
+ /// * encoding: Character encoding of `input`. Allowed values are '' and 'utf-8'.
579
+ /// Value '' is interpreted as ASCII.
580
+ ///
581
+ /// Returns:
582
+ /// * `Output`: The output tensor.
583
+ class StringLower {
584
+ public:
585
+ /// Optional attribute setters for StringLower
586
+ struct Attrs {
587
+ /// Character encoding of `input`. Allowed values are '' and 'utf-8'.
588
+ /// Value '' is interpreted as ASCII.
589
+ ///
590
+ /// Defaults to ""
591
+ TF_MUST_USE_RESULT Attrs Encoding(StringPiece x) {
592
+ Attrs ret = *this;
593
+ ret.encoding_ = x;
594
+ return ret;
595
+ }
596
+
597
+ StringPiece encoding_ = "";
598
+ };
599
+ StringLower(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
600
+ StringLower(const ::tensorflow::Scope& scope, ::tensorflow::Input input, const
601
+ StringLower::Attrs& attrs);
602
+ operator ::tensorflow::Output() const { return output; }
603
+ operator ::tensorflow::Input() const { return output; }
604
+ ::tensorflow::Node* node() const { return output.node(); }
605
+
606
+ static Attrs Encoding(StringPiece x) {
607
+ return Attrs().Encoding(x);
608
+ }
609
+
610
+ Operation operation;
611
+ ::tensorflow::Output output;
612
+ };
613
+
614
+ /// Creates ngrams from ragged string data.
615
+ ///
616
+ /// This op accepts a ragged tensor with 1 ragged dimension containing only
617
+ /// strings and outputs a ragged tensor with 1 ragged dimension containing ngrams
618
+ /// of that string, joined along the innermost axis.
619
+ ///
620
+ /// Args:
621
+ /// * scope: A Scope object
622
+ /// * data: The values tensor of the ragged string tensor to make ngrams out of. Must be a
623
+ /// 1D string tensor.
624
+ /// * data_splits: The splits tensor of the ragged string tensor to make ngrams out of.
625
+ /// * separator: The string to append between elements of the token. Use "" for no separator.
626
+ /// * ngram_widths: The sizes of the ngrams to create.
627
+ /// * left_pad: The string to use to pad the left side of the ngram sequence. Only used if
628
+ /// pad_width != 0.
629
+ /// * right_pad: The string to use to pad the right side of the ngram sequence. Only used if
630
+ /// pad_width != 0.
631
+ /// * pad_width: The number of padding elements to add to each side of each
632
+ /// sequence. Note that padding will never be greater than 'ngram_widths'-1
633
+ /// regardless of this value. If `pad_width=-1`, then add `max(ngram_widths)-1`
634
+ /// elements.
635
+ ///
636
+ /// Returns:
637
+ /// * `Output` ngrams: The values tensor of the output ngrams ragged tensor.
638
+ /// * `Output` ngrams_splits: The splits tensor of the output ngrams ragged tensor.
639
+ class StringNGrams {
640
+ public:
641
+ StringNGrams(const ::tensorflow::Scope& scope, ::tensorflow::Input data,
642
+ ::tensorflow::Input data_splits, StringPiece separator, const
643
+ gtl::ArraySlice<int>& ngram_widths, StringPiece left_pad,
644
+ StringPiece right_pad, int64 pad_width, bool
645
+ preserve_short_sequences);
646
+
647
+ Operation operation;
648
+ ::tensorflow::Output ngrams;
649
+ ::tensorflow::Output ngrams_splits;
650
+ };
651
+
652
+ /// Split elements of `input` based on `delimiter` into a `SparseTensor`.
653
+ ///
654
+ /// Let N be the size of source (typically N will be the batch size). Split each
655
+ /// element of `input` based on `delimiter` and return a `SparseTensor`
656
+ /// containing the splitted tokens. Empty tokens are ignored.
657
+ ///
658
+ /// `delimiter` can be empty, or a string of split characters. If `delimiter` is an
659
+ /// empty string, each element of `input` is split into individual single-byte
660
+ /// character strings, including splitting of UTF-8 multibyte sequences. Otherwise
661
+ /// every character of `delimiter` is a potential split point.
662
+ ///
663
+ /// For example:
664
+ /// N = 2, input[0] is 'hello world' and input[1] is 'a b c', then the output
665
+ /// will be
666
+ ///
667
+ /// indices = [0, 0;
668
+ /// 0, 1;
669
+ /// 1, 0;
670
+ /// 1, 1;
671
+ /// 1, 2]
672
+ /// shape = [2, 3]
673
+ /// values = ['hello', 'world', 'a', 'b', 'c']
674
+ ///
675
+ /// Args:
676
+ /// * scope: A Scope object
677
+ /// * input: 1-D. Strings to split.
678
+ /// * delimiter: 0-D. Delimiter characters (bytes), or empty string.
679
+ ///
680
+ /// Optional attributes (see `Attrs`):
681
+ /// * skip_empty: A `bool`. If `True`, skip the empty strings from the result.
682
+ ///
683
+ /// Returns:
684
+ /// * `Output` indices: A dense matrix of int64 representing the indices of the sparse tensor.
685
+ /// * `Output` values: A vector of strings corresponding to the splited values.
686
+ /// * `Output` shape: a length-2 vector of int64 representing the shape of the sparse
687
+ /// tensor, where the first value is N and the second value is the maximum number
688
+ /// of tokens in a single input entry.
689
+ class StringSplit {
690
+ public:
691
+ /// Optional attribute setters for StringSplit
692
+ struct Attrs {
693
+ /// A `bool`. If `True`, skip the empty strings from the result.
694
+ ///
695
+ /// Defaults to true
696
+ TF_MUST_USE_RESULT Attrs SkipEmpty(bool x) {
697
+ Attrs ret = *this;
698
+ ret.skip_empty_ = x;
699
+ return ret;
700
+ }
701
+
702
+ bool skip_empty_ = true;
703
+ };
704
+ StringSplit(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
705
+ ::tensorflow::Input delimiter);
706
+ StringSplit(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
707
+ ::tensorflow::Input delimiter, const StringSplit::Attrs& attrs);
708
+
709
+ static Attrs SkipEmpty(bool x) {
710
+ return Attrs().SkipEmpty(x);
711
+ }
712
+
713
+ Operation operation;
714
+ ::tensorflow::Output indices;
715
+ ::tensorflow::Output values;
716
+ ::tensorflow::Output shape;
717
+ };
718
+
719
+ /// Split elements of `source` based on `sep` into a `SparseTensor`.
720
+ ///
721
+ /// Let N be the size of source (typically N will be the batch size). Split each
722
+ /// element of `source` based on `sep` and return a `SparseTensor`
723
+ /// containing the split tokens. Empty tokens are ignored.
724
+ ///
725
+ /// For example, N = 2, source[0] is 'hello world' and source[1] is 'a b c',
726
+ /// then the output will be
727
+ /// ```
728
+ /// st.indices = [0, 0;
729
+ /// 0, 1;
730
+ /// 1, 0;
731
+ /// 1, 1;
732
+ /// 1, 2]
733
+ /// st.shape = [2, 3]
734
+ /// st.values = ['hello', 'world', 'a', 'b', 'c']
735
+ /// ```
736
+ ///
737
+ /// If `sep` is given, consecutive delimiters are not grouped together and are
738
+ /// deemed to delimit empty strings. For example, source of `"1<>2<><>3"` and
739
+ /// sep of `"<>"` returns `["1", "2", "", "3"]`. If `sep` is None or an empty
740
+ /// string, consecutive whitespace are regarded as a single separator, and the
741
+ /// result will contain no empty strings at the startor end if the string has
742
+ /// leading or trailing whitespace.
743
+ ///
744
+ /// Note that the above mentioned behavior matches python's str.split.
745
+ ///
746
+ /// Args:
747
+ /// * scope: A Scope object
748
+ /// * input: `1-D` string `Tensor`, the strings to split.
749
+ /// * sep: `0-D` string `Tensor`, the delimiter character.
750
+ ///
751
+ /// Optional attributes (see `Attrs`):
752
+ /// * maxsplit: An `int`. If `maxsplit > 0`, limit of the split of the result.
753
+ ///
754
+ /// Returns:
755
+ /// * `Output` indices
756
+ /// * `Output` values
757
+ /// * `Output` shape
758
+ class StringSplitV2 {
759
+ public:
760
+ /// Optional attribute setters for StringSplitV2
761
+ struct Attrs {
762
+ /// An `int`. If `maxsplit > 0`, limit of the split of the result.
763
+ ///
764
+ /// Defaults to -1
765
+ TF_MUST_USE_RESULT Attrs Maxsplit(int64 x) {
766
+ Attrs ret = *this;
767
+ ret.maxsplit_ = x;
768
+ return ret;
769
+ }
770
+
771
+ int64 maxsplit_ = -1;
772
+ };
773
+ StringSplitV2(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
774
+ ::tensorflow::Input sep);
775
+ StringSplitV2(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
776
+ ::tensorflow::Input sep, const StringSplitV2::Attrs& attrs);
777
+
778
+ static Attrs Maxsplit(int64 x) {
779
+ return Attrs().Maxsplit(x);
780
+ }
781
+
782
+ Operation operation;
783
+ ::tensorflow::Output indices;
784
+ ::tensorflow::Output values;
785
+ ::tensorflow::Output shape;
786
+ };
787
+
788
+ /// Strip leading and trailing whitespaces from the Tensor.
789
+ ///
790
+ /// Examples:
791
+ ///
792
+ /// >>> tf.strings.strip(["\nTensorFlow", " The python library "]).numpy()
793
+ /// array([b'TensorFlow', b'The python library'], dtype=object)
794
+ ///
795
+ /// Args:
796
+ /// * scope: A Scope object
797
+ /// * input: A string `Tensor` of any shape.
798
+ ///
799
+ /// Returns:
800
+ /// * `Output`: A string `Tensor` of the same shape as the input.
801
+ class StringStrip {
802
+ public:
803
+ StringStrip(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
804
+ operator ::tensorflow::Output() const { return output; }
805
+ operator ::tensorflow::Input() const { return output; }
806
+ ::tensorflow::Node* node() const { return output.node(); }
807
+
808
+ Operation operation;
809
+ ::tensorflow::Output output;
810
+ };
811
+
812
+ /// Converts each string in the input Tensor to its hash mod by a number of buckets.
813
+ ///
814
+ /// The hash function is deterministic on the content of the string within the
815
+ /// process.
816
+ ///
817
+ /// Note that the hash function may change from time to time.
818
+ /// This functionality will be deprecated and it's recommended to use
819
+ /// `tf.string_to_hash_bucket_fast()` or `tf.string_to_hash_bucket_strong()`.
820
+ ///
821
+ /// Args:
822
+ /// * scope: A Scope object
823
+ /// * num_buckets: The number of buckets.
824
+ ///
825
+ /// Returns:
826
+ /// * `Output`: A Tensor of the same shape as the input `string_tensor`.
827
+ class StringToHashBucket {
828
+ public:
829
+ StringToHashBucket(const ::tensorflow::Scope& scope, ::tensorflow::Input
830
+ string_tensor, int64 num_buckets);
831
+ operator ::tensorflow::Output() const { return output; }
832
+ operator ::tensorflow::Input() const { return output; }
833
+ ::tensorflow::Node* node() const { return output.node(); }
834
+
835
+ Operation operation;
836
+ ::tensorflow::Output output;
837
+ };
838
+
839
+ /// Converts each string in the input Tensor to its hash mod by a number of buckets.
840
+ ///
841
+ /// The hash function is deterministic on the content of the string within the
842
+ /// process and will never change. However, it is not suitable for cryptography.
843
+ /// This function may be used when CPU time is scarce and inputs are trusted or
844
+ /// unimportant. There is a risk of adversaries constructing inputs that all hash
845
+ /// to the same bucket. To prevent this problem, use a strong hash function with
846
+ /// `tf.string_to_hash_bucket_strong`.
847
+ ///
848
+ /// Examples:
849
+ ///
850
+ /// >>> tf.strings.to_hash_bucket_fast(["Hello", "TensorFlow", "2.x"], 3).numpy()
851
+ /// array([0, 2, 2])
852
+ ///
853
+ /// Args:
854
+ /// * scope: A Scope object
855
+ /// * input: The strings to assign a hash bucket.
856
+ /// * num_buckets: The number of buckets.
857
+ ///
858
+ /// Returns:
859
+ /// * `Output`: A Tensor of the same shape as the input `string_tensor`.
860
+ class StringToHashBucketFast {
861
+ public:
862
+ StringToHashBucketFast(const ::tensorflow::Scope& scope, ::tensorflow::Input
863
+ input, int64 num_buckets);
864
+ operator ::tensorflow::Output() const { return output; }
865
+ operator ::tensorflow::Input() const { return output; }
866
+ ::tensorflow::Node* node() const { return output.node(); }
867
+
868
+ Operation operation;
869
+ ::tensorflow::Output output;
870
+ };
871
+
872
+ /// Converts each string in the input Tensor to its hash mod by a number of buckets.
873
+ ///
874
+ /// The hash function is deterministic on the content of the string within the
875
+ /// process. The hash function is a keyed hash function, where attribute `key`
876
+ /// defines the key of the hash function. `key` is an array of 2 elements.
877
+ ///
878
+ /// A strong hash is important when inputs may be malicious, e.g. URLs with
879
+ /// additional components. Adversaries could try to make their inputs hash to the
880
+ /// same bucket for a denial-of-service attack or to skew the results. A strong
881
+ /// hash can be used to make it difficult to find inputs with a skewed hash value
882
+ /// distribution over buckets. This requires that the hash function is
883
+ /// seeded by a high-entropy (random) "key" unknown to the adversary.
884
+ ///
885
+ /// The additional robustness comes at a cost of roughly 4x higher compute
886
+ /// time than `tf.string_to_hash_bucket_fast`.
887
+ ///
888
+ /// Examples:
889
+ ///
890
+ /// >>> tf.strings.to_hash_bucket_strong(["Hello", "TF"], 3, [1, 2]).numpy()
891
+ /// array([2, 0])
892
+ ///
893
+ /// Args:
894
+ /// * scope: A Scope object
895
+ /// * input: The strings to assign a hash bucket.
896
+ /// * num_buckets: The number of buckets.
897
+ /// * key: The key used to seed the hash function, passed as a list of two uint64
898
+ /// elements.
899
+ ///
900
+ /// Returns:
901
+ /// * `Output`: A Tensor of the same shape as the input `string_tensor`.
902
+ class StringToHashBucketStrong {
903
+ public:
904
+ StringToHashBucketStrong(const ::tensorflow::Scope& scope, ::tensorflow::Input
905
+ input, int64 num_buckets, const gtl::ArraySlice<int>&
906
+ key);
907
+ operator ::tensorflow::Output() const { return output; }
908
+ operator ::tensorflow::Input() const { return output; }
909
+ ::tensorflow::Node* node() const { return output.node(); }
910
+
911
+ Operation operation;
912
+ ::tensorflow::Output output;
913
+ };
914
+
915
+ /// Converts all lowercase characters into their respective uppercase replacements.
916
+ ///
917
+ /// Example:
918
+ ///
919
+ /// >>> tf.strings.upper("CamelCase string and ALL CAPS")
920
+ /// <tf.Tensor: shape=(), dtype=string, numpy=b'CAMELCASE STRING AND ALL CAPS'>
921
+ ///
922
+ ///
923
+ /// Args:
924
+ /// * scope: A Scope object
925
+ /// * input: The input to be upper-cased.
926
+ ///
927
+ /// Optional attributes (see `Attrs`):
928
+ /// * encoding: Character encoding of `input`. Allowed values are '' and 'utf-8'.
929
+ /// Value '' is interpreted as ASCII.
930
+ ///
931
+ /// Returns:
932
+ /// * `Output`: The output tensor.
933
+ class StringUpper {
934
+ public:
935
+ /// Optional attribute setters for StringUpper
936
+ struct Attrs {
937
+ /// Character encoding of `input`. Allowed values are '' and 'utf-8'.
938
+ /// Value '' is interpreted as ASCII.
939
+ ///
940
+ /// Defaults to ""
941
+ TF_MUST_USE_RESULT Attrs Encoding(StringPiece x) {
942
+ Attrs ret = *this;
943
+ ret.encoding_ = x;
944
+ return ret;
945
+ }
946
+
947
+ StringPiece encoding_ = "";
948
+ };
949
+ StringUpper(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
950
+ StringUpper(const ::tensorflow::Scope& scope, ::tensorflow::Input input, const
951
+ StringUpper::Attrs& attrs);
952
+ operator ::tensorflow::Output() const { return output; }
953
+ operator ::tensorflow::Input() const { return output; }
954
+ ::tensorflow::Node* node() const { return output.node(); }
955
+
956
+ static Attrs Encoding(StringPiece x) {
957
+ return Attrs().Encoding(x);
958
+ }
959
+
960
+ Operation operation;
961
+ ::tensorflow::Output output;
962
+ };
963
+
964
+ /// Return substrings from `Tensor` of strings.
965
+ ///
966
+ /// For each string in the input `Tensor`, creates a substring starting at index
967
+ /// `pos` with a total length of `len`.
968
+ ///
969
+ /// If `len` defines a substring that would extend beyond the length of the input
970
+ /// string, or if `len` is negative, then as many characters as possible are used.
971
+ ///
972
+ /// A negative `pos` indicates distance within the string backwards from the end.
973
+ ///
974
+ /// If `pos` specifies an index which is out of range for any of the input strings,
975
+ /// then an `InvalidArgumentError` is thrown.
976
+ ///
977
+ /// `pos` and `len` must have the same shape, otherwise a `ValueError` is thrown on
978
+ /// Op creation.
979
+ ///
980
+ /// *NOTE*: `Substr` supports broadcasting up to two dimensions. More about
981
+ /// broadcasting
982
+ /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html)
983
+ ///
984
+ /// ---
985
+ ///
986
+ /// Examples
987
+ ///
988
+ /// Using scalar `pos` and `len`:
989
+ ///
990
+ /// ```python
991
+ /// input = [b'Hello', b'World']
992
+ /// position = 1
993
+ /// length = 3
994
+ ///
995
+ /// output = [b'ell', b'orl']
996
+ /// ```
997
+ ///
998
+ /// Using `pos` and `len` with same shape as `input`:
999
+ ///
1000
+ /// ```python
1001
+ /// input = [[b'ten', b'eleven', b'twelve'],
1002
+ /// [b'thirteen', b'fourteen', b'fifteen'],
1003
+ /// [b'sixteen', b'seventeen', b'eighteen']]
1004
+ /// position = [[1, 2, 3],
1005
+ /// [1, 2, 3],
1006
+ /// [1, 2, 3]]
1007
+ /// length = [[2, 3, 4],
1008
+ /// [4, 3, 2],
1009
+ /// [5, 5, 5]]
1010
+ ///
1011
+ /// output = [[b'en', b'eve', b'lve'],
1012
+ /// [b'hirt', b'urt', b'te'],
1013
+ /// [b'ixtee', b'vente', b'hteen']]
1014
+ /// ```
1015
+ ///
1016
+ /// Broadcasting `pos` and `len` onto `input`:
1017
+ ///
1018
+ /// ```
1019
+ /// input = [[b'ten', b'eleven', b'twelve'],
1020
+ /// [b'thirteen', b'fourteen', b'fifteen'],
1021
+ /// [b'sixteen', b'seventeen', b'eighteen'],
1022
+ /// [b'nineteen', b'twenty', b'twentyone']]
1023
+ /// position = [1, 2, 3]
1024
+ /// length = [1, 2, 3]
1025
+ ///
1026
+ /// output = [[b'e', b'ev', b'lve'],
1027
+ /// [b'h', b'ur', b'tee'],
1028
+ /// [b'i', b've', b'hte'],
1029
+ /// [b'i', b'en', b'nty']]
1030
+ /// ```
1031
+ ///
1032
+ /// Broadcasting `input` onto `pos` and `len`:
1033
+ ///
1034
+ /// ```
1035
+ /// input = b'thirteen'
1036
+ /// position = [1, 5, 7]
1037
+ /// length = [3, 2, 1]
1038
+ ///
1039
+ /// output = [b'hir', b'ee', b'n']
1040
+ /// ```
1041
+ ///
1042
+ /// Raises:
1043
+ ///
1044
+ /// * `ValueError`: If the first argument cannot be converted to a
1045
+ /// Tensor of `dtype string`.
1046
+ /// * `InvalidArgumentError`: If indices are out of range.
1047
+ /// * `ValueError`: If `pos` and `len` are not the same shape.
1048
+ ///
1049
+ ///
1050
+ /// Args:
1051
+ /// * scope: A Scope object
1052
+ /// * input: Tensor of strings
1053
+ /// * pos: Scalar defining the position of first character in each substring
1054
+ /// * len: Scalar defining the number of characters to include in each substring
1055
+ ///
1056
+ /// Optional attributes (see `Attrs`):
1057
+ /// * unit: The unit that is used to create the substring. One of: `"BYTE"` (for
1058
+ /// defining position and length by bytes) or `"UTF8_CHAR"` (for the UTF-8
1059
+ /// encoded Unicode code points). The default is `"BYTE"`. Results are undefined if
1060
+ /// `unit=UTF8_CHAR` and the `input` strings do not contain structurally valid
1061
+ /// UTF-8.
1062
+ ///
1063
+ /// Returns:
1064
+ /// * `Output`: Tensor of substrings
1065
+ class Substr {
1066
+ public:
1067
+ /// Optional attribute setters for Substr
1068
+ struct Attrs {
1069
+ /// The unit that is used to create the substring. One of: `"BYTE"` (for
1070
+ /// defining position and length by bytes) or `"UTF8_CHAR"` (for the UTF-8
1071
+ /// encoded Unicode code points). The default is `"BYTE"`. Results are undefined if
1072
+ /// `unit=UTF8_CHAR` and the `input` strings do not contain structurally valid
1073
+ /// UTF-8.
1074
+ ///
1075
+ /// Defaults to "BYTE"
1076
+ TF_MUST_USE_RESULT Attrs Unit(StringPiece x) {
1077
+ Attrs ret = *this;
1078
+ ret.unit_ = x;
1079
+ return ret;
1080
+ }
1081
+
1082
+ StringPiece unit_ = "BYTE";
1083
+ };
1084
+ Substr(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
1085
+ ::tensorflow::Input pos, ::tensorflow::Input len);
1086
+ Substr(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
1087
+ ::tensorflow::Input pos, ::tensorflow::Input len, const Substr::Attrs&
1088
+ attrs);
1089
+ operator ::tensorflow::Output() const { return output; }
1090
+ operator ::tensorflow::Input() const { return output; }
1091
+ ::tensorflow::Node* node() const { return output.node(); }
1092
+
1093
+ static Attrs Unit(StringPiece x) {
1094
+ return Attrs().Unit(x);
1095
+ }
1096
+
1097
+ Operation operation;
1098
+ ::tensorflow::Output output;
1099
+ };
1100
+
1101
+ /// Determine the script codes of a given tensor of Unicode integer code points.
1102
+ ///
1103
+ /// This operation converts Unicode code points to script codes corresponding to
1104
+ /// each code point. Script codes correspond to International Components for
1105
+ /// Unicode (ICU) UScriptCode values.
1106
+ ///
1107
+ /// See
1108
+ /// [ICU project docs](http://icu-project.org/apiref/icu4c/uscript_8h.html)
1109
+ /// for more details on script codes.
1110
+ ///
1111
+ /// For an example, see the unicode strings guide on [unicode scripts]
1112
+ /// (https://www.tensorflow.org/tutorials/load_data/unicode#representing_unicode).
1113
+ ///
1114
+ /// Returns -1 (USCRIPT_INVALID_CODE) for invalid codepoints. Output shape will
1115
+ /// match input shape.
1116
+ ///
1117
+ /// Examples:
1118
+ ///
1119
+ /// >>> tf.strings.unicode_script([1, 31, 38])
1120
+ /// <tf.Tensor: shape=(3,), dtype=int32, numpy=array([0, 0, 0], dtype=int32)>
1121
+ ///
1122
+ /// Args:
1123
+ /// * scope: A Scope object
1124
+ /// * input: A Tensor of int32 Unicode code points.
1125
+ ///
1126
+ /// Returns:
1127
+ /// * `Output`: A Tensor of int32 script codes corresponding to each input code point.
1128
+ class UnicodeScript {
1129
+ public:
1130
+ UnicodeScript(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
1131
+ operator ::tensorflow::Output() const { return output; }
1132
+ operator ::tensorflow::Input() const { return output; }
1133
+ ::tensorflow::Node* node() const { return output.node(); }
1134
+
1135
+ Operation operation;
1136
+ ::tensorflow::Output output;
1137
+ };
1138
+
1139
+ /// Transcode the input text from a source encoding to a destination encoding.
1140
+ ///
1141
+ /// The input is a string tensor of any shape. The output is a string tensor of
1142
+ /// the same shape containing the transcoded strings. Output strings are always
1143
+ /// valid unicode. If the input contains invalid encoding positions, the
1144
+ /// `errors` attribute sets the policy for how to deal with them. If the default
1145
+ /// error-handling policy is used, invalid formatting will be substituted in the
1146
+ /// output by the `replacement_char`. If the errors policy is to `ignore`, any
1147
+ /// invalid encoding positions in the input are skipped and not included in the
1148
+ /// output. If it set to `strict` then any invalid formatting will result in an
1149
+ /// InvalidArgument error.
1150
+ ///
1151
+ /// This operation can be used with `output_encoding = input_encoding` to enforce
1152
+ /// correct formatting for inputs even if they are already in the desired encoding.
1153
+ ///
1154
+ /// If the input is prefixed by a Byte Order Mark needed to determine encoding
1155
+ /// (e.g. if the encoding is UTF-16 and the BOM indicates big-endian), then that
1156
+ /// BOM will be consumed and not emitted into the output. If the input encoding
1157
+ /// is marked with an explicit endianness (e.g. UTF-16-BE), then the BOM is
1158
+ /// interpreted as a non-breaking-space and is preserved in the output (including
1159
+ /// always for UTF-8).
1160
+ ///
1161
+ /// The end result is that if the input is marked as an explicit endianness the
1162
+ /// transcoding is faithful to all codepoints in the source. If it is not marked
1163
+ /// with an explicit endianness, the BOM is not considered part of the string itself
1164
+ /// but as metadata, and so is not preserved in the output.
1165
+ ///
1166
+ /// Examples:
1167
+ ///
1168
+ /// >>> tf.strings.unicode_transcode(["Hello", "TensorFlow", "2.x"], "UTF-8", "UTF-16-BE")
1169
+ /// <tf.Tensor: shape=(3,), dtype=string, numpy=
1170
+ /// array([b'\x00H\x00e\x00l\x00l\x00o',
1171
+ /// b'\x00T\x00e\x00n\x00s\x00o\x00r\x00F\x00l\x00o\x00w',
1172
+ /// b'\x002\x00.\x00x'], dtype=object)>
1173
+ /// >>> tf.strings.unicode_transcode(["A", "B", "C"], "US ASCII", "UTF-8").numpy()
1174
+ /// array([b'A', b'B', b'C'], dtype=object)
1175
+ ///
1176
+ /// Args:
1177
+ /// * scope: A Scope object
1178
+ /// * input: The text to be processed. Can have any shape.
1179
+ /// * input_encoding: Text encoding of the input strings. This is any of the encodings supported
1180
+ /// by ICU ucnv algorithmic converters. Examples: `"UTF-16", "US ASCII", "UTF-8"`.
1181
+ /// * output_encoding: The unicode encoding to use in the output. Must be one of
1182
+ /// `"UTF-8", "UTF-16-BE", "UTF-32-BE"`. Multi-byte encodings will be big-endian.
1183
+ ///
1184
+ /// Optional attributes (see `Attrs`):
1185
+ /// * errors: Error handling policy when there is invalid formatting found in the input.
1186
+ /// The value of 'strict' will cause the operation to produce a InvalidArgument
1187
+ /// error on any invalid input formatting. A value of 'replace' (the default) will
1188
+ /// cause the operation to replace any invalid formatting in the input with the
1189
+ /// `replacement_char` codepoint. A value of 'ignore' will cause the operation to
1190
+ /// skip any invalid formatting in the input and produce no corresponding output
1191
+ /// character.
1192
+ /// * replacement_char: The replacement character codepoint to be used in place of any invalid
1193
+ /// formatting in the input when `errors='replace'`. Any valid unicode codepoint may
1194
+ /// be used. The default value is the default unicode replacement character is
1195
+ /// 0xFFFD or U+65533.)
1196
+ ///
1197
+ /// Note that for UTF-8, passing a replacement character expressible in 1 byte, such
1198
+ /// as ' ', will preserve string alignment to the source since invalid bytes will be
1199
+ /// replaced with a 1-byte replacement. For UTF-16-BE and UTF-16-LE, any 1 or 2 byte
1200
+ /// replacement character will preserve byte alignment to the source.
1201
+ /// * replace_control_characters: Whether to replace the C0 control characters (00-1F) with the
1202
+ /// `replacement_char`. Default is false.
1203
+ ///
1204
+ /// Returns:
1205
+ /// * `Output`: A string tensor containing unicode text encoded using `output_encoding`.
1206
+ class UnicodeTranscode {
1207
+ public:
1208
+ /// Optional attribute setters for UnicodeTranscode
1209
+ struct Attrs {
1210
+ /// Error handling policy when there is invalid formatting found in the input.
1211
+ /// The value of 'strict' will cause the operation to produce a InvalidArgument
1212
+ /// error on any invalid input formatting. A value of 'replace' (the default) will
1213
+ /// cause the operation to replace any invalid formatting in the input with the
1214
+ /// `replacement_char` codepoint. A value of 'ignore' will cause the operation to
1215
+ /// skip any invalid formatting in the input and produce no corresponding output
1216
+ /// character.
1217
+ ///
1218
+ /// Defaults to "replace"
1219
+ TF_MUST_USE_RESULT Attrs Errors(StringPiece x) {
1220
+ Attrs ret = *this;
1221
+ ret.errors_ = x;
1222
+ return ret;
1223
+ }
1224
+
1225
+ /// The replacement character codepoint to be used in place of any invalid
1226
+ /// formatting in the input when `errors='replace'`. Any valid unicode codepoint may
1227
+ /// be used. The default value is the default unicode replacement character is
1228
+ /// 0xFFFD or U+65533.)
1229
+ ///
1230
+ /// Note that for UTF-8, passing a replacement character expressible in 1 byte, such
1231
+ /// as ' ', will preserve string alignment to the source since invalid bytes will be
1232
+ /// replaced with a 1-byte replacement. For UTF-16-BE and UTF-16-LE, any 1 or 2 byte
1233
+ /// replacement character will preserve byte alignment to the source.
1234
+ ///
1235
+ /// Defaults to 65533
1236
+ TF_MUST_USE_RESULT Attrs ReplacementChar(int64 x) {
1237
+ Attrs ret = *this;
1238
+ ret.replacement_char_ = x;
1239
+ return ret;
1240
+ }
1241
+
1242
+ /// Whether to replace the C0 control characters (00-1F) with the
1243
+ /// `replacement_char`. Default is false.
1244
+ ///
1245
+ /// Defaults to false
1246
+ TF_MUST_USE_RESULT Attrs ReplaceControlCharacters(bool x) {
1247
+ Attrs ret = *this;
1248
+ ret.replace_control_characters_ = x;
1249
+ return ret;
1250
+ }
1251
+
1252
+ StringPiece errors_ = "replace";
1253
+ int64 replacement_char_ = 65533;
1254
+ bool replace_control_characters_ = false;
1255
+ };
1256
+ UnicodeTranscode(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
1257
+ StringPiece input_encoding, StringPiece output_encoding);
1258
+ UnicodeTranscode(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
1259
+ StringPiece input_encoding, StringPiece output_encoding, const
1260
+ UnicodeTranscode::Attrs& attrs);
1261
+ operator ::tensorflow::Output() const { return output; }
1262
+ operator ::tensorflow::Input() const { return output; }
1263
+ ::tensorflow::Node* node() const { return output.node(); }
1264
+
1265
+ static Attrs Errors(StringPiece x) {
1266
+ return Attrs().Errors(x);
1267
+ }
1268
+ static Attrs ReplacementChar(int64 x) {
1269
+ return Attrs().ReplacementChar(x);
1270
+ }
1271
+ static Attrs ReplaceControlCharacters(bool x) {
1272
+ return Attrs().ReplaceControlCharacters(x);
1273
+ }
1274
+
1275
+ Operation operation;
1276
+ ::tensorflow::Output output;
1277
+ };
1278
+
1279
+ /// @}
1280
+
1281
+ } // namespace ops
1282
+ } // namespace tensorflow
1283
+
1284
+ #endif // TENSORFLOW_CC_OPS_STRING_OPS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/string_ops_internal.h ADDED
@@ -0,0 +1,483 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_STRING_OPS_INTERNAL_H_
4
+ #define TENSORFLOW_CC_OPS_STRING_OPS_INTERNAL_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
+ namespace internal {
18
+ // NOTE: This namespace has internal TensorFlow details that
19
+ // are not part of TensorFlow's public API.
20
+
21
+ /// @defgroup string_ops_internal String Ops Internal
22
+ /// @{
23
+
24
+ /// Check if the input matches the regex pattern.
25
+ ///
26
+ /// The input is a string tensor of any shape. The pattern is the
27
+ /// regular expression to be matched with every element of the input tensor.
28
+ /// The boolean values (True or False) of the output tensor indicate
29
+ /// if the input matches the regex pattern provided.
30
+ ///
31
+ /// The pattern follows the re2 syntax (https://github.com/google/re2/wiki/Syntax)
32
+ ///
33
+ /// Args:
34
+ /// * scope: A Scope object
35
+ /// * input: A string tensor of the text to be processed.
36
+ /// * pattern: The regular expression to match the input.
37
+ ///
38
+ /// Returns:
39
+ /// * `Output`: A bool tensor with the same shape as `input`.
40
+ class StaticRegexFullMatch {
41
+ public:
42
+ StaticRegexFullMatch(const ::tensorflow::Scope& scope, ::tensorflow::Input
43
+ input, StringPiece pattern);
44
+ operator ::tensorflow::Output() const { return output; }
45
+ operator ::tensorflow::Input() const { return output; }
46
+ ::tensorflow::Node* node() const { return output.node(); }
47
+
48
+ Operation operation;
49
+ ::tensorflow::Output output;
50
+ };
51
+
52
+ /// Replaces the match of pattern in input with rewrite.
53
+ ///
54
+ /// It follows the re2 syntax (https://github.com/google/re2/wiki/Syntax)
55
+ ///
56
+ /// Args:
57
+ /// * scope: A Scope object
58
+ /// * input: The text to be processed.
59
+ /// * pattern: The regular expression to match the input.
60
+ /// * rewrite: The rewrite to be applied to the matched expression.
61
+ ///
62
+ /// Optional attributes (see `Attrs`):
63
+ /// * replace_global: If True, the replacement is global, otherwise the replacement
64
+ /// is done only on the first match.
65
+ ///
66
+ /// Returns:
67
+ /// * `Output`: The text after applying pattern and rewrite.
68
+ class StaticRegexReplace {
69
+ public:
70
+ /// Optional attribute setters for StaticRegexReplace
71
+ struct Attrs {
72
+ /// If True, the replacement is global, otherwise the replacement
73
+ /// is done only on the first match.
74
+ ///
75
+ /// Defaults to true
76
+ TF_MUST_USE_RESULT Attrs ReplaceGlobal(bool x) {
77
+ Attrs ret = *this;
78
+ ret.replace_global_ = x;
79
+ return ret;
80
+ }
81
+
82
+ bool replace_global_ = true;
83
+ };
84
+ StaticRegexReplace(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
85
+ StringPiece pattern, StringPiece rewrite);
86
+ StaticRegexReplace(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
87
+ StringPiece pattern, StringPiece rewrite, const
88
+ StaticRegexReplace::Attrs& attrs);
89
+ operator ::tensorflow::Output() const { return output; }
90
+ operator ::tensorflow::Input() const { return output; }
91
+ ::tensorflow::Node* node() const { return output.node(); }
92
+
93
+ static Attrs ReplaceGlobal(bool x) {
94
+ return Attrs().ReplaceGlobal(x);
95
+ }
96
+
97
+ Operation operation;
98
+ ::tensorflow::Output output;
99
+ };
100
+
101
+ /// Decodes each string in `input` into a sequence of Unicode code points.
102
+ ///
103
+ /// The character codepoints for all strings are returned using a single vector
104
+ /// `char_values`, with strings expanded to characters in row-major order.
105
+ ///
106
+ /// The `row_splits` tensor indicates where the codepoints for
107
+ /// each input string begin and end within the `char_values` tensor.
108
+ /// In particular, the values for the `i`th
109
+ /// string (in row-major order) are stored in the slice
110
+ /// `[row_splits[i]:row_splits[i+1]]`. Thus:
111
+ ///
112
+ /// * `char_values[row_splits[i]+j]` is the Unicode codepoint for the `j`th
113
+ /// character in the `i`th string (in row-major order).
114
+ /// * `row_splits[i+1] - row_splits[i]` is the number of characters in the `i`th
115
+ /// string (in row-major order).
116
+ ///
117
+ /// Args:
118
+ /// * scope: A Scope object
119
+ /// * input: The text to be decoded. Can have any shape. Note that the output is flattened
120
+ /// to a vector of char values.
121
+ /// * input_encoding: Text encoding of the input strings. This is any of the encodings supported
122
+ /// by ICU ucnv algorithmic converters. Examples: `"UTF-16", "US ASCII", "UTF-8"`.
123
+ ///
124
+ /// Optional attributes (see `Attrs`):
125
+ /// * errors: Error handling policy when there is invalid formatting found in the input.
126
+ /// The value of 'strict' will cause the operation to produce a InvalidArgument
127
+ /// error on any invalid input formatting. A value of 'replace' (the default) will
128
+ /// cause the operation to replace any invalid formatting in the input with the
129
+ /// `replacement_char` codepoint. A value of 'ignore' will cause the operation to
130
+ /// skip any invalid formatting in the input and produce no corresponding output
131
+ /// character.
132
+ /// * replacement_char: The replacement character codepoint to be used in place of any invalid
133
+ /// formatting in the input when `errors='replace'`. Any valid unicode codepoint may
134
+ /// be used. The default value is the default unicode replacement character is
135
+ /// 0xFFFD or U+65533.)
136
+ /// * replace_control_characters: Whether to replace the C0 control characters (00-1F) with the
137
+ /// `replacement_char`. Default is false.
138
+ ///
139
+ /// Returns:
140
+ /// * `Output` row_splits: A 1D int32 tensor containing the row splits.
141
+ /// * `Output` char_values: A 1D int32 Tensor containing the decoded codepoints.
142
+ class UnicodeDecode {
143
+ public:
144
+ /// Optional attribute setters for UnicodeDecode
145
+ struct Attrs {
146
+ /// Error handling policy when there is invalid formatting found in the input.
147
+ /// The value of 'strict' will cause the operation to produce a InvalidArgument
148
+ /// error on any invalid input formatting. A value of 'replace' (the default) will
149
+ /// cause the operation to replace any invalid formatting in the input with the
150
+ /// `replacement_char` codepoint. A value of 'ignore' will cause the operation to
151
+ /// skip any invalid formatting in the input and produce no corresponding output
152
+ /// character.
153
+ ///
154
+ /// Defaults to "replace"
155
+ TF_MUST_USE_RESULT Attrs Errors(StringPiece x) {
156
+ Attrs ret = *this;
157
+ ret.errors_ = x;
158
+ return ret;
159
+ }
160
+
161
+ /// The replacement character codepoint to be used in place of any invalid
162
+ /// formatting in the input when `errors='replace'`. Any valid unicode codepoint may
163
+ /// be used. The default value is the default unicode replacement character is
164
+ /// 0xFFFD or U+65533.)
165
+ ///
166
+ /// Defaults to 65533
167
+ TF_MUST_USE_RESULT Attrs ReplacementChar(int64 x) {
168
+ Attrs ret = *this;
169
+ ret.replacement_char_ = x;
170
+ return ret;
171
+ }
172
+
173
+ /// Whether to replace the C0 control characters (00-1F) with the
174
+ /// `replacement_char`. Default is false.
175
+ ///
176
+ /// Defaults to false
177
+ TF_MUST_USE_RESULT Attrs ReplaceControlCharacters(bool x) {
178
+ Attrs ret = *this;
179
+ ret.replace_control_characters_ = x;
180
+ return ret;
181
+ }
182
+
183
+ /// Defaults to DT_INT64
184
+ TF_MUST_USE_RESULT Attrs Tsplits(DataType x) {
185
+ Attrs ret = *this;
186
+ ret.Tsplits_ = x;
187
+ return ret;
188
+ }
189
+
190
+ StringPiece errors_ = "replace";
191
+ int64 replacement_char_ = 65533;
192
+ bool replace_control_characters_ = false;
193
+ DataType Tsplits_ = DT_INT64;
194
+ };
195
+ UnicodeDecode(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
196
+ StringPiece input_encoding);
197
+ UnicodeDecode(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
198
+ StringPiece input_encoding, const UnicodeDecode::Attrs& attrs);
199
+
200
+ static Attrs Errors(StringPiece x) {
201
+ return Attrs().Errors(x);
202
+ }
203
+ static Attrs ReplacementChar(int64 x) {
204
+ return Attrs().ReplacementChar(x);
205
+ }
206
+ static Attrs ReplaceControlCharacters(bool x) {
207
+ return Attrs().ReplaceControlCharacters(x);
208
+ }
209
+ static Attrs Tsplits(DataType x) {
210
+ return Attrs().Tsplits(x);
211
+ }
212
+
213
+ Operation operation;
214
+ ::tensorflow::Output row_splits;
215
+ ::tensorflow::Output char_values;
216
+ };
217
+
218
+ /// Decodes each string in `input` into a sequence of Unicode code points.
219
+ ///
220
+ /// The character codepoints for all strings are returned using a single vector
221
+ /// `char_values`, with strings expanded to characters in row-major order.
222
+ /// Similarly, the character start byte offsets are returned using a single vector
223
+ /// `char_to_byte_starts`, with strings expanded in row-major order.
224
+ ///
225
+ /// The `row_splits` tensor indicates where the codepoints and start offsets for
226
+ /// each input string begin and end within the `char_values` and
227
+ /// `char_to_byte_starts` tensors. In particular, the values for the `i`th
228
+ /// string (in row-major order) are stored in the slice
229
+ /// `[row_splits[i]:row_splits[i+1]]`. Thus:
230
+ ///
231
+ /// * `char_values[row_splits[i]+j]` is the Unicode codepoint for the `j`th
232
+ /// character in the `i`th string (in row-major order).
233
+ /// * `char_to_bytes_starts[row_splits[i]+j]` is the start byte offset for the `j`th
234
+ /// character in the `i`th string (in row-major order).
235
+ /// * `row_splits[i+1] - row_splits[i]` is the number of characters in the `i`th
236
+ /// string (in row-major order).
237
+ ///
238
+ /// Args:
239
+ /// * scope: A Scope object
240
+ /// * input: The text to be decoded. Can have any shape. Note that the output is flattened
241
+ /// to a vector of char values.
242
+ /// * input_encoding: Text encoding of the input strings. This is any of the encodings supported
243
+ /// by ICU ucnv algorithmic converters. Examples: `"UTF-16", "US ASCII", "UTF-8"`.
244
+ ///
245
+ /// Optional attributes (see `Attrs`):
246
+ /// * errors: Error handling policy when there is invalid formatting found in the input.
247
+ /// The value of 'strict' will cause the operation to produce a InvalidArgument
248
+ /// error on any invalid input formatting. A value of 'replace' (the default) will
249
+ /// cause the operation to replace any invalid formatting in the input with the
250
+ /// `replacement_char` codepoint. A value of 'ignore' will cause the operation to
251
+ /// skip any invalid formatting in the input and produce no corresponding output
252
+ /// character.
253
+ /// * replacement_char: The replacement character codepoint to be used in place of any invalid
254
+ /// formatting in the input when `errors='replace'`. Any valid unicode codepoint may
255
+ /// be used. The default value is the default unicode replacement character is
256
+ /// 0xFFFD or U+65533.)
257
+ /// * replace_control_characters: Whether to replace the C0 control characters (00-1F) with the
258
+ /// `replacement_char`. Default is false.
259
+ ///
260
+ /// Returns:
261
+ /// * `Output` row_splits: A 1D int32 tensor containing the row splits.
262
+ /// * `Output` char_values: A 1D int32 Tensor containing the decoded codepoints.
263
+ /// * `Output` char_to_byte_starts: A 1D int32 Tensor containing the byte index in the input string where each
264
+ /// character in `char_values` starts.
265
+ class UnicodeDecodeWithOffsets {
266
+ public:
267
+ /// Optional attribute setters for UnicodeDecodeWithOffsets
268
+ struct Attrs {
269
+ /// Error handling policy when there is invalid formatting found in the input.
270
+ /// The value of 'strict' will cause the operation to produce a InvalidArgument
271
+ /// error on any invalid input formatting. A value of 'replace' (the default) will
272
+ /// cause the operation to replace any invalid formatting in the input with the
273
+ /// `replacement_char` codepoint. A value of 'ignore' will cause the operation to
274
+ /// skip any invalid formatting in the input and produce no corresponding output
275
+ /// character.
276
+ ///
277
+ /// Defaults to "replace"
278
+ TF_MUST_USE_RESULT Attrs Errors(StringPiece x) {
279
+ Attrs ret = *this;
280
+ ret.errors_ = x;
281
+ return ret;
282
+ }
283
+
284
+ /// The replacement character codepoint to be used in place of any invalid
285
+ /// formatting in the input when `errors='replace'`. Any valid unicode codepoint may
286
+ /// be used. The default value is the default unicode replacement character is
287
+ /// 0xFFFD or U+65533.)
288
+ ///
289
+ /// Defaults to 65533
290
+ TF_MUST_USE_RESULT Attrs ReplacementChar(int64 x) {
291
+ Attrs ret = *this;
292
+ ret.replacement_char_ = x;
293
+ return ret;
294
+ }
295
+
296
+ /// Whether to replace the C0 control characters (00-1F) with the
297
+ /// `replacement_char`. Default is false.
298
+ ///
299
+ /// Defaults to false
300
+ TF_MUST_USE_RESULT Attrs ReplaceControlCharacters(bool x) {
301
+ Attrs ret = *this;
302
+ ret.replace_control_characters_ = x;
303
+ return ret;
304
+ }
305
+
306
+ /// Defaults to DT_INT64
307
+ TF_MUST_USE_RESULT Attrs Tsplits(DataType x) {
308
+ Attrs ret = *this;
309
+ ret.Tsplits_ = x;
310
+ return ret;
311
+ }
312
+
313
+ StringPiece errors_ = "replace";
314
+ int64 replacement_char_ = 65533;
315
+ bool replace_control_characters_ = false;
316
+ DataType Tsplits_ = DT_INT64;
317
+ };
318
+ UnicodeDecodeWithOffsets(const ::tensorflow::Scope& scope, ::tensorflow::Input
319
+ input, StringPiece input_encoding);
320
+ UnicodeDecodeWithOffsets(const ::tensorflow::Scope& scope, ::tensorflow::Input
321
+ input, StringPiece input_encoding, const
322
+ UnicodeDecodeWithOffsets::Attrs& attrs);
323
+
324
+ static Attrs Errors(StringPiece x) {
325
+ return Attrs().Errors(x);
326
+ }
327
+ static Attrs ReplacementChar(int64 x) {
328
+ return Attrs().ReplacementChar(x);
329
+ }
330
+ static Attrs ReplaceControlCharacters(bool x) {
331
+ return Attrs().ReplaceControlCharacters(x);
332
+ }
333
+ static Attrs Tsplits(DataType x) {
334
+ return Attrs().Tsplits(x);
335
+ }
336
+
337
+ Operation operation;
338
+ ::tensorflow::Output row_splits;
339
+ ::tensorflow::Output char_values;
340
+ ::tensorflow::Output char_to_byte_starts;
341
+ };
342
+
343
+ /// Encode a tensor of ints into unicode strings.
344
+ ///
345
+ /// Returns a vector of strings, where `output[i]` is constructed by encoding the
346
+ /// Unicode codepoints in `input_values[input_splits[i]:input_splits[i+1]]`
347
+ /// using `output_encoding`.
348
+ ///
349
+ /// ---
350
+ ///
351
+ /// Example:
352
+ ///
353
+ /// ```
354
+ /// input_values = [72, 101, 108, 108, 111, 87, 111, 114, 108, 100]
355
+ /// input_splits = [0, 5, 10]
356
+ /// output_encoding = 'UTF-8'
357
+ ///
358
+ /// output = ['Hello', 'World']
359
+ /// ```
360
+ ///
361
+ /// Args:
362
+ /// * scope: A Scope object
363
+ /// * input_values: A 1D tensor containing the unicode codepoints that should be encoded.
364
+ /// * input_splits: A 1D tensor specifying how the unicode codepoints should be split into strings.
365
+ /// In particular, `output[i]` is constructed by encoding the codepoints in the
366
+ /// slice `input_values[input_splits[i]:input_splits[i+1]]`.
367
+ /// * output_encoding: Unicode encoding of the output strings. Valid encodings are: `"UTF-8",
368
+ /// "UTF-16-BE", and "UTF-32-BE"`.
369
+ ///
370
+ /// Optional attributes (see `Attrs`):
371
+ /// * errors: Error handling policy when there is invalid formatting found in the input.
372
+ /// The value of 'strict' will cause the operation to produce a InvalidArgument
373
+ /// error on any invalid input formatting. A value of 'replace' (the default) will
374
+ /// cause the operation to replace any invalid formatting in the input with the
375
+ /// `replacement_char` codepoint. A value of 'ignore' will cause the operation to
376
+ /// skip any invalid formatting in the input and produce no corresponding output
377
+ /// character.
378
+ /// * replacement_char: The replacement character codepoint to be used in place of any invalid
379
+ /// formatting in the input when `errors='replace'`. Any valid unicode codepoint may
380
+ /// be used. The default value is the default unicode replacement character is
381
+ /// 0xFFFD (U+65533).
382
+ ///
383
+ /// Returns:
384
+ /// * `Output`: The 1-D Tensor of strings encoded from the provided unicode codepoints.
385
+ class UnicodeEncode {
386
+ public:
387
+ /// Optional attribute setters for UnicodeEncode
388
+ struct Attrs {
389
+ /// Error handling policy when there is invalid formatting found in the input.
390
+ /// The value of 'strict' will cause the operation to produce a InvalidArgument
391
+ /// error on any invalid input formatting. A value of 'replace' (the default) will
392
+ /// cause the operation to replace any invalid formatting in the input with the
393
+ /// `replacement_char` codepoint. A value of 'ignore' will cause the operation to
394
+ /// skip any invalid formatting in the input and produce no corresponding output
395
+ /// character.
396
+ ///
397
+ /// Defaults to "replace"
398
+ TF_MUST_USE_RESULT Attrs Errors(StringPiece x) {
399
+ Attrs ret = *this;
400
+ ret.errors_ = x;
401
+ return ret;
402
+ }
403
+
404
+ /// The replacement character codepoint to be used in place of any invalid
405
+ /// formatting in the input when `errors='replace'`. Any valid unicode codepoint may
406
+ /// be used. The default value is the default unicode replacement character is
407
+ /// 0xFFFD (U+65533).
408
+ ///
409
+ /// Defaults to 65533
410
+ TF_MUST_USE_RESULT Attrs ReplacementChar(int64 x) {
411
+ Attrs ret = *this;
412
+ ret.replacement_char_ = x;
413
+ return ret;
414
+ }
415
+
416
+ StringPiece errors_ = "replace";
417
+ int64 replacement_char_ = 65533;
418
+ };
419
+ UnicodeEncode(const ::tensorflow::Scope& scope, ::tensorflow::Input
420
+ input_values, ::tensorflow::Input input_splits, StringPiece
421
+ output_encoding);
422
+ UnicodeEncode(const ::tensorflow::Scope& scope, ::tensorflow::Input
423
+ input_values, ::tensorflow::Input input_splits, StringPiece
424
+ output_encoding, const UnicodeEncode::Attrs& attrs);
425
+ operator ::tensorflow::Output() const { return output; }
426
+ operator ::tensorflow::Input() const { return output; }
427
+ ::tensorflow::Node* node() const { return output.node(); }
428
+
429
+ static Attrs Errors(StringPiece x) {
430
+ return Attrs().Errors(x);
431
+ }
432
+ static Attrs ReplacementChar(int64 x) {
433
+ return Attrs().ReplacementChar(x);
434
+ }
435
+
436
+ Operation operation;
437
+ ::tensorflow::Output output;
438
+ };
439
+
440
+ /// TODO: add doc.
441
+ ///
442
+ /// Args:
443
+ /// * scope: A Scope object
444
+ ///
445
+ /// Returns:
446
+ /// * `Output`: The output tensor.
447
+ class UnsortedSegmentJoin {
448
+ public:
449
+ /// Optional attribute setters for UnsortedSegmentJoin
450
+ struct Attrs {
451
+ /// Defaults to ""
452
+ TF_MUST_USE_RESULT Attrs Separator(StringPiece x) {
453
+ Attrs ret = *this;
454
+ ret.separator_ = x;
455
+ return ret;
456
+ }
457
+
458
+ StringPiece separator_ = "";
459
+ };
460
+ UnsortedSegmentJoin(const ::tensorflow::Scope& scope, ::tensorflow::Input
461
+ inputs, ::tensorflow::Input segment_ids,
462
+ ::tensorflow::Input num_segments);
463
+ UnsortedSegmentJoin(const ::tensorflow::Scope& scope, ::tensorflow::Input
464
+ inputs, ::tensorflow::Input segment_ids,
465
+ ::tensorflow::Input num_segments, const
466
+ UnsortedSegmentJoin::Attrs& attrs);
467
+ operator ::tensorflow::Output() const { return output; }
468
+ operator ::tensorflow::Input() const { return output; }
469
+ ::tensorflow::Node* node() const { return output.node(); }
470
+
471
+ static Attrs Separator(StringPiece x) {
472
+ return Attrs().Separator(x);
473
+ }
474
+
475
+ Operation operation;
476
+ ::tensorflow::Output output;
477
+ };
478
+
479
+ } // namespace internal
480
+ } // namespace ops
481
+ } // namespace tensorflow
482
+
483
+ #endif // TENSORFLOW_CC_OPS_STRING_OPS_INTERNAL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/training_ops.h ADDED
The diff for this file is too large to render. See raw diff
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/training_ops_internal.h ADDED
@@ -0,0 +1,426 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_TRAINING_OPS_INTERNAL_H_
4
+ #define TENSORFLOW_CC_OPS_TRAINING_OPS_INTERNAL_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
+ namespace internal {
18
+ // NOTE: This namespace has internal TensorFlow details that
19
+ // are not part of TensorFlow's public API.
20
+
21
+ /// @defgroup training_ops_internal Training Ops Internal
22
+ /// @{
23
+
24
+ /// Update '*var' according to the AdaMax algorithm.
25
+ ///
26
+ /// m_t <- beta1 * m_{t-1} + (1 - beta1) * g
27
+ /// v_t <- max(beta2 * v_{t-1}, abs(g))
28
+ /// variable <- variable - learning_rate / (1 - beta1^t) * m_t / (v_t + epsilon)
29
+ ///
30
+ /// Args:
31
+ /// * scope: A Scope object
32
+ /// * var: Should be from a Variable().
33
+ /// * m: Should be from a Variable().
34
+ /// * v: Should be from a Variable().
35
+ /// * beta1_power: Must be a scalar.
36
+ /// * lr: Scaling factor. Must be a scalar.
37
+ /// * beta1: Momentum factor. Must be a scalar.
38
+ /// * beta2: Momentum factor. Must be a scalar.
39
+ /// * epsilon: Ridge term. Must be a scalar.
40
+ /// * grad: The gradient.
41
+ ///
42
+ /// Optional attributes (see `Attrs`):
43
+ /// * use_locking: If `True`, updating of the var, m, and v tensors will be protected
44
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
45
+ /// contention.
46
+ ///
47
+ /// Returns:
48
+ /// * `Output`: Same as "var".
49
+ class ApplyAdaMax {
50
+ public:
51
+ /// Optional attribute setters for ApplyAdaMax
52
+ struct Attrs {
53
+ /// If `True`, updating of the var, m, and v tensors will be protected
54
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
55
+ /// contention.
56
+ ///
57
+ /// Defaults to false
58
+ TF_MUST_USE_RESULT Attrs UseLocking(bool x) {
59
+ Attrs ret = *this;
60
+ ret.use_locking_ = x;
61
+ return ret;
62
+ }
63
+
64
+ bool use_locking_ = false;
65
+ };
66
+ ApplyAdaMax(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
67
+ ::tensorflow::Input m, ::tensorflow::Input v, ::tensorflow::Input
68
+ beta1_power, ::tensorflow::Input lr, ::tensorflow::Input beta1,
69
+ ::tensorflow::Input beta2, ::tensorflow::Input epsilon,
70
+ ::tensorflow::Input grad);
71
+ ApplyAdaMax(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
72
+ ::tensorflow::Input m, ::tensorflow::Input v, ::tensorflow::Input
73
+ beta1_power, ::tensorflow::Input lr, ::tensorflow::Input beta1,
74
+ ::tensorflow::Input beta2, ::tensorflow::Input epsilon,
75
+ ::tensorflow::Input grad, const ApplyAdaMax::Attrs& attrs);
76
+ operator ::tensorflow::Output() const { return out; }
77
+ operator ::tensorflow::Input() const { return out; }
78
+ ::tensorflow::Node* node() const { return out.node(); }
79
+
80
+ static Attrs UseLocking(bool x) {
81
+ return Attrs().UseLocking(x);
82
+ }
83
+
84
+ Operation operation;
85
+ ::tensorflow::Output out;
86
+ };
87
+
88
+ /// Update '*var' according to the adagrad scheme.
89
+ ///
90
+ /// accum += grad * grad
91
+ /// var -= lr * grad * (1 / sqrt(accum))
92
+ ///
93
+ /// Args:
94
+ /// * scope: A Scope object
95
+ /// * var: Should be from a Variable().
96
+ /// * accum: Should be from a Variable().
97
+ /// * lr: Scaling factor. Must be a scalar.
98
+ /// * epsilon: Constant factor. Must be a scalar.
99
+ /// * grad: The gradient.
100
+ ///
101
+ /// Optional attributes (see `Attrs`):
102
+ /// * use_locking: If `True`, updating of the var and accum tensors will be protected
103
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
104
+ /// contention.
105
+ ///
106
+ /// Returns:
107
+ /// * `Output`: Same as "var".
108
+ class ApplyAdagradV2 {
109
+ public:
110
+ /// Optional attribute setters for ApplyAdagradV2
111
+ struct Attrs {
112
+ /// If `True`, updating of the var and accum tensors will be protected
113
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
114
+ /// contention.
115
+ ///
116
+ /// Defaults to false
117
+ TF_MUST_USE_RESULT Attrs UseLocking(bool x) {
118
+ Attrs ret = *this;
119
+ ret.use_locking_ = x;
120
+ return ret;
121
+ }
122
+
123
+ /// Defaults to true
124
+ TF_MUST_USE_RESULT Attrs UpdateSlots(bool x) {
125
+ Attrs ret = *this;
126
+ ret.update_slots_ = x;
127
+ return ret;
128
+ }
129
+
130
+ bool use_locking_ = false;
131
+ bool update_slots_ = true;
132
+ };
133
+ ApplyAdagradV2(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
134
+ ::tensorflow::Input accum, ::tensorflow::Input lr,
135
+ ::tensorflow::Input epsilon, ::tensorflow::Input grad);
136
+ ApplyAdagradV2(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
137
+ ::tensorflow::Input accum, ::tensorflow::Input lr,
138
+ ::tensorflow::Input epsilon, ::tensorflow::Input grad, const
139
+ ApplyAdagradV2::Attrs& attrs);
140
+ operator ::tensorflow::Output() const { return out; }
141
+ operator ::tensorflow::Input() const { return out; }
142
+ ::tensorflow::Node* node() const { return out.node(); }
143
+
144
+ static Attrs UseLocking(bool x) {
145
+ return Attrs().UseLocking(x);
146
+ }
147
+ static Attrs UpdateSlots(bool x) {
148
+ return Attrs().UpdateSlots(x);
149
+ }
150
+
151
+ Operation operation;
152
+ ::tensorflow::Output out;
153
+ };
154
+
155
+ /// Update '*var' according to the AdaMax algorithm.
156
+ ///
157
+ /// m_t <- beta1 * m_{t-1} + (1 - beta1) * g
158
+ /// v_t <- max(beta2 * v_{t-1}, abs(g))
159
+ /// variable <- variable - learning_rate / (1 - beta1^t) * m_t / (v_t + epsilon)
160
+ ///
161
+ /// Args:
162
+ /// * scope: A Scope object
163
+ /// * var: Should be from a Variable().
164
+ /// * m: Should be from a Variable().
165
+ /// * v: Should be from a Variable().
166
+ /// * beta1_power: Must be a scalar.
167
+ /// * lr: Scaling factor. Must be a scalar.
168
+ /// * beta1: Momentum factor. Must be a scalar.
169
+ /// * beta2: Momentum factor. Must be a scalar.
170
+ /// * epsilon: Ridge term. Must be a scalar.
171
+ /// * grad: The gradient.
172
+ ///
173
+ /// Optional attributes (see `Attrs`):
174
+ /// * use_locking: If `True`, updating of the var, m, and v tensors will be protected
175
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
176
+ /// contention.
177
+ ///
178
+ /// Returns:
179
+ /// * the created `Operation`
180
+ class ResourceApplyAdaMax {
181
+ public:
182
+ /// Optional attribute setters for ResourceApplyAdaMax
183
+ struct Attrs {
184
+ /// If `True`, updating of the var, m, and v tensors will be protected
185
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
186
+ /// contention.
187
+ ///
188
+ /// Defaults to false
189
+ TF_MUST_USE_RESULT Attrs UseLocking(bool x) {
190
+ Attrs ret = *this;
191
+ ret.use_locking_ = x;
192
+ return ret;
193
+ }
194
+
195
+ bool use_locking_ = false;
196
+ };
197
+ ResourceApplyAdaMax(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
198
+ ::tensorflow::Input m, ::tensorflow::Input v,
199
+ ::tensorflow::Input beta1_power, ::tensorflow::Input lr,
200
+ ::tensorflow::Input beta1, ::tensorflow::Input beta2,
201
+ ::tensorflow::Input epsilon, ::tensorflow::Input grad);
202
+ ResourceApplyAdaMax(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
203
+ ::tensorflow::Input m, ::tensorflow::Input v,
204
+ ::tensorflow::Input beta1_power, ::tensorflow::Input lr,
205
+ ::tensorflow::Input beta1, ::tensorflow::Input beta2,
206
+ ::tensorflow::Input epsilon, ::tensorflow::Input grad,
207
+ const ResourceApplyAdaMax::Attrs& attrs);
208
+ operator ::tensorflow::Operation() const { return operation; }
209
+
210
+ static Attrs UseLocking(bool x) {
211
+ return Attrs().UseLocking(x);
212
+ }
213
+
214
+ Operation operation;
215
+ };
216
+
217
+ /// Update '*var' according to the adagrad scheme.
218
+ ///
219
+ /// accum += grad * grad
220
+ /// var -= lr * grad * (1 / (sqrt(accum) + epsilon))
221
+ ///
222
+ /// Args:
223
+ /// * scope: A Scope object
224
+ /// * var: Should be from a Variable().
225
+ /// * accum: Should be from a Variable().
226
+ /// * lr: Scaling factor. Must be a scalar.
227
+ /// * epsilon: Constant factor. Must be a scalar.
228
+ /// * grad: The gradient.
229
+ ///
230
+ /// Optional attributes (see `Attrs`):
231
+ /// * use_locking: If `True`, updating of the var and accum tensors will be protected
232
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
233
+ /// contention.
234
+ ///
235
+ /// Returns:
236
+ /// * the created `Operation`
237
+ class ResourceApplyAdagradV2 {
238
+ public:
239
+ /// Optional attribute setters for ResourceApplyAdagradV2
240
+ struct Attrs {
241
+ /// If `True`, updating of the var and accum tensors will be protected
242
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
243
+ /// contention.
244
+ ///
245
+ /// Defaults to false
246
+ TF_MUST_USE_RESULT Attrs UseLocking(bool x) {
247
+ Attrs ret = *this;
248
+ ret.use_locking_ = x;
249
+ return ret;
250
+ }
251
+
252
+ /// Defaults to true
253
+ TF_MUST_USE_RESULT Attrs UpdateSlots(bool x) {
254
+ Attrs ret = *this;
255
+ ret.update_slots_ = x;
256
+ return ret;
257
+ }
258
+
259
+ bool use_locking_ = false;
260
+ bool update_slots_ = true;
261
+ };
262
+ ResourceApplyAdagradV2(const ::tensorflow::Scope& scope, ::tensorflow::Input
263
+ var, ::tensorflow::Input accum, ::tensorflow::Input lr,
264
+ ::tensorflow::Input epsilon, ::tensorflow::Input grad);
265
+ ResourceApplyAdagradV2(const ::tensorflow::Scope& scope, ::tensorflow::Input
266
+ var, ::tensorflow::Input accum, ::tensorflow::Input lr,
267
+ ::tensorflow::Input epsilon, ::tensorflow::Input grad,
268
+ const ResourceApplyAdagradV2::Attrs& attrs);
269
+ operator ::tensorflow::Operation() const { return operation; }
270
+
271
+ static Attrs UseLocking(bool x) {
272
+ return Attrs().UseLocking(x);
273
+ }
274
+ static Attrs UpdateSlots(bool x) {
275
+ return Attrs().UpdateSlots(x);
276
+ }
277
+
278
+ Operation operation;
279
+ };
280
+
281
+ /// Update relevant entries in '*var' and '*accum' according to the adagrad scheme.
282
+ ///
283
+ /// That is for rows we have grad for, we update var and accum as follows:
284
+ /// accum += grad * grad
285
+ /// var -= lr * grad * (1 / sqrt(accum))
286
+ ///
287
+ /// Args:
288
+ /// * scope: A Scope object
289
+ /// * var: Should be from a Variable().
290
+ /// * accum: Should be from a Variable().
291
+ /// * lr: Learning rate. Must be a scalar.
292
+ /// * epsilon: Constant factor. Must be a scalar.
293
+ /// * grad: The gradient.
294
+ /// * indices: A vector of indices into the first dimension of var and accum.
295
+ ///
296
+ /// Optional attributes (see `Attrs`):
297
+ /// * use_locking: If `True`, updating of the var and accum tensors will be protected
298
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
299
+ /// contention.
300
+ ///
301
+ /// Returns:
302
+ /// * the created `Operation`
303
+ class ResourceSparseApplyAdagradV2 {
304
+ public:
305
+ /// Optional attribute setters for ResourceSparseApplyAdagradV2
306
+ struct Attrs {
307
+ /// If `True`, updating of the var and accum tensors will be protected
308
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
309
+ /// contention.
310
+ ///
311
+ /// Defaults to false
312
+ TF_MUST_USE_RESULT Attrs UseLocking(bool x) {
313
+ Attrs ret = *this;
314
+ ret.use_locking_ = x;
315
+ return ret;
316
+ }
317
+
318
+ /// Defaults to true
319
+ TF_MUST_USE_RESULT Attrs UpdateSlots(bool x) {
320
+ Attrs ret = *this;
321
+ ret.update_slots_ = x;
322
+ return ret;
323
+ }
324
+
325
+ bool use_locking_ = false;
326
+ bool update_slots_ = true;
327
+ };
328
+ ResourceSparseApplyAdagradV2(const ::tensorflow::Scope& scope,
329
+ ::tensorflow::Input var, ::tensorflow::Input
330
+ accum, ::tensorflow::Input lr, ::tensorflow::Input
331
+ epsilon, ::tensorflow::Input grad,
332
+ ::tensorflow::Input indices);
333
+ ResourceSparseApplyAdagradV2(const ::tensorflow::Scope& scope,
334
+ ::tensorflow::Input var, ::tensorflow::Input
335
+ accum, ::tensorflow::Input lr, ::tensorflow::Input
336
+ epsilon, ::tensorflow::Input grad,
337
+ ::tensorflow::Input indices, const
338
+ ResourceSparseApplyAdagradV2::Attrs& attrs);
339
+ operator ::tensorflow::Operation() const { return operation; }
340
+
341
+ static Attrs UseLocking(bool x) {
342
+ return Attrs().UseLocking(x);
343
+ }
344
+ static Attrs UpdateSlots(bool x) {
345
+ return Attrs().UpdateSlots(x);
346
+ }
347
+
348
+ Operation operation;
349
+ };
350
+
351
+ /// Update relevant entries in '*var' and '*accum' according to the adagrad scheme.
352
+ ///
353
+ /// That is for rows we have grad for, we update var and accum as follows:
354
+ /// $$accum += grad * grad$$
355
+ /// $$var -= lr * grad * (1 / sqrt(accum))$$
356
+ ///
357
+ /// Args:
358
+ /// * scope: A Scope object
359
+ /// * var: Should be from a Variable().
360
+ /// * accum: Should be from a Variable().
361
+ /// * lr: Learning rate. Must be a scalar.
362
+ /// * epsilon: Constant factor. Must be a scalar.
363
+ /// * grad: The gradient.
364
+ /// * indices: A vector of indices into the first dimension of var and accum.
365
+ ///
366
+ /// Optional attributes (see `Attrs`):
367
+ /// * use_locking: If `True`, updating of the var and accum tensors will be protected
368
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
369
+ /// contention.
370
+ ///
371
+ /// Returns:
372
+ /// * `Output`: Same as "var".
373
+ class SparseApplyAdagradV2 {
374
+ public:
375
+ /// Optional attribute setters for SparseApplyAdagradV2
376
+ struct Attrs {
377
+ /// If `True`, updating of the var and accum tensors will be protected
378
+ /// by a lock; otherwise the behavior is undefined, but may exhibit less
379
+ /// contention.
380
+ ///
381
+ /// Defaults to false
382
+ TF_MUST_USE_RESULT Attrs UseLocking(bool x) {
383
+ Attrs ret = *this;
384
+ ret.use_locking_ = x;
385
+ return ret;
386
+ }
387
+
388
+ /// Defaults to true
389
+ TF_MUST_USE_RESULT Attrs UpdateSlots(bool x) {
390
+ Attrs ret = *this;
391
+ ret.update_slots_ = x;
392
+ return ret;
393
+ }
394
+
395
+ bool use_locking_ = false;
396
+ bool update_slots_ = true;
397
+ };
398
+ SparseApplyAdagradV2(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
399
+ ::tensorflow::Input accum, ::tensorflow::Input lr,
400
+ ::tensorflow::Input epsilon, ::tensorflow::Input grad,
401
+ ::tensorflow::Input indices);
402
+ SparseApplyAdagradV2(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
403
+ ::tensorflow::Input accum, ::tensorflow::Input lr,
404
+ ::tensorflow::Input epsilon, ::tensorflow::Input grad,
405
+ ::tensorflow::Input indices, const
406
+ SparseApplyAdagradV2::Attrs& attrs);
407
+ operator ::tensorflow::Output() const { return out; }
408
+ operator ::tensorflow::Input() const { return out; }
409
+ ::tensorflow::Node* node() const { return out.node(); }
410
+
411
+ static Attrs UseLocking(bool x) {
412
+ return Attrs().UseLocking(x);
413
+ }
414
+ static Attrs UpdateSlots(bool x) {
415
+ return Attrs().UpdateSlots(x);
416
+ }
417
+
418
+ Operation operation;
419
+ ::tensorflow::Output out;
420
+ };
421
+
422
+ } // namespace internal
423
+ } // namespace ops
424
+ } // namespace tensorflow
425
+
426
+ #endif // TENSORFLOW_CC_OPS_TRAINING_OPS_INTERNAL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/user_ops.h ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_USER_OPS_H_
4
+ #define TENSORFLOW_CC_OPS_USER_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 user_ops User Ops
19
+ /// @{
20
+
21
+ /// Output a fact about factorials.
22
+ ///
23
+ /// Args:
24
+ /// * scope: A Scope object
25
+ ///
26
+ /// Returns:
27
+ /// * `Output`: The fact tensor.
28
+ class Fact {
29
+ public:
30
+ Fact(const ::tensorflow::Scope& scope);
31
+ operator ::tensorflow::Output() const { return fact; }
32
+ operator ::tensorflow::Input() const { return fact; }
33
+ ::tensorflow::Node* node() const { return fact.node(); }
34
+
35
+ Operation operation;
36
+ ::tensorflow::Output fact;
37
+ };
38
+
39
+ /// @}
40
+
41
+ } // namespace ops
42
+ } // namespace tensorflow
43
+
44
+ #endif // TENSORFLOW_CC_OPS_USER_OPS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/user_ops_internal.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is MACHINE GENERATED! Do not edit.
2
+
3
+ #ifndef TENSORFLOW_CC_OPS_USER_OPS_INTERNAL_H_
4
+ #define TENSORFLOW_CC_OPS_USER_OPS_INTERNAL_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
+ namespace internal {
18
+ // NOTE: This namespace has internal TensorFlow details that
19
+ // are not part of TensorFlow's public API.
20
+
21
+ /// @defgroup user_ops_internal User Ops Internal
22
+ /// @{
23
+
24
+ } // namespace internal
25
+ } // namespace ops
26
+ } // namespace tensorflow
27
+
28
+ #endif // TENSORFLOW_CC_OPS_USER_OPS_INTERNAL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/ops/while_loop.h ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_CC_OPS_WHILE_LOOP_H_
17
+ #define TENSORFLOW_CC_OPS_WHILE_LOOP_H_
18
+
19
+ #include <string>
20
+ #include <vector>
21
+
22
+ #include "tensorflow/cc/framework/ops.h"
23
+ #include "tensorflow/cc/framework/scope.h"
24
+
25
+ namespace tensorflow {
26
+ namespace ops {
27
+
28
+ // Function that takes cond graph inputs and returns cond graph boolean output.
29
+ // 'output' need not be set if an error is returned.
30
+ typedef std::function<Status(const Scope&, const std::vector<Output>& inputs,
31
+ Output* output)>
32
+ CondGraphBuilderFn;
33
+
34
+ // Function that takes body graph inputs and returns body graph outputs.
35
+ // 'outputs' need not be populated if an error is returned.
36
+ typedef std::function<Status(const Scope&, const std::vector<Output>& inputs,
37
+ std::vector<Output>* outputs)>
38
+ BodyGraphBuilderFn;
39
+
40
+ // Constructs a while loop.
41
+ //
42
+ // Arguments:
43
+ // * scope: used to construct the while loop.
44
+ // * inputs: the initial values of the loop variables. Must be non-empty.
45
+ // * cond: a function that builds the condition graph of the loop. Takes the
46
+ // current loop variables as inputs and returns a scalar boolean Output
47
+ // indicating whether the loop should continue.
48
+ // * body: a function that builds the body graph of the loop. Takes the current
49
+ // loop variables as inputs and returns the updated loop variables.
50
+ // * frame_name: the frame name to use for this while loop. This should be a
51
+ // unique name. This will be used as a prefix for created operations.
52
+ // * outputs: output param that returns final loop variable outputs in non-error
53
+ // case. Must be non-null and empty.
54
+ // * create_while_ctx: if true, a WhileContext is created and populated for this
55
+ // loop. See core/graph/while_context.h for more details on
56
+ // WhileContexts. This is set to false for loops used as part of gradient
57
+ // computations, since they're part of the gradient for a loop in the
58
+ // forward-pass.
59
+ // TODO(skyewm): revisit this. Should we create WhileContexts for all loops,
60
+ // even if we don't need them?
61
+ // * cond_output: if non-null, the output of the predicate is returned. This
62
+ // will always be a LoopCond node.
63
+ //
64
+ // Returns an error if the while loop could not be fully constructed.
65
+ //
66
+ // TODO(skyewm): clean up partially-constructed loop in error case
67
+ // TODO(skyewm): create public interface to this method
68
+ Status BuildWhileLoop(const Scope& scope, const std::vector<Output>& inputs,
69
+ const CondGraphBuilderFn& cond,
70
+ const BodyGraphBuilderFn& body, const string& frame_name,
71
+ OutputList* outputs, bool create_while_ctx = true,
72
+ Output* cond_output = nullptr);
73
+
74
+ } // namespace ops
75
+ } // namespace tensorflow
76
+
77
+ #endif // TENSORFLOW_CC_OPS_WHILE_LOOP_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/bundle_v2.h ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ // Helpers for loading the persistent representation of a SavedModelV2.
17
+ // Please note that this is depended on by code that does not make use of
18
+ // the full runtime and its dependencies should be restricted.
19
+
20
+ #ifndef TENSORFLOW_CC_SAVED_MODEL_BUNDLE_V2_H_
21
+ #define TENSORFLOW_CC_SAVED_MODEL_BUNDLE_V2_H_
22
+
23
+ #include <functional>
24
+ #include <memory>
25
+ #include <string>
26
+
27
+ #include "absl/container/flat_hash_set.h"
28
+ #include "tensorflow/core/framework/graph_debug_info.pb.h"
29
+ #include "tensorflow/core/lib/core/status.h"
30
+ #include "tensorflow/core/protobuf/meta_graph.pb.h"
31
+ #include "tensorflow/core/protobuf/saved_object_graph.pb.h"
32
+ #include "tensorflow/core/protobuf/trackable_object_graph.pb.h"
33
+ #include "tensorflow/core/util/tensor_bundle/tensor_bundle.h"
34
+
35
+ namespace tensorflow {
36
+
37
+ /// Represents a version 2 SavedModel that is loaded from storage (but not yet
38
+ /// loaded into an executable in-memory representation).
39
+ class SavedModelV2Bundle {
40
+ public:
41
+ using RestoreObjectsCallback =
42
+ std::function<Status(int, const TrackableObjectGraph::TrackableObject&)>;
43
+
44
+ /// Loads persistent representations for a SavedModelV2 from the specified
45
+ /// export directory.
46
+ static Status Load(const std::string& export_dir, SavedModelV2Bundle* bundle);
47
+
48
+ /// MetaGraphDef from the loaded SavedModel.
49
+ MetaGraphDef& meta_graph_def() { return meta_graph_def_; }
50
+
51
+ /// SavedObjectGraph from the MetaGraphDef.
52
+ const SavedObjectGraph& saved_object_graph() {
53
+ return meta_graph_def().object_graph_def();
54
+ }
55
+
56
+ /// TrackableObjectGraph loaded from the variable_reader() checkpoint.
57
+ TrackableObjectGraph& trackable_object_graph() {
58
+ return trackable_object_graph_;
59
+ }
60
+
61
+ /// BundleReader for accessing the variables bundle.
62
+ BundleReader* variable_reader() { return variable_reader_.get(); }
63
+
64
+ /// The GraphDebugInfo (or nullptr if none).
65
+ GraphDebugInfo* debug_info() { return debug_info_.get(); }
66
+
67
+ /// Restores objects, invoking the callback with the node id in the
68
+ /// saved_object_graph() and the corresponding TrackableObject from the
69
+ /// trackable_object_graph(). The callback may use the variable_reader() but
70
+ /// must not modify the underlying saved_object_graph().
71
+ Status VisitObjectsToRestore(RestoreObjectsCallback callback);
72
+
73
+ private:
74
+ Status RecurseObjectsToRestore(
75
+ const SavedObject* saved_object, int saved_object_node_id,
76
+ const TrackableObjectGraph::TrackableObject* trackable_object,
77
+ std::string object_name,
78
+ absl::flat_hash_set<int>* seen_trackable_node_ids,
79
+ RestoreObjectsCallback callback);
80
+
81
+ MetaGraphDef meta_graph_def_;
82
+ TrackableObjectGraph trackable_object_graph_;
83
+ std::unique_ptr<BundleReader> variable_reader_;
84
+ std::unique_ptr<GraphDebugInfo> debug_info_;
85
+ };
86
+
87
+ } // namespace tensorflow
88
+
89
+ #endif // TENSORFLOW_CC_SAVED_MODEL_BUNDLE_V2_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/constants.h ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_CC_SAVED_MODEL_CONSTANTS_H_
17
+ #define TENSORFLOW_CC_SAVED_MODEL_CONSTANTS_H_
18
+
19
+ namespace tensorflow {
20
+
21
+ // SavedModel assets directory.
22
+ inline constexpr char kSavedModelAssetsDirectory[] = "assets";
23
+
24
+ // SavedModel assets.extra directory.
25
+ inline constexpr char kSavedModelAssetsExtraDirectory[] = "assets.extra";
26
+
27
+ // SavedModel assets key for graph collection-def.
28
+ inline constexpr char kSavedModelAssetsKey[] = "saved_model_assets";
29
+
30
+ /// SavedModel legacy init op collection key. Used in v1 SavedModels.
31
+ inline constexpr char kSavedModelLegacyInitOpKey[] = "legacy_init_op";
32
+
33
+ /// SavedModel main op collection key. Used in v1 SavedModels.
34
+ inline constexpr char kSavedModelMainOpKey[] = "saved_model_main_op";
35
+
36
+ // CollectionDef key for the SavedModel train op.
37
+ // Not exported while export_all_saved_models is experimental.
38
+ inline constexpr char kSavedModelTrainOpKey[] = "saved_model_train_op";
39
+
40
+ // Schema version for SavedModel.
41
+ inline constexpr int kSavedModelSchemaVersion = 1;
42
+
43
+ // SavedModel proto filename prefix.
44
+ inline constexpr char kSavedModelFilenamePrefix[] = "saved_model";
45
+ // SavedModel proto filename.
46
+ inline constexpr char kSavedModelFilenamePb[] = "saved_model.pb";
47
+
48
+ // SavedModel chunked proto filename.
49
+ inline constexpr char kSavedModelFilenameCpb[] = "saved_model.cpb";
50
+
51
+ // SavedModel text format proto filename.
52
+ inline constexpr char kSavedModelFilenamePbTxt[] = "saved_model.pbtxt";
53
+
54
+ // Subdirectory where debugging related files are written.
55
+ inline constexpr char kSavedModelDebugDirectory[] = "debug";
56
+
57
+ // File name for GraphDebugInfo protocol buffer which corresponds to the
58
+ // SavedModel.
59
+ inline constexpr char kSavedModelDebugInfoFilenamePb[] =
60
+ "saved_model_debug_info.pb";
61
+
62
+ // Directory in which to save the SavedModel variables.
63
+ inline constexpr char kSavedModelVariablesDirectory[] = "variables";
64
+
65
+ // SavedModel variables filename.
66
+ inline constexpr char kSavedModelVariablesFilename[] = "variables";
67
+
68
+ // SavedModel SignatureDef keys for the initialization and train ops. Used in
69
+ // V2 SavedModels.
70
+ inline constexpr char kSavedModelInitOpSignatureKey[] = "__saved_model_init_op";
71
+ inline constexpr char kSavedModelTrainOpSignatureKey[] =
72
+ "__saved_model_train_op";
73
+
74
+ // Key in the TensorBundle for the object graph proto.
75
+ inline constexpr char kObjectGraphProtoKey[] = "_CHECKPOINTABLE_OBJECT_GRAPH";
76
+
77
+ // Filename for the FingerprintDef protocol buffer.
78
+ inline constexpr char kFingerprintFilenamePb[] = "fingerprint.pb";
79
+
80
+ } // namespace tensorflow
81
+
82
+ #endif // TENSORFLOW_CC_SAVED_MODEL_CONSTANTS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/fingerprinting.h ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_CC_SAVED_MODEL_FINGERPRINTING_H_
17
+ #define TENSORFLOW_CC_SAVED_MODEL_FINGERPRINTING_H_
18
+
19
+ #include <string>
20
+
21
+ #include "absl/status/statusor.h"
22
+ #include "absl/strings/string_view.h"
23
+ #include "tensorflow/core/protobuf/fingerprint.pb.h"
24
+
25
+ namespace tensorflow::saved_model::fingerprinting {
26
+
27
+ // Creates a FingerprintDef proto from a SavedModel (regular or chunked) and the
28
+ // checkpoint meta file (.index) in `export_dir`.
29
+ absl::StatusOr<FingerprintDef> CreateFingerprintDef(
30
+ absl::string_view export_dir);
31
+
32
+ // Loads the `fingerprint.pb` from `export_dir`, returns an error if there is
33
+ // none.
34
+ absl::StatusOr<FingerprintDef> ReadSavedModelFingerprint(
35
+ absl::string_view export_dir);
36
+
37
+ // Canonical fingerprinting ID for a SavedModel.
38
+ std::string Singleprint(uint64_t graph_def_program_hash,
39
+ uint64_t signature_def_hash,
40
+ uint64_t saved_object_graph_hash,
41
+ uint64_t checkpoint_hash);
42
+ std::string Singleprint(const FingerprintDef& fingerprint);
43
+ absl::StatusOr<std::string> Singleprint(absl::string_view export_dir);
44
+
45
+ } // namespace tensorflow::saved_model::fingerprinting
46
+
47
+ #endif // TENSORFLOW_CC_SAVED_MODEL_FINGERPRINTING_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/loader.h ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ /// SavedModel loading functions and SavedModelBundle struct.
17
+
18
+ #ifndef TENSORFLOW_CC_SAVED_MODEL_LOADER_H_
19
+ #define TENSORFLOW_CC_SAVED_MODEL_LOADER_H_
20
+
21
+ #include <string>
22
+ #include <unordered_set>
23
+
24
+ #include "tensorflow/core/framework/graph_debug_info.pb.h"
25
+ #include "tensorflow/core/lib/core/status.h"
26
+ #include "tensorflow/core/protobuf/meta_graph.pb.h"
27
+ #include "tensorflow/core/public/session.h"
28
+
29
+ namespace tensorflow {
30
+
31
+ /// Represents a SavedModel that is loaded from storage.
32
+ class SavedModelBundleInterface {
33
+ public:
34
+ virtual ~SavedModelBundleInterface();
35
+
36
+ /// Returns the TensorFlow Session that can be used to interact with the
37
+ /// SavedModel.
38
+ virtual Session* GetSession() const = 0;
39
+
40
+ /// Returns a map from signature name to SignatureDef for all signatures in
41
+ /// in the SavedModel.
42
+ virtual const protobuf::Map<string, SignatureDef>& GetSignatures() const = 0;
43
+ };
44
+
45
+ /// SavedModel representation once the SavedModel is loaded from storage.
46
+ ///
47
+ /// NOTE: Prefer to use SavedModelBundleLite in new code, as it consumes less
48
+ /// RAM.
49
+ struct SavedModelBundle : public SavedModelBundleInterface {
50
+ /// A TensorFlow Session does not Close itself on destruction. To avoid
51
+ /// resource leaks, we explicitly call Close on Sessions that we create.
52
+ ~SavedModelBundle() override {
53
+ if (session) {
54
+ session->Close().IgnoreError();
55
+ }
56
+ }
57
+
58
+ SavedModelBundle() = default;
59
+
60
+ Session* GetSession() const override { return session.get(); }
61
+ const protobuf::Map<string, SignatureDef>& GetSignatures() const override {
62
+ return meta_graph_def.signature_def();
63
+ }
64
+
65
+ std::unique_ptr<Session> session;
66
+ MetaGraphDef meta_graph_def;
67
+ std::unique_ptr<GraphDebugInfo> debug_info;
68
+ };
69
+
70
+ // A version of SavedModelBundle that avoids storing a potentially large
71
+ // MetaGraphDef. Prefer to use SavedModelBundleLite in new code.
72
+ class SavedModelBundleLite : public SavedModelBundleInterface {
73
+ public:
74
+ SavedModelBundleLite() = default;
75
+ SavedModelBundleLite(SavedModelBundleLite&& other) = default;
76
+ SavedModelBundleLite& operator=(SavedModelBundleLite&& other) = default;
77
+
78
+ SavedModelBundleLite(std::unique_ptr<Session> session,
79
+ protobuf::Map<string, SignatureDef> signatures)
80
+ : session_(std::move(session)), signatures_(std::move(signatures)) {}
81
+
82
+ /// A TensorFlow Session does not Close itself on destruction. To avoid
83
+ /// resource leaks, we explicitly call Close on Sessions that we create.
84
+ ~SavedModelBundleLite() override {
85
+ if (session_) {
86
+ session_->Close().IgnoreError();
87
+ }
88
+ }
89
+
90
+ Session* GetSession() const override { return session_.get(); }
91
+ const protobuf::Map<string, SignatureDef>& GetSignatures() const override {
92
+ return signatures_;
93
+ }
94
+
95
+ private:
96
+ std::unique_ptr<Session> session_;
97
+ protobuf::Map<string, SignatureDef> signatures_;
98
+ };
99
+
100
+ // Restore variable and resources in the SavedModel export dir for the
101
+ // indicated metagraph.
102
+ // The recommended way to load a saved model is to call LoadSavedModel,
103
+ // which provides an already initialized Metagraph, Session, and DebugInfo.
104
+ Status RestoreSession(const RunOptions& run_options,
105
+ const MetaGraphDef& meta_graph, const string& export_dir,
106
+ std::unique_ptr<Session>* session);
107
+
108
+ // Initialize a session which wraps this metagraph.
109
+ // The recommended way to load a saved model is to call LoadSavedModel,
110
+ // which provides an already initialized Metagraph, Session, and DebugInfo.
111
+ Status LoadMetagraphIntoSession(const SessionOptions& session_options,
112
+ const MetaGraphDef& meta_graph,
113
+ std::unique_ptr<Session>* session);
114
+
115
+ /// Loads a SavedModel from the specified export directory. The MetaGraphDef
116
+ /// to be loaded is identified by the supplied tags, corresponding exactly to
117
+ /// the set of tags used at SavedModel build time. Stores a SavedModel bundle in
118
+ /// *bundle with a session and the requested MetaGraphDef, if found.
119
+ ///
120
+ /// NOTE: Prefer the overload that takes a SavedModelBundleLite* in new code.
121
+ Status LoadSavedModel(const SessionOptions& session_options,
122
+ const RunOptions& run_options, const string& export_dir,
123
+ const std::unordered_set<string>& tags,
124
+ SavedModelBundle* const bundle);
125
+
126
+ /// Loads a SavedModel from the specified export directory. The MetaGraphDef
127
+ /// to be loaded is identified by the supplied tags, corresponding exactly to
128
+ /// the set of tags used at SavedModel build time. Stores a SavedModel bundle
129
+ /// in *bundle with a session created from the requested MetaGraphDef if found.
130
+ ///
131
+ /// This overload creates a SavedModelBundleLite, which consumes less RAM than
132
+ /// an equivalent SavedModelBundle.
133
+ Status LoadSavedModel(const SessionOptions& session_options,
134
+ const RunOptions& run_options, const string& export_dir,
135
+ const std::unordered_set<string>& tags,
136
+ SavedModelBundleLite* const bundle);
137
+
138
+ /// Checks whether the provided directory could contain a SavedModel. Note that
139
+ /// the method does not load any data by itself. If the method returns `false`,
140
+ /// the export directory definitely does not contain a SavedModel. If the method
141
+ /// returns `true`, the export directory may contain a SavedModel but provides
142
+ /// no guarantee that it can be loaded.
143
+ bool MaybeSavedModelDirectory(const std::string& export_dir);
144
+
145
+ } // namespace tensorflow
146
+
147
+ #endif // TENSORFLOW_CC_SAVED_MODEL_LOADER_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/loader_util.h ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_CC_SAVED_MODEL_LOADER_UTIL_H_
17
+ #define TENSORFLOW_CC_SAVED_MODEL_LOADER_UTIL_H_
18
+
19
+ #include <string>
20
+
21
+ #include "tensorflow/core/lib/core/status.h"
22
+ #include "tensorflow/core/protobuf/meta_graph.pb.h"
23
+
24
+ namespace tensorflow {
25
+ namespace internal {
26
+
27
+ // A SavedModel may store the name of the initialization op to run in the
28
+ // in the SignatureDef (v2) or a collection (v1). If an init_op collection
29
+ // exists, then the collection must contain exactly one op.
30
+ Status GetInitOp(const string& export_dir, const MetaGraphDef& meta_graph_def,
31
+ string* init_op_name);
32
+
33
+ Status GetAssetFileDefs(const MetaGraphDef& meta_graph_def,
34
+ std::vector<AssetFileDef>* asset_file_defs);
35
+
36
+ } // namespace internal
37
+ } // namespace tensorflow
38
+
39
+ #endif // TENSORFLOW_CC_SAVED_MODEL_LOADER_UTIL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/metrics.h ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+ // APIs for accessing SavedModel and checkpoint metric objects.
16
+ //
17
+ // In order to collect the data from these metrics, please add the metrics to
18
+ // the provided monitoring platform. Unless configured with a user-specified
19
+ // monitoring platform, the data is not collected in OSS.
20
+
21
+ #ifndef TENSORFLOW_CC_SAVED_MODEL_METRICS_H_
22
+ #define TENSORFLOW_CC_SAVED_MODEL_METRICS_H_
23
+
24
+ #include <cstdint>
25
+ #include <string>
26
+ #include <utility>
27
+
28
+ #include "absl/status/statusor.h"
29
+ #include "absl/strings/string_view.h"
30
+ #include "tensorflow/core/lib/monitoring/counter.h"
31
+ #include "tensorflow/core/lib/monitoring/gauge.h"
32
+ #include "tensorflow/core/lib/monitoring/sampler.h"
33
+ #include "tensorflow/core/protobuf/fingerprint.pb.h"
34
+
35
+ namespace tensorflow {
36
+ namespace metrics {
37
+
38
+ const char kFingerprintFound[] = "FOUND";
39
+ const char kFingerprintNotFound[] = "NOT_FOUND";
40
+ const char kFingerprintError[] = "ERROR";
41
+
42
+ // Returns "/tensorflow/core/saved_model/write/count" cell. This metric
43
+ // has 1 field "write_version", which is equal to the
44
+ // `tensorflow::libexport::GetWriteVersion` of the protobuf and should be
45
+ // incremented when a SavedModel has been successfully written.
46
+ monitoring::CounterCell& SavedModelWriteCount(absl::string_view write_version);
47
+
48
+ // Returns "/tensorflow/core/saved_model/read/count" cell. This metric
49
+ // has 1 field "write_version", which is equal to the
50
+ // `tensorflow::libexport::GetWriteVersion` of the protobuf, and should be
51
+ // incremented when a SavedModel has been successfully read.
52
+ monitoring::CounterCell& SavedModelReadCount(absl::string_view write_version);
53
+
54
+ // Returns "/tensorflow/core/saved_model/write/api" cell. This metric has 1
55
+ // field "api_label" which corresponds to a SavedModel write API. The cell for
56
+ // `foo` should be incremented when the write API `foo` is called.
57
+ monitoring::CounterCell& SavedModelWriteApi(absl::string_view api_label);
58
+
59
+ // Returns "/tensorflow/core/saved_model/read/api" cell. This metric has 1
60
+ // field "api_label" which corresponds to a SavedModel read API. The cell for
61
+ // `foo` should be incremented when the read API `foo` is called.
62
+ monitoring::CounterCell& SavedModelReadApi(absl::string_view api_label);
63
+
64
+ // Returns "/tensorflow/core/saved_model/write/fingerprint" cell, which contains
65
+ // the saved_model_checksum of the SM's fingerprint when it is exported.
66
+ monitoring::GaugeCell<std::string>& SavedModelWriteFingerprint();
67
+
68
+ // Returns "/tensorflow/core/saved_model/write/path" cell, which contains
69
+ // the saved_model_path of the SM when it is exported.
70
+ monitoring::GaugeCell<std::string>& SavedModelWritePath();
71
+
72
+ // Returns "/tensorflow/core/saved_model/write/path_and_fingerprint" cell, which
73
+ // contains the path (saved_model_path) and fingerprint (concatenation of
74
+ // graph_def_program_hash, signature_def_hash, saved_object_graph_hash,
75
+ // and checkpoint_hash) of the SavedModel when it is exported.
76
+ monitoring::GaugeCell<std::string>& SavedModelWritePathAndSingleprint();
77
+
78
+ // Returns "/tensorflow/core/saved_model/read/fingerprint" cell, wich contains
79
+ // the saved_model_checksum of the SM's fingerprint when it is imported.
80
+ monitoring::GaugeCell<std::string>& SavedModelReadFingerprint();
81
+
82
+ // Returns "/tensorflow/core/saved_model/read/path" cell, wich contains
83
+ // the saved_model_path of the SM when it is imported.
84
+ monitoring::GaugeCell<std::string>& SavedModelReadPath();
85
+
86
+ // Returns "/tensorflow/core/saved_model/read/path_and_fingerprint" cell, which
87
+ // contains the path (saved_model_path) and singleprint (concatenation of
88
+ // graph_def_program_hash, signature_def_hash, saved_object_graph_hash,
89
+ // and checkpoint_hash) of the SavedModel when it is imported.
90
+ monitoring::GaugeCell<std::string>& SavedModelReadPathAndSingleprint();
91
+
92
+ // Returns the fingerprint as a Json string.
93
+ std::string MakeFingerprintJson(FingerprintDef fingerprint_def);
94
+
95
+ // Returns canonical string concatenation of path and singleprint.
96
+ absl::StatusOr<std::string> MakeSavedModelPathAndSingleprint(
97
+ std::string path, std::string singleprint);
98
+
99
+ // Returns path and singleprint as a pair, parsed canonically from the string
100
+ // metric.
101
+ absl::StatusOr<std::pair<std::string, std::string>>
102
+ ParseSavedModelPathAndSingleprint(std::string path_and_singleprint);
103
+
104
+ // Returns string status indicating whether or not the fingerprint.pb file was
105
+ // found when loading the SavedModel.
106
+ monitoring::GaugeCell<std::string>& SavedModelFoundFingerprintOnLoad();
107
+
108
+ // Returns "/tensorflow/core/checkpoint/read/read_durations" cell belonging to
109
+ // field `api_label`.
110
+ monitoring::SamplerCell& CheckpointReadDuration(absl::string_view api_label);
111
+
112
+ // Returns "/tensorflow/core/checkpoint/write/write_durations" cell belonging to
113
+ // field `api_label`.
114
+ monitoring::SamplerCell& CheckpointWriteDuration(absl::string_view api_label);
115
+
116
+ // Returns "/tensorflow/core/checkpoint/write/async_write_durations" cell
117
+ // belonging to field `api_label`.
118
+ monitoring::SamplerCell& AsyncCheckpointWriteDuration(
119
+ absl::string_view api_label);
120
+
121
+ // Returns "/tensorflow/core/checkpoint/write/training_time_saved" cell
122
+ // belonging to field `api_label`.
123
+ monitoring::CounterCell& TrainingTimeSaved(absl::string_view api_label);
124
+
125
+ // Returns "/tensorflow/core/checkpoint/write/checkpoint_size" cell
126
+ // belonging to field (`api_label`, `filesize`).
127
+ monitoring::CounterCell& CheckpointSize(absl::string_view api_label,
128
+ int64_t filesize);
129
+
130
+ } // namespace metrics
131
+ } // namespace tensorflow
132
+
133
+ #endif // TENSORFLOW_CC_SAVED_MODEL_METRICS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/reader.h ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ /// Functions to read the SavedModel proto, or parts of it.
17
+
18
+ #ifndef TENSORFLOW_CC_SAVED_MODEL_READER_H_
19
+ #define TENSORFLOW_CC_SAVED_MODEL_READER_H_
20
+
21
+ #include <memory>
22
+ #include <string>
23
+ #include <unordered_set>
24
+
25
+ #include "tensorflow/core/framework/graph_debug_info.pb.h"
26
+ #include "tensorflow/core/lib/core/status.h"
27
+ #include "tensorflow/core/protobuf/meta_graph.pb.h"
28
+ #include "tensorflow/core/protobuf/saved_model.pb.h"
29
+
30
+ namespace tensorflow {
31
+ Status ReadSavedModel(absl::string_view export_dir,
32
+ SavedModel* saved_model_proto);
33
+
34
+ // Reads the SavedModel proto from saved_model.pb(txt) in the given directory,
35
+ // finds the MetaGraphDef that matches the given set of tags and writes it to
36
+ // the `meta_graph_def` parameter. Returns a failure status when the SavedModel
37
+ // file does not exist or no MetaGraphDef matches the tags.
38
+ Status ReadMetaGraphDefFromSavedModel(const string& export_dir,
39
+ const std::unordered_set<string>& tags,
40
+ MetaGraphDef* meta_graph_def);
41
+
42
+ // Store debug info from the SavedModel export dir.
43
+ Status ReadSavedModelDebugInfoIfPresent(
44
+ const string& export_dir,
45
+ std::unique_ptr<GraphDebugInfo>* debug_info_proto);
46
+
47
+ } // namespace tensorflow
48
+
49
+ #endif // TENSORFLOW_CC_SAVED_MODEL_READER_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/saved_model/util.h ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+ #ifndef TENSORFLOW_CC_SAVED_MODEL_UTIL_H_
16
+ #define TENSORFLOW_CC_SAVED_MODEL_UTIL_H_
17
+
18
+ #include <set>
19
+ #include <string>
20
+ #include <utility>
21
+ #include <vector>
22
+
23
+ #include "tensorflow/core/framework/tensor.h"
24
+ #include "tensorflow/core/framework/tensor.pb.h"
25
+ #include "tensorflow/core/platform/status.h"
26
+ #include "tensorflow/core/protobuf/meta_graph.pb.h"
27
+ #include "tensorflow/core/protobuf/saved_model.pb.h"
28
+
29
+ namespace tensorflow {
30
+ namespace saved_model {
31
+
32
+ // Utility functions for SavedModel reading and writing.
33
+
34
+ // Returns "WriteVersion" ("1" or "2") of the SavedModel protobuf. If the
35
+ // protobuf has exactly one MetaGraphDef, which contains a SavedObjectGraph, it
36
+ // is version 2. Else, the protobuf is version 1.
37
+ //
38
+ // NOTE: The "WriteVersion" does *not* equal the major version of TF.
39
+ std::string GetWriteVersion(const SavedModel& saved_model);
40
+
41
+ // Get view of string keys of a map.
42
+ std::set<std::string> GetMapKeys(
43
+ const ::google::protobuf::Map<std::string, ::tensorflow::TensorProto>& map);
44
+
45
+ // Get the default input value from signature if it's missing in the request
46
+ // inputs. If `is_alias` is set to true, the keys of the `request_inputs` are
47
+ // alias names rather than the feed names in the graph.
48
+ Status GetInputValues(
49
+ const SignatureDef& signature,
50
+ const ::google::protobuf::Map<std::string, ::tensorflow::TensorProto>& request_inputs,
51
+ std::vector<std::pair<string, Tensor>>& inputs);
52
+
53
+ } // namespace saved_model
54
+ } // namespace tensorflow
55
+
56
+ #endif // TENSORFLOW_CC_SAVED_MODEL_UTIL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/tools/freeze_saved_model.h ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+ #ifndef TENSORFLOW_CC_TOOLS_FREEZE_SAVED_MODEL_H_
16
+ #define TENSORFLOW_CC_TOOLS_FREEZE_SAVED_MODEL_H_
17
+
18
+ #include <unordered_set>
19
+
20
+ #include "tensorflow/cc/saved_model/loader.h"
21
+ #include "tensorflow/core/framework/graph.pb.h"
22
+ #include "tensorflow/core/lib/core/status.h"
23
+
24
+ namespace tensorflow {
25
+
26
+ // Returns a frozen GraphDef, input tensors, and output tensors from the loaded
27
+ // SavedModelBundle.
28
+ // `inputs` and `outputs` consist of the union of all inputs and outputs in the
29
+ // SignatureDefs in the SavedModelBundle.
30
+ // FreezeSavedModel sets `frozen_graph_def` to a GraphDef of all nodes needed by
31
+ // `outputs`. All variables in the supplied SavedModelBundle are converted to
32
+ // constants, set to the value of the variables, by running the restored Session
33
+ // in the SavedModelBundle.
34
+ // WARNING: Only the variable checkpoints will be reflected in the frozen
35
+ // graph_def. All saved_model assets will be ignored.
36
+ Status FreezeSavedModel(const SavedModelBundle& saved_model_bundle,
37
+ GraphDef* frozen_graph_def,
38
+ std::unordered_set<string>* inputs,
39
+ std::unordered_set<string>* outputs);
40
+
41
+ } // namespace tensorflow
42
+
43
+ #endif // TENSORFLOW_CC_TOOLS_FREEZE_SAVED_MODEL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/training/coordinator.h ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_CC_TRAINING_COORDINATOR_H_
17
+ #define TENSORFLOW_CC_TRAINING_COORDINATOR_H_
18
+
19
+ #include <atomic>
20
+ #include <memory>
21
+ #include <unordered_set>
22
+ #include <vector>
23
+
24
+ #include "tensorflow/core/framework/cost_graph.pb.h"
25
+ #include "tensorflow/core/lib/core/status.h"
26
+ #include "tensorflow/core/platform/macros.h"
27
+ #include "tensorflow/core/platform/mutex.h"
28
+ #include "tensorflow/core/protobuf/config.pb.h"
29
+ #include "tensorflow/core/protobuf/error_codes.pb.h"
30
+
31
+ namespace tensorflow {
32
+
33
+ /// The abstract interface for runners which must implement the Join and the
34
+ /// IsRunning function.
35
+ class RunnerInterface {
36
+ public:
37
+ virtual ~RunnerInterface() {}
38
+ virtual Status Join() = 0;
39
+ virtual Status ExportCostGraph(CostGraphDef* cost_graph) const {
40
+ return Status(absl::StatusCode::kInvalidArgument,
41
+ "No cost model to export.");
42
+ }
43
+ /// Returns true iff the runner is running, i.e. if it is trying to populate
44
+ /// its queue.
45
+ virtual bool IsRunning() const = 0;
46
+ };
47
+
48
+ /// Coordinator class manages the termination of a collection of QueueRunners.
49
+ /// Without a coordinator, QueueRunners have to be joined in a specific order;
50
+ /// otherwise the QueueRunner::Join() could sometimes hang. The
51
+ /// Coordinator::RequestStop() plays the key role which notifies all running
52
+ /// threads under a coordinator to stop. This function could be called by any
53
+ /// thread or any client.
54
+ /// Usage, in the client:
55
+ /// Coordinator coord;
56
+ /// std::unique_ptr<QueueRunner> qr(&coord, ...);
57
+ /// qr.Start(session);
58
+ /// coord.RegisterRunner(std::move(qr));
59
+ /// /// do some work
60
+ /// TF_CHECK_OK(coord.Join());
61
+ /// In each thread of QueueRunner, the coordinator needs to be used as:
62
+ /// void Run() {
63
+ /// while (!coord->ShouldStop()) {
64
+ /// /// do some work
65
+ /// if (error) {
66
+ /// coord->RequestStop();
67
+ /// coord->ReportStatus(error_status);
68
+ /// }
69
+ /// }
70
+ /// }
71
+ class Coordinator {
72
+ public:
73
+ Coordinator();
74
+
75
+ /// Constructor with a list of error codes which would not be taken as errors
76
+ /// in status reporting.
77
+ Coordinator(const std::vector<error::Code>& clean_stop_errors);
78
+
79
+ /// In the destructor, RequestStop() and Join() would be called.
80
+ ~Coordinator();
81
+
82
+ /// Registers a runner, i.e. a unit of running threads which is usually a
83
+ /// QueueRunner. It takes the ownership of runner to avoid lifecycle-related
84
+ /// problems. Note, the coordinator would not start these threads; they are
85
+ /// supposed to be in running state when they are registered here.
86
+ Status RegisterRunner(std::unique_ptr<RunnerInterface> runner);
87
+
88
+ /// Returns true iff all the registered runners have been stopped.
89
+ bool AllRunnersStopped();
90
+
91
+ /// Requests all running threads to stop.
92
+ Status RequestStop();
93
+
94
+ /// Returns true if its RequestStop() has been called.
95
+ bool ShouldStop();
96
+
97
+ /// Joins all threads, returns OK or the first reported and unexpected status.
98
+ Status Join();
99
+
100
+ /// Reports status to the coordinator. This is usually called by threads.
101
+ void ReportStatus(const Status& status);
102
+
103
+ /// Returns the latest status.
104
+ Status GetStatus();
105
+
106
+ /// Returns immediately if the coordinator is stopped or blocks until
107
+ /// RequestStop() is called.
108
+ void WaitForStop();
109
+
110
+ // Returns the cost graph from stored run metadata in registered runners.
111
+ Status ExportCostGraph(CostGraphDef* cost_graph) const;
112
+
113
+ private:
114
+ std::unordered_set<int> clean_stop_errors_;
115
+ condition_variable wait_for_stop_;
116
+
117
+ mutex mu_;
118
+ bool should_stop_ TF_GUARDED_BY(mu_);
119
+
120
+ mutex status_lock_;
121
+ Status status_ TF_GUARDED_BY(status_lock_);
122
+
123
+ mutable mutex runners_lock_;
124
+ std::vector<std::unique_ptr<RunnerInterface>> runners_
125
+ TF_GUARDED_BY(runners_lock_);
126
+
127
+ TF_DISALLOW_COPY_AND_ASSIGN(Coordinator);
128
+ };
129
+
130
+ } // namespace tensorflow
131
+
132
+ #endif // TENSORFLOW_CC_TRAINING_COORDINATOR_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/cc/training/queue_runner.h ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_CC_TRAINING_QUEUE_RUNNER_H_
17
+ #define TENSORFLOW_CC_TRAINING_QUEUE_RUNNER_H_
18
+
19
+ #include <memory>
20
+ #include <string>
21
+ #include <unordered_set>
22
+ #include <vector>
23
+
24
+ #include "tensorflow/cc/training/coordinator.h"
25
+ #include "tensorflow/core/lib/core/status.h"
26
+ #include "tensorflow/core/lib/core/threadpool.h"
27
+ #include "tensorflow/core/platform/blocking_counter.h"
28
+ #include "tensorflow/core/platform/mutex.h"
29
+ #include "tensorflow/core/protobuf/config.pb.h"
30
+ #include "tensorflow/core/protobuf/error_codes.pb.h"
31
+ #include "tensorflow/core/protobuf/queue_runner.pb.h"
32
+ #include "tensorflow/core/public/session.h"
33
+
34
+ namespace tensorflow {
35
+
36
+ /// QueueRunner class imitates the behavior of the python version of QueueRunner
37
+ /// which creates a thread for each enqueue op, runs close op on completion.
38
+ class QueueRunner : public RunnerInterface {
39
+ public:
40
+ /// Creates a new QueueRunner from proto.
41
+ // TODO(yuefengz): we may want to initialize from queues and ops in the
42
+ // future.
43
+ static Status New(const QueueRunnerDef& queue_runner_def,
44
+ std::unique_ptr<QueueRunner>* result);
45
+
46
+ /// Creates a new QueueRunner with a coordinator, see coordinator.h for usage.
47
+ static Status New(const QueueRunnerDef& queue_runner_def, Coordinator* coord,
48
+ std::unique_ptr<QueueRunner>* result);
49
+
50
+ /// Adds a callback that the queue runner will call when it detects an error.
51
+ void AddErrorCallback(const std::function<void(Status)>& cb);
52
+
53
+ /// Delete the previously registered callbacks.
54
+ void ClearErrorCallbacks();
55
+
56
+ /// The destructor would join all the threads.
57
+ ~QueueRunner();
58
+
59
+ /// Starts the queue runner with the given session.
60
+ Status Start(Session* sess);
61
+
62
+ /// Starts the queue runner with the given session and sets the run arguments
63
+ /// for sess->Run. It also collects and stores the cost model.
64
+ Status StartAndCollectCostGraph(Session* sess,
65
+ const RunOptions& run_options = RunOptions());
66
+
67
+ /// Starts the queue runner with the given session, and wait for up to the
68
+ /// specified time (in milliseconds) for the queues to start to fill up.
69
+ Status Start(Session* sess, int wait_for_ms);
70
+ Status StartAndCollectCostGraph(Session* session, int wait_for_ms,
71
+ const RunOptions& run_options = RunOptions());
72
+
73
+ /// Requests to stop and runs the cancel op. It would be called in a separate
74
+ /// thread when coordinator is set. If there is no coordinator it should be
75
+ /// called before calling Join.
76
+ void Stop(Session* sess);
77
+
78
+ /// Joins all the threads. Returns okay if all threads run successfully;
79
+ /// otherwise returns the first captured failure status.
80
+ Status Join() final;
81
+
82
+ /// Returns the latest status.
83
+ Status GetStatus();
84
+
85
+ // Returns the stored cost model.
86
+ Status ExportCostGraph(CostGraphDef* cost_graph) const override;
87
+
88
+ private:
89
+ QueueRunner() : coord_(nullptr), stopped_(false), cg_mu_(nullptr) {}
90
+
91
+ // Initializes the instance with the QueueRunnerDef proto.
92
+ Status Init(const QueueRunnerDef& queue_runner_def);
93
+
94
+ // The Run function for each thread.
95
+ void Run(Session* sess, const string& enqueue_op);
96
+
97
+ // Updates the internal status; it only keeps OK or the first unexpected error
98
+ // status.
99
+ void UpdateStatus(const Status& status);
100
+
101
+ bool IsQueueClosed(Status status) const {
102
+ return queue_closed_exception_types_.count(
103
+ static_cast<int>(status.code())) > 0;
104
+ }
105
+
106
+ bool IsRunning() const override { return !stopped_; }
107
+
108
+ void SetRunArgumentsAndCostGraph(const RunOptions& run_options);
109
+
110
+ Status RealRun(Session* sess, const string& op, bool update_costs);
111
+
112
+ string queue_name_;
113
+ std::vector<string> enqueue_op_names_;
114
+ string close_op_name_;
115
+ string cancel_op_name_;
116
+ // code::Code casted to int to avoid a hash function.
117
+ std::unordered_set<int> queue_closed_exception_types_;
118
+
119
+ std::unique_ptr<thread::ThreadPool> thread_pool_;
120
+ mutex mu_;
121
+ int runs_ = 0;
122
+ Status status_ TF_GUARDED_BY(mu_);
123
+ Status enqueue_status_ TF_GUARDED_BY(mu_);
124
+ std::unique_ptr<BlockingCounter> counter_;
125
+
126
+ Coordinator* coord_;
127
+
128
+ std::atomic<bool> stopped_;
129
+
130
+ mutex cb_mu_;
131
+ std::vector<std::function<void(Status)>> callbacks_;
132
+
133
+ mutable std::unique_ptr<mutex> cg_mu_;
134
+ std::unique_ptr<CostGraphDef> cost_graph_ TF_GUARDED_BY(cg_mu_);
135
+ RunOptions run_options_;
136
+ };
137
+
138
+ } // namespace tensorflow
139
+
140
+ #endif // TENSORFLOW_CC_TRAINING_QUEUE_RUNNER_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/build_xla_ops_pass.h ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_BUILD_XLA_OPS_PASS_H_
17
+ #define TENSORFLOW_COMPILER_JIT_BUILD_XLA_OPS_PASS_H_
18
+
19
+ #include "absl/types/optional.h"
20
+ #include "tensorflow/core/common_runtime/optimization_registry.h"
21
+ #include "tensorflow/core/lib/core/status.h"
22
+
23
+ namespace tensorflow {
24
+
25
+ // Replaces TF function calls marked with `_XlaCompiledKernel` with _XlaCompile
26
+ // and _XlaRun nodes (which compile and launch, respectively, the corresponding
27
+ // HLO module).
28
+ class BuildXlaOpsPass : public GraphOptimizationPass {
29
+ public:
30
+ // If enable_lazy_compilation is not nullopt then *enable_lazy_compilation
31
+ // overrides --tf_xla_enable_lazy_compilation flag in deciding whether lazy
32
+ // compilation is enabled.
33
+ explicit BuildXlaOpsPass(
34
+ std::optional<bool> enable_lazy_compilation = std::nullopt)
35
+ : enable_lazy_compilation_(enable_lazy_compilation) {}
36
+
37
+ Status Run(const GraphOptimizationPassOptions& options) override;
38
+
39
+ private:
40
+ std::optional<bool> enable_lazy_compilation_;
41
+ };
42
+
43
+ } // namespace tensorflow
44
+
45
+ #endif // TENSORFLOW_COMPILER_JIT_BUILD_XLA_OPS_PASS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/clone_constants_for_better_clustering.h ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_CLONE_CONSTANTS_FOR_BETTER_CLUSTERING_H_
17
+ #define TENSORFLOW_COMPILER_JIT_CLONE_CONSTANTS_FOR_BETTER_CLUSTERING_H_
18
+
19
+ #include "absl/container/flat_hash_set.h"
20
+ #include "tensorflow/core/common_runtime/optimization_registry.h"
21
+
22
+ namespace tensorflow {
23
+ // Clones small host constants in the graph to make it easier to form larger
24
+ // clusters.
25
+ //
26
+ // This helps us in two ways:
27
+ //
28
+ // - It reduces dependencies between clusters. Let's say a constant C is used
29
+ // by nodes X and Y. If X and Y are put in different clusters (for whatever
30
+ // reason) Y's cluster now has to wait for all the operations in X's cluster
31
+ // to finish before it starts running.
32
+ //
33
+ // - It lets us create bigger clusters in multi-GPU benchmarks. Consider the
34
+ // following graph:
35
+ //
36
+ // digraph {
37
+ // Const -> GPU_1
38
+ // Const -> GPU_0_Y
39
+ // GPU_0_X -> GPU_0_Y
40
+ // }
41
+ //
42
+ // We'd cluster Const and GPU_1 together (and place it on GPU_1), and this
43
+ // will block us from clustering GPU_0_X and GPU_0_Y together since that
44
+ // would increase the amount of work on GPU 0 waiting on work on GPU 1.
45
+ // However, cloning Const into two copies, one for GPU_0_Y and one for GPU_1
46
+ // will let us create one cluster containing {Const/copy_0, GPU_1} and
47
+ // another containing {Const/copy_1, GPU_0_X, GPU_0_Y}.
48
+ //
49
+ // We only clone small host constants now to avoid increasing memory consumption
50
+ // too much. Moreover, in practice the constants we have to duplicate are
51
+ // things like the `perm` input to `Transpose` and the `size` input to `Slice`
52
+ // which tend to be small anyway.
53
+
54
+ class CloneConstantsForBetterClusteringPass : public GraphOptimizationPass {
55
+ public:
56
+ CloneConstantsForBetterClusteringPass() = default;
57
+
58
+ Status Run(const GraphOptimizationPassOptions& options) override;
59
+ };
60
+ } // namespace tensorflow
61
+
62
+ #endif // TENSORFLOW_COMPILER_JIT_CLONE_CONSTANTS_FOR_BETTER_CLUSTERING_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/cluster_scoping_pass.h ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_CLUSTER_SCOPING_PASS_H_
17
+ #define TENSORFLOW_COMPILER_JIT_CLUSTER_SCOPING_PASS_H_
18
+
19
+ #include "tensorflow/core/common_runtime/optimization_registry.h"
20
+
21
+ namespace tensorflow {
22
+
23
+ // This pass adds scopes to nodes in the _XlaInternalScope attribute to guide
24
+ // the later clustering passes. A major reason to do this is to prevent the
25
+ // clustering from losing critical parallelism in the Tensorflow graph, which
26
+ // can incur great performance degradation.
27
+ //
28
+ // This pass must be run before MarkForCompilationPass, as it stores the
29
+ // scoping information that MarkForCompilationPass will need to respect for
30
+ // clustering decision.
31
+ class ClusterScopingPass : public GraphOptimizationPass {
32
+ public:
33
+ Status Run(const GraphOptimizationPassOptions& options) override;
34
+ };
35
+
36
+ } // namespace tensorflow
37
+
38
+ #endif // TENSORFLOW_COMPILER_JIT_CLUSTER_SCOPING_PASS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/compilability_check_util.h ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_COMPILABILITY_CHECK_UTIL_H_
17
+ #define TENSORFLOW_COMPILER_JIT_COMPILABILITY_CHECK_UTIL_H_
18
+
19
+ #include <string>
20
+
21
+ #include "absl/algorithm/container.h"
22
+ #include "absl/strings/string_view.h"
23
+ #include "absl/types/optional.h"
24
+ #include "tensorflow/compiler/jit/defs.h"
25
+ #include "tensorflow/compiler/jit/device_util.h"
26
+ #include "tensorflow/compiler/jit/flags.h"
27
+ #include "tensorflow/compiler/jit/resource_operation_safety_analysis.h"
28
+ #include "tensorflow/compiler/tf2xla/const_analysis.h"
29
+ #include "tensorflow/compiler/tf2xla/resource_operation_table.h"
30
+ #include "tensorflow/compiler/tf2xla/xla_op_registry.h"
31
+ #include "xla/service/graphcycles/graphcycles.h"
32
+ #include "xla/statusor.h"
33
+ #include "xla/union_find.h"
34
+ #include "xla/util.h"
35
+ #include "tensorflow/core/common_runtime/function.h"
36
+ #include "tensorflow/core/common_runtime/graph_constructor.h"
37
+ #include "tensorflow/core/framework/attr_value.pb.h"
38
+ #include "tensorflow/core/framework/bounds_check.h"
39
+ #include "tensorflow/core/framework/function.h"
40
+ #include "tensorflow/core/framework/graph_def_util.h"
41
+ #include "tensorflow/core/framework/memory_types.h"
42
+ #include "tensorflow/core/framework/node_def.pb.h"
43
+ #include "tensorflow/core/framework/op_kernel.h"
44
+ #include "tensorflow/core/framework/types.h"
45
+ #include "tensorflow/core/framework/types.pb.h"
46
+ #include "tensorflow/core/graph/algorithm.h"
47
+ #include "tensorflow/core/graph/control_flow.h"
48
+ #include "tensorflow/core/graph/graph.h"
49
+ #include "tensorflow/core/lib/gtl/cleanup.h"
50
+ #include "tensorflow/core/lib/strings/stringprintf.h"
51
+ #include "tensorflow/core/public/version.h"
52
+ #include "tensorflow/core/util/dump_graph.h"
53
+
54
+ namespace tensorflow {
55
+ // Checks whether a TF node can be compiled or not. "Recursive" as in for call
56
+ // and functional while nodes it recursively checks whether the callee functions
57
+ // can be compiled.
58
+ class RecursiveCompilabilityChecker {
59
+ public:
60
+ // Contains node name and function name. If the node is not inside a function
61
+ // body, function name is an empty string.
62
+ struct StackFrame {
63
+ std::string name;
64
+ std::string function_name;
65
+ std::shared_ptr<AbstractStackTrace> stack_trace;
66
+ };
67
+
68
+ // Contains information about uncompilable node inside a function body.
69
+ struct UncompilableNodeInfo {
70
+ std::string name;
71
+ // A list representing a stacktrace from the highest level node in
72
+ // increasing call depth to immediate node that fails the
73
+ // compilability checker.
74
+ std::vector<StackFrame> stack_trace;
75
+ std::string uncompilable_reason;
76
+ };
77
+
78
+ // Aggregates information about what kinds of ops are allowed.
79
+ struct OperationFilter { // TODO(lzr): Add AllowEverything() helper.
80
+ // Whether resource variable ops are allowed are allowed in callees. We do
81
+ // not allow resource variable ops in called functions (either as direct TF
82
+ // calls or as higher order control flow ops) because we do not yet model
83
+ // their memory effects in jit/resource_operation_safety_analysis.
84
+ bool allow_resource_ops_in_called_functions = false;
85
+
86
+ // Whether Stack operations are allowed. We avoid auto-clustering Stack
87
+ // operations in general because we do not support snapshotting them.
88
+ //
89
+ // TODO(b/112837194): This restriction can be lifted with some work.
90
+ bool allow_stack_ops = false;
91
+
92
+ // Whether TensorArray operations are allowed. We avoid auto-clustering
93
+ // TensorArray operations in general because we do not support snapshotting
94
+ // them.
95
+ //
96
+ // TODO(b/112837194): This restriction can be lifted with some work.
97
+ bool allow_tensor_array_ops = false;
98
+
99
+ // Whether stateful RNG ops are allowed. XLA's RNG does not have the same
100
+ // seeding behavior as TensorFlow's RNG (b/34749654). So we avoid
101
+ // auto-clustering stateful RNG ops.
102
+ bool allow_stateful_rng_ops = false;
103
+
104
+ // TODO(b/118970344): Whether ControlTrigger ops are allowed. It is unsound
105
+ // to cluster ControlTrigger because of how we use deadness analysis.
106
+ bool allow_control_trigger = false;
107
+
108
+ // Whether it is okay to "cluster" Assert and CheckNumerics by simply
109
+ // removing them (they're not removed during clustering, but their
110
+ // XlaOpKernel is a no-op kernel). We avoid auto-clustering these ops so
111
+ // that the user is not surprised when XLA is implicitly enabled. If the
112
+ // user explicitly specifies to use XLA, it is fine to resort to a dummy
113
+ // implementation. Currently Assert and CheckNumerics ops have dummy XLA
114
+ // implementations.
115
+ bool allow_eliding_assert_and_checknumerics_ops = false;
116
+
117
+ // Whether ops that produce or consume DT_VARIANT values are allowed. We
118
+ // don't auto-cluster these ops because we don't yet support live-in or
119
+ // live-out DT_VARIANT values.
120
+ bool allow_ops_producing_or_consuming_variant = false;
121
+
122
+ // Whether ops known to be slow on XLA-GPU should be considered compilable.
123
+ bool allow_slow_ops = false;
124
+
125
+ // Whether ops known to have numerical accuracy issues should be considered
126
+ // compilable..
127
+ bool allow_inaccurate_ops = false;
128
+
129
+ // Require the function to be always compilable, regardless whether some
130
+ // control flow branches might be dead for a given input.
131
+ bool require_always_compilable = false;
132
+
133
+ // Whether string constants are compilable.
134
+ bool allow_string_consts = true;
135
+
136
+ // Whether to allow the compilation of CollectiveReduceV2Op.
137
+ bool allow_collective_reduce_v2 = true;
138
+
139
+ // Whether to allow the compilation of WhereOp.
140
+ bool allow_where_op = true;
141
+
142
+ // Whether to allow the compilation of UniqueOp. Compilation of the UniqueOp
143
+ // generates output with bounded dynamic shape that may cause failures with
144
+ // auto clustering.
145
+ // TODO(b/209813421): Enable tf.unique during
146
+ // autoclustering once all failures are rfixed.
147
+ bool allow_unique_op = true;
148
+
149
+ // Whether ops that are marked as outside compiled are always considered
150
+ // compilable.
151
+ // TODO(b/191502757): Make this behavior true by default and remove this
152
+ // option once inference converter supports outside compilation.
153
+ bool allow_outside_compiled = false;
154
+ };
155
+
156
+ RecursiveCompilabilityChecker(OperationFilter op_filter,
157
+ DeviceType jit_device_type)
158
+ : op_filter_(std::move(op_filter)),
159
+ jit_device_type_(std::move(jit_device_type)) {}
160
+
161
+ using UncompilableNodesMap =
162
+ std::map<std::string,
163
+ std::pair<NameAttrList, std::vector<UncompilableNodeInfo>>>;
164
+
165
+ // Returns a map where the key is the function identifier(short debug
166
+ // string) of the function encapsulating the uncompilable nodes, and the
167
+ // value is a pair of NameAttrList of the function and a vector of
168
+ // uncompilable node info. When uncompilable node is not inside any
169
+ // function call nodes, then key is a ShortDebugString() of an empty
170
+ // NameAttrList.
171
+ //
172
+ // Also, when `node` is inside a function body, users can set
173
+ // `node_stack_trace` to provide an additional context for `node`'s
174
+ // placement within the outer most graph.
175
+ UncompilableNodesMap FindUncompilableNodes(
176
+ const Node& node, FunctionLibraryRuntime* lib_runtime,
177
+ const std::vector<StackFrame>* node_stack_trace = nullptr) const;
178
+
179
+ // Returns true if `node` can be compiled by XLA.
180
+ bool IsCompilableNode(const Node& node,
181
+ FunctionLibraryRuntime* lib_runtime) const {
182
+ std::vector<StackFrameView> stack_trace;
183
+ stack_trace.emplace_back(StackFrameView{node.name(), ""});
184
+ return IsCompilableNode(node, lib_runtime, &stack_trace);
185
+ }
186
+
187
+ // Returns true if XLA supports this Op, but we don't want to cluster it (ie:
188
+ // due to performance or correctness concerns).
189
+ bool OpIsInaccurate(const Node& node) const;
190
+ bool OpIsSlow(const Node& node) const;
191
+
192
+ private:
193
+ struct StackFrameView {
194
+ absl::string_view name;
195
+ absl::string_view function_name;
196
+ std::shared_ptr<AbstractStackTrace> stack_trace;
197
+ };
198
+
199
+ bool IsCompilableNode(
200
+ const Node& node, FunctionLibraryRuntime* lib_runtime,
201
+ std::vector<StackFrameView>* stack_trace,
202
+ NameAttrList* encapsulating_function = nullptr,
203
+ UncompilableNodesMap* uncompilable_nodes = nullptr) const;
204
+ bool IsCompilableCall(
205
+ const NodeDef& call_def, FunctionLibraryRuntime* lib_runtime,
206
+ std::vector<StackFrameView>* stack_trace,
207
+ NameAttrList* encapsulating_function = nullptr,
208
+ UncompilableNodesMap* uncompilable_nodes = nullptr) const;
209
+ bool IsCompilableIf(const Node& if_node, FunctionLibraryRuntime* lib_runtime,
210
+ std::vector<StackFrameView>* stack_trace,
211
+ NameAttrList* encapsulating_function,
212
+ UncompilableNodesMap* uncompilable_nodes) const;
213
+ bool IsCompilableWhile(const Node& while_node,
214
+ FunctionLibraryRuntime* lib_runtime,
215
+ std::vector<StackFrameView>* stack_trace,
216
+ NameAttrList* encapsulating_function,
217
+ UncompilableNodesMap* uncompilable_nodes) const;
218
+
219
+ // Tests whether 'case_node' is compilable. Every operator in all branches
220
+ // must be compilable.
221
+ bool IsCompilableCase(const Node& case_node,
222
+ FunctionLibraryRuntime* lib_runtime,
223
+ std::vector<StackFrameView>* stack_trace,
224
+ NameAttrList* encapsulating_function,
225
+ UncompilableNodesMap* uncompilable_nodes) const;
226
+
227
+ // Returns compilability of node def retrieved from `node`'s attribute with
228
+ // name `attr_name`.
229
+ bool ExtractNodeDefAndCheckCompilability(
230
+ const Node& node, const std::string& attr_name,
231
+ const std::string& call_name, NameAttrList* encapsulating_function,
232
+ FunctionLibraryRuntime* lib_runtime,
233
+ std::vector<StackFrameView>* stack_trace,
234
+ UncompilableNodesMap* uncompilable_nodes) const;
235
+
236
+ bool IsStackOp(const Node& node) const {
237
+ const XlaResourceOpInfo* op_info =
238
+ GetResourceOpInfoForOp(node.type_string());
239
+ return op_info && op_info->resource_kind() == XlaResourceKind::kStack;
240
+ }
241
+
242
+ bool IsTensorArrayOp(const Node& node) const {
243
+ const XlaResourceOpInfo* op_info =
244
+ GetResourceOpInfoForOp(node.type_string());
245
+ return op_info && op_info->resource_kind() == XlaResourceKind::kTensorArray;
246
+ }
247
+
248
+ bool IsAssertOrCheckNumerics(absl::string_view op_name) const {
249
+ return op_name == "Assert" || op_name == "CheckNumerics";
250
+ }
251
+
252
+ bool IsStatefulRandomOp(absl::string_view op_name) const {
253
+ return op_name == "RandomUniform" || op_name == "RandomShuffle" ||
254
+ op_name == "RandomUniformInt" || op_name == "RandomStandardNormal" ||
255
+ op_name == "TruncatedNormal" || op_name == "Multinomial";
256
+ }
257
+
258
+ bool OpProducesOrConsumesVariant(const Node& node) const {
259
+ auto is_variant = [](DataType dtype) { return dtype == DT_VARIANT; };
260
+ return absl::c_any_of(node.input_types(), is_variant) ||
261
+ absl::c_any_of(node.output_types(), is_variant);
262
+ }
263
+
264
+ bool HasXLAKernel(const Node& node,
265
+ string* uncompilable_reason = nullptr) const;
266
+
267
+ static void MaybeMarkUncompilableNode(
268
+ const absl::string_view reason,
269
+ const std::vector<StackFrameView>& stack_trace,
270
+ NameAttrList* encapsulating_function,
271
+ UncompilableNodesMap* uncompilable_nodes_map);
272
+
273
+ // Make sure we don't recurse infinitely on recursive functions.
274
+ const size_t kMaxRecursionDepth = 50;
275
+
276
+ const OperationFilter op_filter_;
277
+ const DeviceType jit_device_type_;
278
+ };
279
+
280
+ RecursiveCompilabilityChecker::OperationFilter CreateOperationFilter(
281
+ const XlaOpRegistry::DeviceRegistration& registration);
282
+
283
+ // Given a FunctionLibraryRuntime and a `function`, returns this function's body
284
+ // in `fbody` as well as the indices of its constant and resource arguments.
285
+ // `fbody` is owned by `flr`.
286
+ // `constant_arg_indices` and `resource_arg_indices` should be empty vector.
287
+ // They are sorted in ascending order on this function's return.
288
+ Status GetBodyAndConstantsAndResources(FunctionLibraryRuntime* flr,
289
+ const NameAttrList& function,
290
+ const FunctionBody** fbody,
291
+ std::vector<int>* constant_arg_indices,
292
+ std::vector<int>* resource_arg_indices);
293
+
294
+ // Given a NodeDef `node_def` returns true iff `node_def` has kXlaCompileAttr
295
+ // set.
296
+ bool CanCreateXlaKernel(const NodeDef& node_def);
297
+
298
+ // Returns memory types for the input.
299
+ // `constant_arg_indices` and `resource_arg_indices` are sorted arrays of
300
+ // indices corresponding to constant and resource arguments respectively.
301
+ //
302
+ // One might wonder, about the case where a compile-time constant argument
303
+ // (which must be in host memory) is also used as an input into an op,
304
+ // e.g. `Add`, that expects its inputs in device memory. Here is how it
305
+ // works now.
306
+ // First, what do we mean by "op expects an input in XYZ memory"?
307
+ // There are two types of "ops" here: the tf2xla kernel and the HLO
308
+ // computation it builds. The tf2xla kernel needs to retrieve the actual
309
+ // numeric value of the compile-time constant tensors, so it really expects
310
+ // them to be on in host memory. However, for other inputs, it refers to them
311
+ // using xla::ComputationDataHandle, which is just a symbolic handle that
312
+ // xla::ComputationBuilder assigns. How does this handle gets assigned for
313
+ // constant arguments? Even constant arguments get an _Arg node in the graph
314
+ // instantiated for Function compilation. The tf2xla kernel for constant _Arg
315
+ // nodes takes the constant value, converts it to XlaLiteral, and feeds it
316
+ // to xla::ComputationBuilder.ConstantLiteral, which returns the handle. This
317
+ // constant XlaLiteral is included in the HLO graph, and subsequently, in
318
+ // the actual executable, which is copied to the device before being
319
+ // executed. Thus, when this executable runs, the constant is available in
320
+ // device memory.
321
+ tensorflow::MemoryTypeVector GetInputMemoryTypes(
322
+ const tensorflow::FunctionBody* fbody,
323
+ absl::Span<int const> constant_arg_indices,
324
+ absl::Span<int const> resource_arg_indices);
325
+
326
+ // Returns output memory types.
327
+ //
328
+ // XlaLaunch kernel keeps all outputs (including constants, which it copies),
329
+ // in device memory except for resources.
330
+ tensorflow::MemoryTypeVector GetOutputMemoryTypes(
331
+ const tensorflow::FunctionBody* fbody);
332
+
333
+ // Check whether graph can trigger XLA compilation.
334
+ bool CanTriggerXlaCompilation(const GraphDef& graph);
335
+
336
+ } // namespace tensorflow
337
+
338
+ #endif // TENSORFLOW_COMPILER_JIT_COMPILABILITY_CHECK_UTIL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/deadness_analysis.h ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_DEADNESS_ANALYSIS_H_
17
+ #define TENSORFLOW_COMPILER_JIT_DEADNESS_ANALYSIS_H_
18
+
19
+ #include "tensorflow/core/graph/graph.h"
20
+
21
+ namespace tensorflow {
22
+
23
+ // This analyzes a TensorFlow graph to identify nodes which may have partially
24
+ // dead inputs (i.e. these nodes may have some dead inputs and some alive
25
+ // inputs).
26
+ //
27
+ // For example, the ADD node in the following graph
28
+ //
29
+ // V0 PRED0 V1 PRED1
30
+ // | | | |
31
+ // v v v v
32
+ // SWITCH SWITCH
33
+ // | |
34
+ // +---+ + ---+
35
+ // | |
36
+ // v v
37
+ // ADD
38
+ //
39
+ // can have its inputs independently dead or alive based on the runtime values
40
+ // of PRED0 and PRED1.
41
+ //
42
+ // It is tempting to call this a liveness analysis but I avoided that because
43
+ // "liveness" already has other connotations.
44
+ class DeadnessAnalysis {
45
+ public:
46
+ // An opaque representation of a predicate. DeadnessPredicate
47
+ // instances that compare equal via operator== represent predicates
48
+ // that always evaluate to the same value.
49
+ struct DeadnessPredicate {
50
+ public:
51
+ DeadnessPredicate(const DeadnessPredicate&) = default;
52
+ DeadnessPredicate(DeadnessPredicate&&) = default;
53
+
54
+ DeadnessPredicate& operator=(const DeadnessPredicate&) = default;
55
+ DeadnessPredicate& operator=(DeadnessPredicate&&) = default;
56
+
57
+ bool operator==(const DeadnessPredicate& other) const {
58
+ return other.pred_ == pred_;
59
+ }
60
+
61
+ bool operator!=(const DeadnessPredicate& other) const {
62
+ return other.pred_ != pred_;
63
+ }
64
+
65
+ private:
66
+ explicit DeadnessPredicate(void* pred) : pred_(pred) {}
67
+
68
+ // This is really a Predicate*, but we don't want to expose that
69
+ // implementation detail to our clients. `pred_` has pointer equality so we
70
+ // can just compare the pointer in operator== and operator!=.
71
+ void* pred_;
72
+
73
+ friend class DeadnessAnalysis;
74
+ };
75
+
76
+ virtual tsl::StatusOr<DeadnessPredicate> GetPredicateFor(Node* n,
77
+ int oidx) const = 0;
78
+
79
+ // Prints out the internal state of this instance. For debugging purposes
80
+ // only.
81
+ virtual void Print() const = 0;
82
+ virtual ~DeadnessAnalysis();
83
+
84
+ string DebugString(DeadnessPredicate predicate) const;
85
+
86
+ // Run the deadness analysis over `graph` and returns an error or a populated
87
+ // instance of DeadnessAnalysis in `result`.
88
+ static Status Run(const Graph& graph,
89
+ std::unique_ptr<DeadnessAnalysis>* result);
90
+
91
+ protected:
92
+ static DeadnessPredicate MakeDeadnessPredicate(void* pred) {
93
+ return DeadnessPredicate(pred);
94
+ }
95
+ };
96
+
97
+ } // namespace tensorflow
98
+
99
+ #endif // TENSORFLOW_COMPILER_JIT_DEADNESS_ANALYSIS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/deadness_analysis_internal.h ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_DEADNESS_ANALYSIS_INTERNAL_H_
17
+ #define TENSORFLOW_COMPILER_JIT_DEADNESS_ANALYSIS_INTERNAL_H_
18
+
19
+ #include "absl/container/flat_hash_map.h"
20
+ #include "tensorflow/core/graph/tensor_id.h"
21
+
22
+ namespace tensorflow {
23
+ namespace deadness_analysis_internal {
24
+
25
+ // Returns a map describing the predicate each Tensor was mapped to. For
26
+ // testing purposes only.
27
+ using PredicateMapTy = absl::flat_hash_map<TensorId, string, TensorId::Hasher>;
28
+ Status ComputePredicates(const Graph& graph, PredicateMapTy* out_predicate_map,
29
+ bool enable_optimistic = true);
30
+
31
+ } // namespace deadness_analysis_internal
32
+ } // namespace tensorflow
33
+
34
+ #endif // TENSORFLOW_COMPILER_JIT_DEADNESS_ANALYSIS_INTERNAL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/defs.h ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ // Provides definitions needed for use of the TensorFlow XLA
17
+ // device.
18
+
19
+ #ifndef TENSORFLOW_COMPILER_JIT_DEFS_H_
20
+ #define TENSORFLOW_COMPILER_JIT_DEFS_H_
21
+
22
+ namespace tensorflow {
23
+
24
+ // Name of attribute used to tag operators for compilation with XLA
25
+
26
+ // Implies must-compile semantics: either it will be compiled
27
+ // with XLA, or an error will be thrown.
28
+ extern const char* const kXlaMustCompileAttr; // "_XlaMustCompile"
29
+
30
+ // Implies auto-clustering: tagged nodes will be clustered and compiled with XLA
31
+ // on a best-effort basis.
32
+ extern const char* const kXlaCompileAttr; // "_XlaCompile"
33
+
34
+ // Implies auto-clustering within the given scope.
35
+ extern const char* const kXlaScopeAttr; // "_XlaScope"
36
+ extern const char* const kXlaInternalScopeAttr; // "_XlaInternalScope"
37
+
38
+ // The id of the compiled cluster.
39
+ extern const char* const kXlaClusterIdAttr; // "_xla_compile_id"
40
+
41
+ [[deprecated("XLA:CPU/GPU devices are deprecated")]] void
42
+ RequestXlaDevicesCreation();
43
+
44
+ [[deprecated("XLA:CPU/GPU devices are deprecated")]] bool
45
+ XlaDevicesCreationRequired();
46
+
47
+ } // namespace tensorflow
48
+
49
+ #endif // TENSORFLOW_COMPILER_JIT_DEFS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_compilation_cache.h ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_DEVICE_COMPILATION_CACHE_H_
17
+ #define TENSORFLOW_COMPILER_JIT_DEVICE_COMPILATION_CACHE_H_
18
+
19
+ #include <cstdint>
20
+ #include <memory>
21
+ #include <optional>
22
+ #include <string>
23
+ #include <utility>
24
+ #include <variant>
25
+
26
+ #include "absl/strings/str_cat.h"
27
+ #include "tensorflow/compiler/jit/device_compilation_cluster_signature.h"
28
+ #include "tensorflow/compiler/jit/xla_compile_util.h"
29
+ #include "tensorflow/compiler/tf2xla/xla_compiler.h"
30
+ #include "xla/client/local_client.h"
31
+ #include "xla/pjrt/pjrt_client.h"
32
+ #include "tensorflow/core/platform/mutex.h"
33
+
34
+ namespace tensorflow {
35
+ namespace device_compilation_cache_internal {
36
+ template <typename ExecutableType>
37
+ int64_t ExecutableSize(const ExecutableType* executable) {
38
+ return 0;
39
+ }
40
+
41
+ template <>
42
+ inline int64_t ExecutableSize<xla::LocalExecutable>(
43
+ const xla::LocalExecutable* executable) {
44
+ if (executable != nullptr && executable->executable() != nullptr) {
45
+ return executable->executable()->SizeOfGeneratedCodeInBytes();
46
+ }
47
+
48
+ return 0;
49
+ }
50
+
51
+ template <>
52
+ inline int64_t ExecutableSize<xla::PjRtLoadedExecutable>(
53
+ const xla::PjRtLoadedExecutable* executable) {
54
+ if (executable != nullptr) {
55
+ return executable->SizeOfGeneratedCodeInBytes();
56
+ }
57
+
58
+ return 0;
59
+ }
60
+ } // namespace device_compilation_cache_internal
61
+
62
+ // Cache to store compiled HLO, executables and related metadata keyed by
63
+ // `DeviceCompilationClusterSignature`. The cache owns the stored
64
+ // CompilationResults and Executables.
65
+ // Currently no cache eviction policy is implemented and the cache grows without
66
+ // bound.
67
+ template <typename ExecutableType>
68
+ class DeviceCompilationCache {
69
+ public:
70
+ DeviceCompilationCache() = default;
71
+ ~DeviceCompilationCache() = default;
72
+
73
+ using Key = DeviceCompilationClusterSignature;
74
+ struct Value {
75
+ DeviceCompileState compile_state = DeviceCompileState::kUncompiled;
76
+ Status compilation_status;
77
+ int64_t request_count = 0;
78
+ const XlaCompiler::CompilationResult* compilation_result = nullptr;
79
+ ExecutableType* executable = nullptr;
80
+ };
81
+
82
+ // Returns std::nullopt if value for the supplied key is not found. If a value
83
+ // is found, `request_count` is incremented before returning the value.
84
+ std::optional<Value> Lookup(const Key& key) const;
85
+
86
+ // Inserts an empty value if value is not found and returns it. If a value is
87
+ // found, `request_count` is incremented before returning the value.
88
+ Value LookupOrCreate(const Key& key);
89
+
90
+ // Caches `compile_state`, `compilation_status`, `compilation_result` and
91
+ // `executable` and associates them with the provided `key`. Takes ownership
92
+ // of `compilation_result` and `executable`. Does not increment the
93
+ // corresponding `request_count`. Only arguments that are not std::nullopt are
94
+ // updated in the cache.
95
+ void Store(const Key& key, std::optional<DeviceCompileState> compile_state,
96
+ std::optional<Status> compilation_status,
97
+ std::optional<std::unique_ptr<XlaCompiler::CompilationResult>>
98
+ compilation_result,
99
+ std::optional<std::unique_ptr<ExecutableType>> executable);
100
+
101
+ std::string DebugString() const;
102
+
103
+ private:
104
+ // The value associated with a cache entry.
105
+ struct Entry {
106
+ mutable mutex mu;
107
+
108
+ // The current compilation state for this entry.
109
+ DeviceCompileState compile_state TF_GUARDED_BY(mu) =
110
+ DeviceCompileState::kUncompiled;
111
+
112
+ // The number of times a compilation with this signature has been requested.
113
+ int64_t request_count TF_GUARDED_BY(mu) = 0;
114
+
115
+ // Did compilation succeed?
116
+ Status compilation_status TF_GUARDED_BY(mu);
117
+
118
+ // Output of the XlaCompiler.
119
+ std::unique_ptr<XlaCompiler::CompilationResult> compilation_result
120
+ TF_GUARDED_BY(mu);
121
+
122
+ // The XLA executable compiled from <computation>. May be null if no
123
+ // executable has been built.
124
+ std::unique_ptr<ExecutableType> executable TF_GUARDED_BY(mu);
125
+
126
+ std::string DebugString() const {
127
+ mutex_lock lock(mu);
128
+
129
+ int64_t executable_size =
130
+ device_compilation_cache_internal::ExecutableSize<ExecutableType>(
131
+ executable.get());
132
+
133
+ int64_t hlo_module_size = 0;
134
+ if (compilation_result != nullptr &&
135
+ compilation_result->computation != nullptr) {
136
+ hlo_module_size =
137
+ compilation_result->computation->proto().ByteSizeLong();
138
+ }
139
+
140
+ return absl::StrCat(
141
+ "{compile_state: ", compile_state, ", request_count: ", request_count,
142
+ ", compilation_status: ", compilation_status.ToString(),
143
+ ", compilation_result?: ", compilation_result != nullptr,
144
+ ", hlo_module_size: ", hlo_module_size, " bytes",
145
+ ", executable?: ", executable != nullptr,
146
+ ", executable_size: ", executable_size, " bytes}");
147
+ }
148
+ };
149
+
150
+ mutable mutex compile_cache_mu_;
151
+ absl::flat_hash_map<Key, std::unique_ptr<Entry>, Key::Hash> cache_
152
+ TF_GUARDED_BY(compile_cache_mu_);
153
+
154
+ TF_DISALLOW_COPY_AND_ASSIGN(DeviceCompilationCache);
155
+ };
156
+
157
+ template <typename ExecutableType>
158
+ std::optional<typename DeviceCompilationCache<ExecutableType>::Value>
159
+ DeviceCompilationCache<ExecutableType>::Lookup(const Key& key) const {
160
+ // The outer lock protects the existence of the cache entry. It does not
161
+ // protect the contents of the cache entry.
162
+ Entry* entry;
163
+ {
164
+ mutex_lock lock(compile_cache_mu_);
165
+ // Find cache entry.
166
+ auto it = cache_.find(key);
167
+ if (it == cache_.cend()) {
168
+ return std::nullopt;
169
+ }
170
+
171
+ entry = it->second.get();
172
+ }
173
+
174
+ mutex_lock lock(entry->mu);
175
+ Value value = {/*compile_state=*/entry->compile_state,
176
+ /*compilation_status=*/entry->compilation_status,
177
+ /*request_count=*/++entry->request_count,
178
+ /*compilation_result=*/entry->compilation_result.get(),
179
+ /*executable=*/entry->executable.get()};
180
+ return value;
181
+ }
182
+
183
+ template <typename ExecutableType>
184
+ typename DeviceCompilationCache<ExecutableType>::Value
185
+ DeviceCompilationCache<ExecutableType>::LookupOrCreate(const Key& key) {
186
+ // The outer lock protects the existence of the cache entry. It does not
187
+ // protect the contents of the cache entry.
188
+ Entry* entry;
189
+ {
190
+ mutex_lock lock(compile_cache_mu_);
191
+ // Emplace empty cache entry if not found.
192
+ auto it = cache_.emplace(key, std::make_unique<Entry>()).first;
193
+ entry = it->second.get();
194
+ }
195
+
196
+ mutex_lock lock(entry->mu);
197
+ Value value = {/*compile_state=*/entry->compile_state,
198
+ /*compilation_status=*/entry->compilation_status,
199
+ /*request_count=*/++entry->request_count,
200
+ /*compilation_result=*/entry->compilation_result.get(),
201
+ /*executable=*/entry->executable.get()};
202
+ return value;
203
+ }
204
+
205
+ template <typename ExecutableType>
206
+ void DeviceCompilationCache<ExecutableType>::Store(
207
+ const Key& key, std::optional<DeviceCompileState> compile_state,
208
+ std::optional<Status> compilation_status,
209
+ std::optional<std::unique_ptr<XlaCompiler::CompilationResult>>
210
+ compilation_result,
211
+ std::optional<std::unique_ptr<ExecutableType>> executable) {
212
+ Entry* entry;
213
+ {
214
+ mutex_lock lock(compile_cache_mu_);
215
+ // Emplace empty cache entry if not found.
216
+ auto it = cache_.emplace(key, std::make_unique<Entry>()).first;
217
+ entry = it->second.get();
218
+ }
219
+
220
+ {
221
+ mutex_lock lock(entry->mu);
222
+ if (compile_state.has_value()) {
223
+ entry->compile_state = *compile_state;
224
+ }
225
+ if (compilation_status.has_value()) {
226
+ entry->compilation_status = *compilation_status;
227
+ }
228
+ if (compilation_result.has_value()) {
229
+ entry->compilation_result = std::move(*compilation_result);
230
+ }
231
+ if (executable.has_value()) {
232
+ entry->executable = std::move(*executable);
233
+ }
234
+ }
235
+
236
+ VLOG(4) << "Added/updated cache entry: key=" << key.HumanString()
237
+ << ", entry=" << entry->DebugString();
238
+ }
239
+
240
+ template <typename ExecutableType>
241
+ std::string DeviceCompilationCache<ExecutableType>::DebugString() const {
242
+ std::string s = "DeviceCompilationCache<ExecutableType> {\n";
243
+ {
244
+ mutex_lock lock(compile_cache_mu_);
245
+ for (const auto& [key, entry] : cache_) {
246
+ absl::StrAppend(&s, key.HumanString(), " : ", entry->DebugString(),
247
+ ",\n");
248
+ }
249
+ }
250
+ absl::StrAppend(&s, "}");
251
+
252
+ return s;
253
+ }
254
+
255
+ } // namespace tensorflow
256
+
257
+ #endif // TENSORFLOW_COMPILER_JIT_DEVICE_COMPILATION_CACHE_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_compilation_cluster_signature.h ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_DEVICE_COMPILATION_CLUSTER_SIGNATURE_H_
17
+ #define TENSORFLOW_COMPILER_JIT_DEVICE_COMPILATION_CLUSTER_SIGNATURE_H_
18
+
19
+ #include <utility>
20
+ #include <variant>
21
+
22
+ #include "tensorflow/compiler/tf2xla/xla_compiler.h"
23
+
24
+ namespace tensorflow {
25
+
26
+ // Describes the types, shapes and any compile-time constant arguments
27
+ // to a kernel. Key that uniquely identifies a compilation output.
28
+ struct DeviceCompilationClusterSignature {
29
+ // Name of the cluster, built from the function name and it's attributes.
30
+ string name;
31
+
32
+ // List of args (either as a TensorTypeAndShape or as a Tensor value)
33
+ // for compile-time constant arguments to the compilation, ordered by
34
+ // argument number. Tensors must be in host memory.
35
+ using TensorTypeAndShape =
36
+ std::pair<DataType, absl::InlinedVector<int64_t, 4>>;
37
+ absl::InlinedVector<std::variant<Tensor, TensorTypeAndShape>, 8> args;
38
+
39
+ bool operator==(const DeviceCompilationClusterSignature& other) const;
40
+
41
+ struct Hash {
42
+ uint64 operator()(const DeviceCompilationClusterSignature& signature) const;
43
+ };
44
+
45
+ // Returns a human-readable description of the signature.
46
+ string HumanString() const;
47
+
48
+ // Builds the signature for a compilation.
49
+ static StatusOr<DeviceCompilationClusterSignature> Build(
50
+ const NameAttrList& function,
51
+ absl::Span<const XlaCompiler::Argument> args);
52
+ };
53
+
54
+ } // namespace tensorflow
55
+
56
+ #endif // TENSORFLOW_COMPILER_JIT_DEVICE_COMPILATION_CLUSTER_SIGNATURE_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_compilation_profiler.h ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_DEVICE_COMPILATION_PROFILER_H_
17
+ #define TENSORFLOW_COMPILER_JIT_DEVICE_COMPILATION_PROFILER_H_
18
+
19
+ #include <cstdint>
20
+ #include <string>
21
+
22
+ #include "tensorflow/compiler/jit/xla_compile_util.h"
23
+ #include "tensorflow/core/framework/attr_value.pb.h"
24
+
25
+ namespace tensorflow {
26
+
27
+ // Tracks statistics for device compilation and uses these to determine whether
28
+ // the given cluster should be compiled or not.
29
+ class DeviceCompilationProfiler : public ResourceBase {
30
+ public:
31
+ DeviceCompilationProfiler() = default;
32
+ ~DeviceCompilationProfiler() override;
33
+
34
+ struct ClusterCompileStats {
35
+ // Number of times the cluster has been (re-)compiled.
36
+ int64_t compile_count = 0;
37
+
38
+ // The number of times this cluster has been executed.
39
+ int64_t execution_count = 0;
40
+
41
+ // Cumulative time spent compiling the cluster.
42
+ int64_t cumulative_compile_time_us = 0;
43
+
44
+ // True if we have decided that this cluster is too dynamic (i.e. its shapes
45
+ // change too frequently) to profitably JIT compile. Once a cluster is
46
+ // tagged megamorphic, it stays megamorphic forever.
47
+ bool is_megamorphic = false;
48
+
49
+ std::string DebugString() const {
50
+ return absl::StrCat(
51
+ "DeviceCompilationProfiler::ClusterCompileStats {compile_count=",
52
+ compile_count, ", execution_count=", execution_count,
53
+ ", cumulative_compile_time_us=", cumulative_compile_time_us,
54
+ ", is_megamorphic=", is_megamorphic, "}");
55
+ }
56
+ };
57
+
58
+ // Returns the compilation statistics for the given cluster.
59
+ StatusOr<ClusterCompileStats> GetCompileStats(
60
+ const NameAttrList& function) const;
61
+
62
+ // Determines whether the cluster should be compiled. Creates and inserts an
63
+ // entry into stats (also calls `RegisterExecution`) for `function` if it
64
+ // doesn't already exist.
65
+ virtual bool ShouldCompileCluster(const NameAttrList& function,
66
+ DeviceCompileMode compile_mode,
67
+ int64_t current_request_count);
68
+
69
+ // Registers a cluster execution. Increments the execution count for the given
70
+ // cluster and also determines whether the cluster has gone megamorphic (and
71
+ // sets the megamorphic bit accordingly).
72
+ void RegisterExecution(const NameAttrList& function);
73
+
74
+ // Registers a cluster compilation. Increments the compilation count and
75
+ // accumulates the compile time for the given cluster. Also broadcasts an
76
+ // XlaJitCompilationActivity.
77
+ virtual Status RegisterCompilation(const NameAttrList& function,
78
+ int64_t compile_time_us,
79
+ bool used_persistent_cache);
80
+
81
+ void IncrementOngoingAsyncCompilations();
82
+ void DecrementOngoingAsyncCompilations();
83
+ int64_t GetNumOngoingAsyncCompilations() const;
84
+ std::string DebugString() const override;
85
+
86
+ private:
87
+ mutable mutex mu_;
88
+
89
+ // Maps cluster names to compilation statistics for said cluster.
90
+ absl::flat_hash_map<std::string, ClusterCompileStats> cluster_compile_stats_
91
+ TF_GUARDED_BY(mu_);
92
+
93
+ int64_t num_ongoing_compilations_ TF_GUARDED_BY(mu_) = 0;
94
+
95
+ TF_DISALLOW_COPY_AND_ASSIGN(DeviceCompilationProfiler);
96
+ };
97
+
98
+ } // namespace tensorflow
99
+
100
+ #endif // TENSORFLOW_COMPILER_JIT_DEVICE_COMPILATION_PROFILER_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_compiler.h ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_DEVICE_COMPILER_H_
17
+ #define TENSORFLOW_COMPILER_JIT_DEVICE_COMPILER_H_
18
+
19
+ #include <memory>
20
+ #include <numeric>
21
+ #include <optional>
22
+ #include <string>
23
+ #include <utility>
24
+ #include <variant>
25
+ #include <vector>
26
+
27
+ #include "absl/base/call_once.h"
28
+ #include "absl/container/flat_hash_map.h"
29
+ #include "absl/types/optional.h"
30
+ #include "absl/types/span.h"
31
+ #include "tensorflow/compiler/jit/device_compilation_cache.h"
32
+ #include "tensorflow/compiler/jit/device_compilation_cluster_signature.h"
33
+ #include "tensorflow/compiler/jit/device_compilation_profiler.h"
34
+ #include "tensorflow/compiler/jit/device_compiler_client.h"
35
+ #include "tensorflow/compiler/jit/device_executable_persistor.h"
36
+ #include "tensorflow/compiler/jit/flags.h"
37
+ #include "tensorflow/compiler/jit/tf_graph_to_hlo_compiler.h"
38
+ #include "tensorflow/compiler/jit/xla_compile_util.h"
39
+ #include "tensorflow/compiler/tf2xla/xla_compiler.h"
40
+ #include "xla/client/local_client.h"
41
+ #include "tensorflow/core/framework/op_kernel.h"
42
+ #include "tensorflow/core/lib/core/threadpool.h"
43
+ #include "tensorflow/core/platform/mutex.h"
44
+ #include "tensorflow/core/platform/thread_annotations.h"
45
+
46
+ namespace tensorflow {
47
+
48
+ // Compiles/lowers a given Tensorflow graph/function/cluster into a compiled XLA
49
+ // compilation (HLO) using the XlaCompiler and compiles the resulting
50
+ // XlaCompilationResult into an `ExecutableType` (eg. xla::LocalExecutable) by
51
+ // calling `ClientType` (eg. xla::LocalClient).
52
+ //
53
+ // Caches the compiled XlaCompilationResult and Executable using a
54
+ // DeviceCompilationCache. Compilation is done only when there's a cache miss.
55
+ //
56
+ // Uses the DeviceExecutablePersistor class for persistence and tries to load a
57
+ // serialized executable from disk upon a request for compilation. If the
58
+ // appropriate executable isn't found on disk, compiles the given Tensorflow
59
+ // function/graph/cluster into an XlaCompilationResult (HLO) and
60
+ // `ExecutableType` and tries saving/persisting the compiled HLO and executable
61
+ // to disk.
62
+ //
63
+ // Since XLA computations must have static shapes, DeviceCompiler generates a
64
+ // new XLA computation for each new set of input shapes.
65
+ // TODO(b/255826209): De-templatize once we've moved to Device API completely.
66
+ template <typename ExecutableType, typename ClientType>
67
+ class DeviceCompiler : public ResourceBase {
68
+ public:
69
+ DeviceCompiler(
70
+ std::unique_ptr<DeviceExecutablePersistor<ExecutableType, ClientType>>
71
+ persistor,
72
+ std::unique_ptr<DeviceCompilerClient<ExecutableType, ClientType>>
73
+ compiler_client);
74
+ ~DeviceCompiler() override;
75
+
76
+ enum class CompileScope {
77
+ kOp,
78
+ kFunction,
79
+ };
80
+
81
+ // Compiles a function into a XlaCompiler::CompilationResult that can be used
82
+ // to execute an XLA Computation. Compilation results are cached. Compilation
83
+ // is skipped if there is a cache hit. `function` is the name of a Tensorflow
84
+ // function to compile. `args` is a description of the arguments to the
85
+ // computation.
86
+ //
87
+ // `compile_mode` controls the behavior of the compilation cache on a cache
88
+ // miss. If `compile_mode` is `kLazy` then, based on some profitability
89
+ // heuristics, the compilation cache may decide not to compile the cluster at
90
+ // this time. In this case it returns null into both `out_compilation_result`
91
+ // and `out_executable`. If `compile_mode` is `kStrict` then the compilation
92
+ // cache always attempts the compilation on a cache miss. If compilation mode
93
+ // is 'kAsync' compilation of the cluster happens in the background while the
94
+ // fallback path executes.
95
+ //
96
+ // The result of compilation is written to `*out_compilation_result`, which
97
+ // must be non-null. If `out_executable` is non-null, also builds an
98
+ // `ExecutableType` and sets `out_executable` to point to it. The
99
+ // resulting executable pointer may be null if the computation has no
100
+ // non-constant outputs.
101
+ Status CompileIfNeeded(
102
+ const XlaCompiler::Options& options, const NameAttrList& function,
103
+ const std::vector<XlaCompiler::Argument>& args,
104
+ const XlaCompiler::CompileOptions& compile_options,
105
+ DeviceCompileMode compile_mode, DeviceCompilationProfiler* profiler,
106
+ const XlaCompiler::CompilationResult** out_compilation_result,
107
+ ExecutableType** out_executable);
108
+
109
+ // As above, but for a single op.
110
+ Status CompileSingleOpIfNeeded(
111
+ const XlaCompiler::Options& options,
112
+ const std::vector<XlaCompiler::Argument>& args,
113
+ const XlaCompiler::CompileOptions& compile_options, OpKernelContext* ctx,
114
+ DeviceCompilationProfiler* profiler,
115
+ const XlaCompiler::CompilationResult** out_compilation_result,
116
+ ExecutableType** out_executable);
117
+
118
+ ClientType* client() const { return compiler_client_->client(); }
119
+ const DeviceType& device_type() const { return persistor_->device_type(); }
120
+ DeviceCompilationCache<ExecutableType>* cache() { return cache_.get(); }
121
+ DeviceExecutablePersistor<ExecutableType, ClientType>* persistor() {
122
+ return persistor_.get();
123
+ }
124
+ DeviceCompilerClient<ExecutableType, ClientType>* compiler_client() {
125
+ return compiler_client_.get();
126
+ }
127
+
128
+ string DebugString() const override;
129
+
130
+ private:
131
+ // Common implementation of Compile and CompileSingleOp. The `OpKernelContext`
132
+ // parameter is always null for the former.
133
+ Status CompileImpl(
134
+ const XlaCompiler::CompileOptions& compile_options,
135
+ const XlaCompiler::Options& options, const NameAttrList& function,
136
+ const std::vector<XlaCompiler::Argument>& args, CompileScope scope,
137
+ DeviceCompileMode compile_mode, OpKernelContext* ctx,
138
+ DeviceCompilationProfiler* profiler,
139
+ const XlaCompiler::CompilationResult** out_compilation_result,
140
+ ExecutableType** out_executable);
141
+
142
+ StatusOr<typename DeviceCompilationCache<ExecutableType>::Value>
143
+ CompileStrict(
144
+ const DeviceCompilationClusterSignature& sig,
145
+ const XlaCompiler::CompileOptions& compile_options,
146
+ const XlaCompiler::Options& options,
147
+ const std::vector<XlaCompiler::Argument>& args,
148
+ const NameAttrList& function,
149
+ typename DeviceCompilationCache<ExecutableType>::Value cache_value,
150
+ CompileScope scope, OpKernelContext* ctx,
151
+ DeviceCompilationProfiler* profiler, mutex* mu)
152
+ TF_EXCLUSIVE_LOCKS_REQUIRED(*mu);
153
+
154
+ Status CompileAsynchronous(const DeviceCompilationClusterSignature& sig,
155
+ const XlaCompiler::CompileOptions& compile_options,
156
+ const XlaCompiler::Options& options,
157
+ const std::vector<XlaCompiler::Argument>& args,
158
+ const NameAttrList& function, CompileScope scope,
159
+ OpKernelContext* ctx,
160
+ DeviceCompilationProfiler* profiler);
161
+
162
+ std::unique_ptr<DeviceExecutablePersistor<ExecutableType, ClientType>>
163
+ persistor_;
164
+ std::unique_ptr<DeviceCompilerClient<ExecutableType, ClientType>>
165
+ compiler_client_;
166
+ std::unique_ptr<DeviceCompilationCache<ExecutableType>> cache_;
167
+
168
+ // Pool of threads for asynchronous compilations.
169
+ std::unique_ptr<thread::ThreadPool> async_compiler_threads_;
170
+
171
+ mutex cluster_mutexes_mu_;
172
+ absl::flat_hash_map<DeviceCompilationClusterSignature, std::unique_ptr<mutex>,
173
+ DeviceCompilationClusterSignature::Hash>
174
+ cluster_mutexes_ TF_GUARDED_BY(cluster_mutexes_mu_);
175
+
176
+ TF_DISALLOW_COPY_AND_ASSIGN(DeviceCompiler);
177
+ };
178
+
179
+ namespace device_compiler_internal {
180
+ // Print something that users can search for to definitively ascertain that XLA
181
+ // was used for their TF model.
182
+ // Prints only once to avoid spamming LOG(INFO).
183
+ inline void LogOnceXlaCompiledFirstCluster() {
184
+ static absl::once_flag log_once;
185
+ absl::call_once(log_once, [] {
186
+ LOG(INFO) << "Compiled cluster using XLA! This line is logged at most "
187
+ "once for the lifetime of the process.";
188
+ });
189
+ }
190
+
191
+ template <typename ExecutableType>
192
+ inline Status EligibleToPersist(DeviceCompileState compile_state,
193
+ const ExecutableType* executable) {
194
+ if (compile_state != DeviceCompileState::kCompiled) {
195
+ return errors::FailedPrecondition(
196
+ "Cache entry to serialize is not compiled.");
197
+ }
198
+ if (executable == nullptr) {
199
+ return errors::FailedPrecondition(
200
+ "LocalExecutable not found for cache entry to serialize.");
201
+ }
202
+ return OkStatus();
203
+ }
204
+ } // namespace device_compiler_internal
205
+
206
+ template <typename ExecutableType, typename ClientType>
207
+ DeviceCompiler<ExecutableType, ClientType>::DeviceCompiler(
208
+ std::unique_ptr<DeviceExecutablePersistor<ExecutableType, ClientType>>
209
+ persistor,
210
+ std::unique_ptr<DeviceCompilerClient<ExecutableType, ClientType>>
211
+ compiler_client)
212
+ : persistor_(std::move(persistor)),
213
+ compiler_client_(std::move(compiler_client)) {
214
+ cache_ = std::make_unique<DeviceCompilationCache<ExecutableType>>();
215
+ async_compiler_threads_ = std::make_unique<tensorflow::thread::ThreadPool>(
216
+ tensorflow::Env::Default(), "async_compiler_threads",
217
+ kNumAsyncDeviceCompilerThreads);
218
+ }
219
+
220
+ template <typename ExecutableType, typename ClientType>
221
+ DeviceCompiler<ExecutableType, ClientType>::~DeviceCompiler() {
222
+ // Since programs are owned by the cache, ensure any use of our programs have
223
+ // completed by waiting for all stream executors to complete.
224
+ compiler_client_->WaitForProgramsToFinish();
225
+ // Wait for all outstanding compilations to finish.
226
+ // Resetting the pointer explicitly in the top level destructor.
227
+ // Without this, the pointer would be reset when the AsyncCompilationState
228
+ // is destructed, which is dependent on the order of the members in the
229
+ // DeviceCompiler class, which is error prone if the order changes.
230
+ async_compiler_threads_.reset();
231
+ // TODO(b/110813685): Think about the program ownership model. Programs are
232
+ // currently owned by the compilation cache which means we must wait for
233
+ // program completion in the destructor. There are multiple compilation caches
234
+ // around, which complicates things a little. Perhaps having programs be
235
+ // shared_ptrs (an invasive change) would make the model easier to reason
236
+ // about?
237
+ }
238
+
239
+ template <typename ExecutableType, typename ClientType>
240
+ string DeviceCompiler<ExecutableType, ClientType>::DebugString() const {
241
+ return "DeviceCompiler";
242
+ }
243
+
244
+ template <typename ExecutableType, typename ClientType>
245
+ Status DeviceCompiler<ExecutableType, ClientType>::CompileIfNeeded(
246
+ const XlaCompiler::Options& options, const NameAttrList& function,
247
+ const std::vector<XlaCompiler::Argument>& args,
248
+ const XlaCompiler::CompileOptions& compile_options,
249
+ DeviceCompileMode compile_mode, DeviceCompilationProfiler* profiler,
250
+ const XlaCompiler::CompilationResult** out_compilation_result,
251
+ ExecutableType** out_executable) {
252
+ return CompileImpl(compile_options, options, function, args,
253
+ CompileScope::kFunction, compile_mode, /*ctx=*/nullptr,
254
+ profiler, out_compilation_result, out_executable);
255
+ }
256
+
257
+ template <typename ExecutableType, typename ClientType>
258
+ Status DeviceCompiler<ExecutableType, ClientType>::CompileSingleOpIfNeeded(
259
+ const XlaCompiler::Options& options,
260
+ const std::vector<XlaCompiler::Argument>& args,
261
+ const XlaCompiler::CompileOptions& compile_options, OpKernelContext* ctx,
262
+ DeviceCompilationProfiler* profiler,
263
+ const XlaCompiler::CompilationResult** out_compilation_result,
264
+ ExecutableType** out_executable) {
265
+ const NodeDef& def = ctx->op_kernel().def();
266
+ NameAttrList name;
267
+ name.set_name(def.op());
268
+ *name.mutable_attr() = def.attr();
269
+ // Remove the "_class" attribute from the attribute set used to create the
270
+ // compilation cache key. This attribute is information for the colocator
271
+ // and causes false uniqueness between nodes.
272
+ name.mutable_attr()->erase("_class");
273
+ return CompileImpl(compile_options, options, name, args, CompileScope::kOp,
274
+ DeviceCompileMode::kStrict, ctx, profiler,
275
+ out_compilation_result, out_executable);
276
+ }
277
+
278
+ template <typename ExecutableType, typename ClientType>
279
+ StatusOr<typename DeviceCompilationCache<ExecutableType>::Value>
280
+ DeviceCompiler<ExecutableType, ClientType>::CompileStrict(
281
+ const DeviceCompilationClusterSignature& sig,
282
+ const XlaCompiler::CompileOptions& compile_options,
283
+ const XlaCompiler::Options& options,
284
+ const std::vector<XlaCompiler::Argument>& args,
285
+ const NameAttrList& function,
286
+ typename DeviceCompilationCache<ExecutableType>::Value cache_value,
287
+ CompileScope scope, OpKernelContext* ctx,
288
+ DeviceCompilationProfiler* profiler, mutex* mu) {
289
+ tensorflow::Env* env = tensorflow::Env::Default();
290
+ const uint64 compile_start_us = env->NowMicros();
291
+
292
+ TfGraphToHloCompiler compiler(options);
293
+ cache_value.compile_state = DeviceCompileState::kCompiled;
294
+
295
+ std::unique_ptr<ExecutableType> out_executable;
296
+ auto out_compilation_result =
297
+ std::make_unique<XlaCompiler::CompilationResult>();
298
+
299
+ if (scope == CompileScope::kOp) {
300
+ cache_value.compilation_status = compiler.CompileSingleOp(
301
+ compile_options, ctx, args, out_compilation_result.get());
302
+ } else {
303
+ CHECK(scope == CompileScope::kFunction); // Crash OK
304
+ cache_value.compilation_status = compiler.Compile(
305
+ compile_options, function, args, out_compilation_result.get());
306
+ }
307
+ TF_RETURN_IF_ERROR(cache_value.compilation_status);
308
+ TF_RET_CHECK(cache_value.executable == nullptr);
309
+ TF_RET_CHECK(out_compilation_result->computation != nullptr);
310
+
311
+ auto loaded_executable = persistor_->TryToLoadExecutable(
312
+ DeviceCompilationClusterSignature::Hash()(sig), sig.HumanString(),
313
+ options, *out_compilation_result, compiler_client_.get());
314
+
315
+ if (loaded_executable.has_value()) {
316
+ cache_value.compilation_status = loaded_executable->status();
317
+ if (loaded_executable->ok()) {
318
+ out_executable = *std::move(*loaded_executable);
319
+ }
320
+ } else {
321
+ auto built_executable =
322
+ compiler_client_->BuildExecutable(options, *out_compilation_result);
323
+ TF_RETURN_IF_ERROR(built_executable.status());
324
+ out_executable = *std::move(built_executable);
325
+
326
+ TF_RETURN_IF_ERROR(
327
+ device_compiler_internal::EligibleToPersist<ExecutableType>(
328
+ cache_value.compile_state, out_executable.get()));
329
+ TF_RETURN_IF_ERROR(persistor_->TryToPersistExecutable(
330
+ DeviceCompilationClusterSignature::Hash()(sig), sig.HumanString(),
331
+ options, *out_compilation_result, *out_executable,
332
+ compiler_client_.get()));
333
+ }
334
+
335
+ cache_value.compilation_result = out_compilation_result.get();
336
+ cache_value.executable = out_executable.get();
337
+ cache_->Store(sig, cache_value.compile_state, cache_value.compilation_status,
338
+ std::move(out_compilation_result), std::move(out_executable));
339
+
340
+ const uint64 compile_end_us = env->NowMicros();
341
+ const uint64 compile_time_us = compile_end_us - compile_start_us;
342
+
343
+ device_compiler_internal::LogOnceXlaCompiledFirstCluster();
344
+ TF_RETURN_IF_ERROR(profiler->RegisterCompilation(
345
+ function, compile_time_us, loaded_executable.has_value()));
346
+ return cache_value;
347
+ }
348
+
349
+ template <typename ExecutableType, typename ClientType>
350
+ Status DeviceCompiler<ExecutableType, ClientType>::CompileAsynchronous(
351
+ const DeviceCompilationClusterSignature& signature,
352
+ const XlaCompiler::CompileOptions& compile_options,
353
+ const XlaCompiler::Options& options,
354
+ const std::vector<XlaCompiler::Argument>& args,
355
+ const NameAttrList& function, CompileScope scope, OpKernelContext* ctx,
356
+ DeviceCompilationProfiler* profiler) {
357
+ // Explicitly capture all required data by value for async compilation.
358
+ // Update compilation state in cache.
359
+ cache_->Store(signature, DeviceCompileState::kCompiling, std::nullopt,
360
+ std::nullopt, std::nullopt);
361
+ profiler->IncrementOngoingAsyncCompilations();
362
+ // Don't move the above code into the thread function as it synchronously
363
+ // updates the async compilation state!
364
+
365
+ // When the ThreadPool for the compilation cache is destroyed, it waits for
366
+ // compilations to have finished. This means that both 'entry' and 'this' will
367
+ // be alive for the duration of the compilation.
368
+ // !!Pay attention when additional variables must be captured by this lambda!!
369
+ // All values are captured by value. Make sure that all pointer values (like
370
+ // entry) do not get freed until the lambda has finished.
371
+ const std::string& function_name = function.name();
372
+ async_compiler_threads_->Schedule([=] {
373
+ VLOG(2) << "Starting asynchronous compilation of cluster " << function_name
374
+ << '.';
375
+ // We don't need to lock mu, but do it anyway to satisfy thread safety
376
+ // analysis.
377
+ mutex mu;
378
+ mutex_lock lock(mu);
379
+ auto cache_value = typename DeviceCompilationCache<ExecutableType>::Value();
380
+ auto s = CompileStrict(signature, compile_options, options, args, function,
381
+ cache_value, scope, ctx, profiler, &mu);
382
+ VLOG(2) << "Finished asynchronous compililation of cluster "
383
+ << function_name << '.';
384
+ profiler->DecrementOngoingAsyncCompilations();
385
+ // Update compilation status in cache.
386
+ if (!s.ok()) {
387
+ cache_->Store(signature, std::nullopt, s.status(), std::nullopt,
388
+ std::nullopt);
389
+ }
390
+ });
391
+ return OkStatus();
392
+ }
393
+
394
+ template <typename ExecutableType, typename ClientType>
395
+ Status DeviceCompiler<ExecutableType, ClientType>::CompileImpl(
396
+ const XlaCompiler::CompileOptions& compile_options,
397
+ const XlaCompiler::Options& options, const NameAttrList& function,
398
+ const std::vector<XlaCompiler::Argument>& args, CompileScope scope,
399
+ DeviceCompileMode compile_mode, OpKernelContext* ctx,
400
+ DeviceCompilationProfiler* profiler,
401
+ const XlaCompiler::CompilationResult** out_compilation_result,
402
+ ExecutableType** out_executable) {
403
+ DCHECK_NE(out_executable, nullptr);
404
+ VLOG(2) << "DeviceCompiler::Compile " << DebugString();
405
+
406
+ if (VLOG_IS_ON(2)) {
407
+ VLOG(2) << "num_inputs=" << args.size();
408
+ for (int i = 0, end = args.size(); i < end; i++) {
409
+ VLOG(3) << i << ": " << args[i].HumanString();
410
+ }
411
+ }
412
+ TF_ASSIGN_OR_RETURN(auto signature,
413
+ DeviceCompilationClusterSignature::Build(function, args));
414
+
415
+ // The outer lock protects the existence of the mutex in the map.
416
+ mutex* cluster_mutex;
417
+ {
418
+ mutex_lock lock(cluster_mutexes_mu_);
419
+ auto it =
420
+ cluster_mutexes_.emplace(signature, std::make_unique<mutex>()).first;
421
+ cluster_mutex = it->second.get();
422
+ }
423
+
424
+ profiler->RegisterExecution(function);
425
+
426
+ string human_signature;
427
+ if (VLOG_IS_ON(2)) {
428
+ human_signature = VLOG_IS_ON(3) ? signature.HumanString() : function.name();
429
+ VLOG(2) << "DeviceCompilationClusterSignature: " << human_signature;
430
+ }
431
+
432
+ // Acquire the cache entry lock and compile, if necessary.
433
+ // TODO(phawkins): this locking will need to be restructured when we implement
434
+ // cache eviction.
435
+ mutex_lock cluster_compile_lock(*cluster_mutex);
436
+ auto cache_value = cache_->LookupOrCreate(signature);
437
+
438
+ int64_t current_request_count = cache_value.request_count;
439
+ VLOG(2) << "Compilation cache entry hit: "
440
+ << static_cast<int>(cache_value.compile_state)
441
+ << " signature: " << human_signature << " with request count "
442
+ << current_request_count;
443
+
444
+ DeviceCompileState state = cache_value.compile_state;
445
+ *out_compilation_result = nullptr;
446
+ *out_executable = nullptr;
447
+
448
+ // Check if the requested entry is uncompiled and return an error if
449
+ // compilation is disabled. This will raise an error for kLazy even if we have
450
+ // not yet hit the compilation threshold and no compilation happens this
451
+ // round. This is to avoid non-determanism of when compilation is disallowed,
452
+ // for example by changing the threshold.
453
+ if (state == DeviceCompileState::kUncompiled && FailOnXlaCompilation()) {
454
+ VLOG(1) << "XLA compilation disabled: " << function.name() << "\n"
455
+ << absl::StrJoin(
456
+ args, "\n",
457
+ [](std::string* out, const XlaCompiler::Argument& arg) {
458
+ absl::StrAppend(out, " arg: ", arg.HumanString());
459
+ });
460
+
461
+ return errors::Internal("XLA compilation disabled");
462
+ }
463
+
464
+ if (state == DeviceCompileState::kUncompiled) {
465
+ XLA_SCOPED_LOGGING_TIMER("Compilation of XLA executable");
466
+ if (!profiler->ShouldCompileCluster(function, compile_mode,
467
+ current_request_count)) {
468
+ VLOG(2) << "Not compiling for signature: " << human_signature;
469
+ return OkStatus();
470
+ } else if (compile_mode == DeviceCompileMode::kAsync) {
471
+ VLOG(2) << "Queueing asynchronous compilation for signature: "
472
+ << human_signature;
473
+ TF_RETURN_IF_ERROR(CompileAsynchronous(signature, compile_options,
474
+ options, args, function, scope,
475
+ ctx, profiler));
476
+ return OkStatus();
477
+ } else {
478
+ VLOG(2) << "Instantly compiling for signature: " << human_signature;
479
+ TF_ASSIGN_OR_RETURN(
480
+ cache_value,
481
+ CompileStrict(signature, compile_options, options, args, function,
482
+ cache_value, scope, ctx, profiler, cluster_mutex));
483
+ }
484
+ } else if (state == DeviceCompileState::kCompiling) {
485
+ VLOG(2) << "Ongoing asynchronous compilation for signature: "
486
+ << human_signature;
487
+ return OkStatus();
488
+ } else if (state == DeviceCompileState::kCompiled) {
489
+ VLOG(2) << "Already Compiled for signature: " << human_signature;
490
+ }
491
+
492
+ TF_RETURN_IF_ERROR(cache_value.compilation_status);
493
+ *out_compilation_result = cache_value.compilation_result;
494
+ *out_executable = cache_value.executable;
495
+ return OkStatus();
496
+ }
497
+
498
+ } // namespace tensorflow
499
+
500
+ #endif // TENSORFLOW_COMPILER_JIT_DEVICE_COMPILER_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_compiler_client.h ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_DEVICE_COMPILER_CLIENT_H_
17
+ #define TENSORFLOW_COMPILER_JIT_DEVICE_COMPILER_CLIENT_H_
18
+
19
+ #include <optional>
20
+ #include <string>
21
+ #include <variant>
22
+
23
+ #include "tensorflow/compiler/tf2xla/xla_compiler.h"
24
+ #include "xla/client/executable_build_options.h"
25
+
26
+ namespace tensorflow {
27
+
28
+ template <typename ExecutableType, typename ClientType>
29
+ class DeviceCompilerClient {
30
+ public:
31
+ DeviceCompilerClient() = default;
32
+ virtual ~DeviceCompilerClient() = default;
33
+
34
+ // Compiles `result` (HLO) to an `ExecutableType` using `ClientType` and
35
+ // returns it.
36
+ virtual StatusOr<std::unique_ptr<ExecutableType>> BuildExecutable(
37
+ const XlaCompiler::Options& options,
38
+ const XlaCompiler::CompilationResult& result) = 0;
39
+
40
+ // Serializes an available `executable` to string using `ClientType` and
41
+ // returns it.
42
+ virtual StatusOr<std::string> SerializeExecutable(
43
+ const ExecutableType& executable) = 0;
44
+
45
+ // Compiles `result` (HLO) to a serializable executable (eg.
46
+ // xla::AotCompilationResult) using `ClientType`, serializes it to string and
47
+ // returns it.
48
+ virtual StatusOr<std::string> BuildSerializedExecutable(
49
+ const XlaCompiler::Options& options,
50
+ const XlaCompiler::CompilationResult& result) = 0;
51
+
52
+ // Loads `serialized_executable` into an `ExecutableType` using `ClientType`.
53
+ virtual StatusOr<std::unique_ptr<ExecutableType>> LoadExecutable(
54
+ const XlaCompiler::Options& options,
55
+ const XlaCompiler::CompilationResult& result,
56
+ const std::string& serialized_executable) = 0;
57
+
58
+ // Waits for the underlying `ClientType` backend's programs to finish
59
+ // executing before returning.
60
+ virtual void WaitForProgramsToFinish() = 0;
61
+
62
+ virtual ClientType* client() const = 0;
63
+
64
+ private:
65
+ TF_DISALLOW_COPY_AND_ASSIGN(DeviceCompilerClient);
66
+ };
67
+
68
+ // Generates the ExecutableBuildOptions for compilation from HLO to
69
+ // executable.
70
+ xla::ExecutableBuildOptions GetExecutableBuildOptions(
71
+ const XlaCompiler::Options& options,
72
+ const XlaCompiler::CompilationResult& result, int default_device_ordinal);
73
+ } // namespace tensorflow
74
+
75
+ #endif // TENSORFLOW_COMPILER_JIT_DEVICE_COMPILER_CLIENT_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_executable_persistor.h ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_DEVICE_EXECUTABLE_PERSISTOR_H_
17
+ #define TENSORFLOW_COMPILER_JIT_DEVICE_EXECUTABLE_PERSISTOR_H_
18
+
19
+ #include <optional>
20
+ #include <string>
21
+
22
+ #include "absl/log/log.h"
23
+ #include "tensorflow/compiler/jit/xla_compilation_cache.pb.h"
24
+ #include "tensorflow/compiler/jit/xla_device_compiler_client.h"
25
+ #include "tensorflow/compiler/tf2xla/xla_compiler.h"
26
+ #include "xla/pjrt/pjrt_client.h"
27
+ #include "xla/service/hlo.pb.h"
28
+ #include "xla/util.h"
29
+ #include "tensorflow/core/framework/device.h"
30
+ #include "tensorflow/core/lib/strings/proto_serialization.h"
31
+ #include "tensorflow/core/platform/path.h"
32
+ #include "tensorflow/core/platform/status.h"
33
+ #include "tensorflow/core/platform/statusor.h"
34
+ #include "tsl/platform/statusor.h"
35
+
36
+ namespace tensorflow {
37
+
38
+ // Offers a way to persist and/or load compiled `ExecutableType`s along with the
39
+ // corresponding HLO (`CompilationResult`) to/from `persistent_cache_directory`
40
+ // (if one was provided during construction) on disk using `ClientType`.
41
+ template <typename ExecutableType, typename ClientType>
42
+ class DeviceExecutablePersistor {
43
+ public:
44
+ // Configuration for setting up persistence (directory, filename prefix, etc).
45
+ struct Config {
46
+ Config() = default;
47
+ explicit Config(absl::string_view persistent_cache_directory,
48
+ bool disable_strict_signature_checks,
49
+ absl::string_view persistence_prefix,
50
+ bool persistent_cache_directory_read_only)
51
+ : persistent_cache_directory(persistent_cache_directory),
52
+ disable_strict_signature_checks(disable_strict_signature_checks),
53
+ persistence_prefix(persistence_prefix),
54
+ persistent_cache_directory_read_only(
55
+ persistent_cache_directory_read_only) {}
56
+
57
+ explicit Config(absl::string_view persistent_cache_directory,
58
+ bool disable_strict_signature_checks,
59
+ absl::string_view persistence_prefix)
60
+ : persistent_cache_directory(persistent_cache_directory),
61
+ disable_strict_signature_checks(disable_strict_signature_checks),
62
+ persistence_prefix(persistence_prefix) {}
63
+
64
+ // If non-empty, JIT-compiled executables are saved to and loaded from the
65
+ // specified file system directory path.
66
+ std::string persistent_cache_directory;
67
+
68
+ // Disable strict signature checks for entries loaded into the cache from
69
+ // external sources.
70
+ bool disable_strict_signature_checks = false;
71
+
72
+ // The cache persistence prefix to use if serializing/deserialzing entries.
73
+ std::string persistence_prefix;
74
+
75
+ // Cache is read-only if set to true.
76
+ bool persistent_cache_directory_read_only = false;
77
+ };
78
+
79
+ DeviceExecutablePersistor(const Config& config,
80
+ const DeviceType& device_type);
81
+ virtual ~DeviceExecutablePersistor() = default;
82
+
83
+ // Returns std::nullopt if persistence is not enabled (i.e.
84
+ // `persistent_cache_directory_` is empty) or if the serialized entry is not
85
+ // found on disk. Otherwise, loads and returns the serialized executable
86
+ // (or returns a status).
87
+ // TODO(b/255826209): Take in Signature instead of hash and string once cache
88
+ // is refactored.
89
+ std::optional<StatusOr<std::unique_ptr<ExecutableType>>> TryToLoadExecutable(
90
+ uint64 signature_hash, const std::string& signature_str,
91
+ const XlaCompiler::Options& options,
92
+ const XlaCompiler::CompilationResult& compilation_result,
93
+ DeviceCompilerClient<ExecutableType, ClientType>* client) const;
94
+
95
+ // Tries to serialize an already built `executable` and persist it on disk. If
96
+ // unable to do so, tries to build a serialized executable using the AOT
97
+ // pipeline and persists that to disk.
98
+ // TODO(b/255826209): Take in Signature instead hash and string once cache
99
+ // is refactored.
100
+ virtual Status TryToPersistExecutable(
101
+ uint64 signature_hash, const std::string& signature_str,
102
+ const XlaCompiler::Options& options,
103
+ const XlaCompiler::CompilationResult& compilation_result,
104
+ const ExecutableType& executable,
105
+ DeviceCompilerClient<ExecutableType, ClientType>* client) const;
106
+
107
+ const DeviceType& device_type() const { return device_type_; }
108
+ const std::string& persistence_prefix() const { return persistence_prefix_; }
109
+ const std::string& persistent_cache_directory() const {
110
+ return persistent_cache_directory_;
111
+ }
112
+
113
+ private:
114
+ // Returns a cache key proto that identifies an entry in the compilation
115
+ // cache.
116
+ XlaSerializedCacheKey BuildSerializedCacheKey(
117
+ uint64 signature_hash, const xla::HloModuleProto& hlo_module) const;
118
+
119
+ XlaSerializedCacheKey BuildSerializedCacheKey(
120
+ uint64 signature_hash, const xla::HloModuleProto& hlo_module,
121
+ bool compiled_using_pjrt) const;
122
+
123
+ // Serializes the signature and its corresponding entry to a proto message.
124
+ StatusOr<XlaSerializedCacheEntry> SerializeEntry(
125
+ uint64 signature_hash, const XlaCompiler::Options& options,
126
+ const XlaCompiler::CompilationResult& compilation_result,
127
+ const ExecutableType& executable,
128
+ DeviceCompilerClient<ExecutableType, ClientType>* compiler_client) const;
129
+
130
+ // Saves the cache entry in the file directory supplied during the
131
+ // construction of this class. Overwrites existing entries.
132
+ Status SaveSerializedEntry(const XlaSerializedCacheEntry& entry) const;
133
+
134
+ // Tries to read a cache entry given a `key` by searching the file directory
135
+ // supplied during the construction of this class. Returns std::nullopt if no
136
+ // cache entry is found.
137
+ StatusOr<std::optional<XlaSerializedCacheEntry>> TryToReadSerializedEntry(
138
+ const XlaSerializedCacheKey& key) const;
139
+
140
+ // Checks if the loaded `entry` matches the expected `key` and `hlo_module`.
141
+ Status VerifyLoadedCacheEntry(const XlaSerializedCacheKey& key,
142
+ const xla::HloModuleProto& hlo_module,
143
+ const XlaSerializedCacheEntry& entry) const;
144
+
145
+ std::string XlaSerializedCacheKeyToString(
146
+ const XlaSerializedCacheKey& key) const;
147
+ std::string GetFilePath(const XlaSerializedCacheKey& key) const;
148
+
149
+ const DeviceType device_type_;
150
+ const bool disable_strict_signature_checks_;
151
+ const std::string persistence_prefix_;
152
+
153
+ // If non-empty, JIT-compiled executables are saved to and loaded from the
154
+ // specified file system directory path.
155
+ const std::string persistent_cache_directory_;
156
+
157
+ // Cache is read-only if set to true.
158
+ const bool persistent_cache_directory_read_only_;
159
+
160
+ TF_DISALLOW_COPY_AND_ASSIGN(DeviceExecutablePersistor);
161
+ };
162
+
163
+ template <typename ExecutableType, typename ClientType>
164
+ DeviceExecutablePersistor<ExecutableType, ClientType>::
165
+ DeviceExecutablePersistor(const Config& config,
166
+ const DeviceType& device_type)
167
+ : device_type_(device_type),
168
+ disable_strict_signature_checks_(config.disable_strict_signature_checks),
169
+ persistence_prefix_(config.persistence_prefix),
170
+ persistent_cache_directory_(config.persistent_cache_directory),
171
+ persistent_cache_directory_read_only_(
172
+ config.persistent_cache_directory_read_only) {}
173
+
174
+ template <typename ExecutableType, typename ClientType>
175
+ std::string DeviceExecutablePersistor<ExecutableType, ClientType>::
176
+ XlaSerializedCacheKeyToString(const XlaSerializedCacheKey& key) const {
177
+ static constexpr char kXlaSerializedCacheKeySeparator[] = "__";
178
+ return absl::StrCat(
179
+ key.prefix(), key.prefix().empty() ? "" : kXlaSerializedCacheKeySeparator,
180
+ key.signature_fingerprint(), kXlaSerializedCacheKeySeparator,
181
+ key.cluster_fingerprint(), kXlaSerializedCacheKeySeparator,
182
+ key.device_type(),
183
+ key.compiled_using_pjrt()
184
+ ? absl::StrCat(kXlaSerializedCacheKeySeparator, "pjrt")
185
+ : "");
186
+ }
187
+
188
+ template <typename ExecutableType, typename ClientType>
189
+ std::string DeviceExecutablePersistor<ExecutableType, ClientType>::GetFilePath(
190
+ const XlaSerializedCacheKey& key) const {
191
+ const std::string file_name =
192
+ absl::StrCat(XlaSerializedCacheKeyToString(key), ".pb");
193
+ return io::JoinPath(persistent_cache_directory_, file_name);
194
+ }
195
+
196
+ template <typename ExecutableType, typename ClientType>
197
+ XlaSerializedCacheKey
198
+ DeviceExecutablePersistor<ExecutableType, ClientType>::BuildSerializedCacheKey(
199
+ uint64 signature_hash, const xla::HloModuleProto& hlo_module,
200
+ bool compiled_using_pjrt) const {
201
+ XlaSerializedCacheKey key;
202
+ key.set_signature_fingerprint(signature_hash);
203
+ key.set_cluster_fingerprint(DeterministicProtoHash64(hlo_module));
204
+ key.set_device_type(device_type().type_string());
205
+ key.set_prefix(persistence_prefix());
206
+ key.set_compiled_using_pjrt(compiled_using_pjrt);
207
+ return key;
208
+ }
209
+
210
+ template <typename ExecutableType, typename ClientType>
211
+ XlaSerializedCacheKey
212
+ DeviceExecutablePersistor<ExecutableType, ClientType>::BuildSerializedCacheKey(
213
+ uint64 signature_hash, const xla::HloModuleProto& hlo_module) const {
214
+ return BuildSerializedCacheKey(signature_hash, hlo_module, false);
215
+ }
216
+
217
+ // This template specialization sets compiled_using_prjt to true in the cache
218
+ // key when the template arguments are PjRtLoadedExecutable and PjRtClient.
219
+ template <>
220
+ inline XlaSerializedCacheKey
221
+ DeviceExecutablePersistor<xla::PjRtLoadedExecutable, xla::PjRtClient>::
222
+ BuildSerializedCacheKey(uint64 signature_hash,
223
+ const xla::HloModuleProto& hlo_module) const {
224
+ return BuildSerializedCacheKey(signature_hash, hlo_module, true);
225
+ }
226
+
227
+ template <typename ExecutableType, typename ClientType>
228
+ StatusOr<std::optional<XlaSerializedCacheEntry>>
229
+ DeviceExecutablePersistor<ExecutableType, ClientType>::TryToReadSerializedEntry(
230
+ const XlaSerializedCacheKey& key) const {
231
+ Env* env = Env::Default();
232
+ const std::string file_path = GetFilePath(key);
233
+ if (!env->FileExists(file_path).ok()) {
234
+ return StatusOr<std::optional<XlaSerializedCacheEntry>>(std::nullopt);
235
+ }
236
+
237
+ XlaSerializedCacheEntry entry;
238
+ TF_RETURN_IF_ERROR(ReadTextOrBinaryProto(env, file_path, &entry));
239
+ return std::optional<XlaSerializedCacheEntry>(entry);
240
+ }
241
+
242
+ template <typename ExecutableType, typename ClientType>
243
+ Status
244
+ DeviceExecutablePersistor<ExecutableType, ClientType>::VerifyLoadedCacheEntry(
245
+ const XlaSerializedCacheKey& key, const xla::HloModuleProto& hlo_module,
246
+ const XlaSerializedCacheEntry& entry) const {
247
+ XLA_SCOPED_LOGGING_TIMER(absl::StrCat("Verifying loaded cache entry: ",
248
+ hlo_module.entry_computation_name()));
249
+
250
+ if (!AreSerializedProtosEqual(key, entry.key())) {
251
+ VLOG(2) << "Serialized cache key does not match:\n"
252
+ << "got:\n"
253
+ << entry.key().DebugString() << "\nexpected:\n"
254
+ << key.DebugString() << "\n";
255
+ return errors::InvalidArgument("Serialized cache key does not match.");
256
+ }
257
+
258
+ // Perform a stricter (slower) check of the snapshot to verify that they
259
+ // match exactly.
260
+ if (!disable_strict_signature_checks_) {
261
+ if (!AreSerializedProtosEqual(hlo_module, entry.hlo_module())) {
262
+ VLOG(2) << "HLOs do not match:\n"
263
+ << "got:\n"
264
+ << hlo_module.DebugString() << "\nexpected:\n"
265
+ << entry.hlo_module().DebugString() << "\n";
266
+ return errors::InvalidArgument("Serialized HLO does not match.");
267
+ }
268
+ }
269
+
270
+ if (entry.executable().empty()) {
271
+ return errors::InvalidArgument("No binary found in serialized entry.");
272
+ }
273
+ return OkStatus();
274
+ }
275
+
276
+ template <typename ExecutableType, typename ClientType>
277
+ Status
278
+ DeviceExecutablePersistor<ExecutableType, ClientType>::SaveSerializedEntry(
279
+ const XlaSerializedCacheEntry& entry) const {
280
+ Env* env = Env::Default();
281
+ TF_RETURN_IF_ERROR(env->RecursivelyCreateDir(persistent_cache_directory_));
282
+
283
+ // The cache on the filesystem can be read while we're writing out the proto.
284
+ // To prevent reads of partially-written files, we write the proto to a temp
285
+ // file, then move it into place once we're done writing. And we warn the
286
+ // user if these moves are not known to be atomic.
287
+ bool has_atomic_move = false;
288
+ env->HasAtomicMove(persistent_cache_directory_, &has_atomic_move)
289
+ .IgnoreError();
290
+ if (!has_atomic_move) {
291
+ LOG_EVERY_POW_2(WARNING)
292
+ << "Filesystem for XLA persistent cache at "
293
+ << persistent_cache_directory_
294
+ << " does not support atomic moves. Therefore the persistent cache is "
295
+ "racy if you have multiple XLA compilations occurring "
296
+ "simultaneously! You have been warned. :)";
297
+ }
298
+
299
+ // Write to temp location, then when that completes, atomically move into the
300
+ // final location.
301
+ std::string temp_path = io::JoinPath(
302
+ persistent_cache_directory_, XlaSerializedCacheKeyToString(entry.key()));
303
+ if (!env->CreateUniqueFileName(&temp_path, ".pb.tmp")) {
304
+ return absl::UnavailableError(absl::StrCat(
305
+ "Could not create a unique file inside ", persistent_cache_directory_));
306
+ }
307
+ TF_RETURN_IF_ERROR(WriteBinaryProto(env, temp_path, entry));
308
+ return env->RenameFile(temp_path, GetFilePath(entry.key()));
309
+ }
310
+
311
+ template <typename ExecutableType, typename ClientType>
312
+ StatusOr<XlaSerializedCacheEntry>
313
+ DeviceExecutablePersistor<ExecutableType, ClientType>::SerializeEntry(
314
+ uint64 signature_hash, const XlaCompiler::Options& options,
315
+ const XlaCompiler::CompilationResult& compilation_result,
316
+ const ExecutableType& executable,
317
+ DeviceCompilerClient<ExecutableType, ClientType>* compiler_client) const {
318
+ XlaSerializedCacheEntry serialized_entry;
319
+ const xla::HloModuleProto& hlo_module =
320
+ compilation_result.computation->proto();
321
+ *serialized_entry.mutable_key() =
322
+ BuildSerializedCacheKey(signature_hash, hlo_module);
323
+ *serialized_entry.mutable_hlo_module() = hlo_module;
324
+
325
+ // XLA compiler supports exporting executables as an AOT compilation result
326
+ // to avoid running potentially expensive compilation pipeline twice.
327
+ // Check if XLA compiler can export available executable.
328
+ if (auto serialized_executable =
329
+ compiler_client->SerializeExecutable(executable);
330
+ serialized_executable.ok()) {
331
+ serialized_entry.set_executable(std::move(*serialized_executable));
332
+ return serialized_entry;
333
+ } else if (serialized_executable.status().code() == error::UNIMPLEMENTED) {
334
+ VLOG(1) << "Executable export is not implemented";
335
+ } else {
336
+ return serialized_executable.status();
337
+ }
338
+
339
+ TF_ASSIGN_OR_RETURN(
340
+ auto serialized_executable,
341
+ compiler_client->BuildSerializedExecutable(options, compilation_result));
342
+ serialized_entry.set_executable(std::move(serialized_executable));
343
+ return serialized_entry;
344
+ }
345
+
346
+ template <typename ExecutableType, typename ClientType>
347
+ std::optional<StatusOr<std::unique_ptr<ExecutableType>>>
348
+ DeviceExecutablePersistor<ExecutableType, ClientType>::TryToLoadExecutable(
349
+ uint64 signature_hash, const std::string& signature_str,
350
+ const XlaCompiler::Options& options,
351
+ const XlaCompiler::CompilationResult& compilation_result,
352
+ DeviceCompilerClient<ExecutableType, ClientType>* compiler_client) const {
353
+ if (persistent_cache_directory_.empty()) {
354
+ return std::nullopt;
355
+ }
356
+
357
+ const xla::HloModuleProto& hlo_module =
358
+ compilation_result.computation->proto();
359
+
360
+ XlaSerializedCacheKey cache_key =
361
+ BuildSerializedCacheKey(signature_hash, hlo_module);
362
+
363
+ std::optional<XlaSerializedCacheEntry> serialized_entry;
364
+ {
365
+ XLA_SCOPED_LOGGING_TIMER(
366
+ absl::StrCat("Try loading serialized cache entry:", signature_str));
367
+ TF_ASSIGN_OR_RETURN(serialized_entry, TryToReadSerializedEntry(cache_key));
368
+ }
369
+
370
+ if (!serialized_entry.has_value()) {
371
+ return std::nullopt;
372
+ }
373
+
374
+ TF_RETURN_IF_ERROR(
375
+ VerifyLoadedCacheEntry(cache_key, hlo_module, *serialized_entry));
376
+
377
+ VLOG(1) << "Loading cached entry for: " << signature_str;
378
+ return compiler_client->LoadExecutable(options, compilation_result,
379
+ serialized_entry->executable());
380
+ }
381
+
382
+ template <typename ExecutableType, typename ClientType>
383
+ Status
384
+ DeviceExecutablePersistor<ExecutableType, ClientType>::TryToPersistExecutable(
385
+ uint64 signature_hash, const std::string& signature_str,
386
+ const XlaCompiler::Options& options,
387
+ const XlaCompiler::CompilationResult& compilation_result,
388
+ const ExecutableType& executable,
389
+ DeviceCompilerClient<ExecutableType, ClientType>* client) const {
390
+ if (persistent_cache_directory_.empty() ||
391
+ persistent_cache_directory_read_only_) {
392
+ VLOG(1) << "Not persisting executable. No `persistent_cache_directory` "
393
+ "provided or cache is read-only.";
394
+ return OkStatus();
395
+ }
396
+
397
+ XLA_SCOPED_LOGGING_TIMER(
398
+ absl::StrCat("Serializing and saving cache entry: ", signature_str));
399
+ TF_ASSIGN_OR_RETURN(XlaSerializedCacheEntry serialized_entry,
400
+ SerializeEntry(signature_hash, options,
401
+ compilation_result, executable, client));
402
+ TF_RETURN_IF_ERROR(SaveSerializedEntry(std::move(serialized_entry)));
403
+ return OkStatus();
404
+ }
405
+
406
+ } // namespace tensorflow
407
+
408
+ #endif // TENSORFLOW_COMPILER_JIT_DEVICE_EXECUTABLE_PERSISTOR_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/device_util.h ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_DEVICE_UTIL_H_
17
+ #define TENSORFLOW_COMPILER_JIT_DEVICE_UTIL_H_
18
+
19
+ #include <functional>
20
+ #include <memory>
21
+
22
+ #include "absl/container/flat_hash_map.h"
23
+ #include "absl/strings/string_view.h"
24
+ #include "absl/types/span.h"
25
+ #include "tensorflow/compiler/tf2xla/xla_op_registry.h"
26
+ #include "xla/status_macros.h"
27
+ #include "xla/statusor.h"
28
+ #include "tensorflow/core/framework/types.h"
29
+
30
+ namespace tensorflow {
31
+ namespace jit {
32
+ class DeviceInfoCache;
33
+ class DeviceSet;
34
+
35
+ // Instances of DeviceId represent TensorFlow devices as integers.
36
+ //
37
+ // This helps avoid having to manipulate device names as strings when
38
+ // auto-clustering.
39
+ class DeviceId {
40
+ public:
41
+ DeviceId(DeviceId&&) = default;
42
+ DeviceId(const DeviceId&) = default;
43
+ DeviceId& operator=(const DeviceId&) = default;
44
+
45
+ bool operator==(const DeviceId& other) const { return id() == other.id(); }
46
+ bool operator!=(const DeviceId& other) const { return !(*this == other); }
47
+
48
+ private:
49
+ int id_;
50
+
51
+ explicit DeviceId(int id) : id_(id) {}
52
+
53
+ int id() const { return id_; }
54
+
55
+ friend class DeviceInfoCache;
56
+ friend class DeviceSet;
57
+ };
58
+
59
+ // A set of DeviceIds, represented as a bitmap.
60
+ class DeviceSet {
61
+ public:
62
+ void Insert(DeviceId device_id);
63
+ void UnionWith(const DeviceSet& other);
64
+ bool IsEmpty() const;
65
+
66
+ // Calls `func` on each DeviceId in the set. Stops iterating early if `func`
67
+ // return false.
68
+ //
69
+ // TODO(sanjoy): Change this to take a typed std::function if that's
70
+ // performance neutral.
71
+ template <typename FnTy>
72
+ void ForEach(FnTy func) const {
73
+ // This is really a poor man's iterator, we should consider writing a proper
74
+ // iterator if this ends up being used widely.
75
+ for (int word_index = 0, end = storage_.size(); word_index < end;
76
+ word_index++) {
77
+ uint64 word = storage_[word_index];
78
+ while (word != 0) {
79
+ uint64 only_lowest_bit_set = word & -word;
80
+ // The number of trailing zeros in a non-zero word is the index of the
81
+ // least significant 1.
82
+ int bit_index = ctz_uint64(word);
83
+ if (!func(DeviceId(word_index * kWordSize + bit_index))) {
84
+ return;
85
+ }
86
+ word ^= only_lowest_bit_set;
87
+ }
88
+ }
89
+ }
90
+
91
+ private:
92
+ static int ctz_uint64(uint64 x) {
93
+ DCHECK_NE(x, 0);
94
+ #ifdef __GNUC__
95
+ return __builtin_ctzl(x);
96
+ #else
97
+ int result = 0u;
98
+ while ((x & 1u) == 0u) {
99
+ x >>= 1;
100
+ ++result;
101
+ }
102
+ return result;
103
+ #endif
104
+ }
105
+
106
+ absl::InlinedVector<uint64, 1> storage_;
107
+
108
+ const int kWordSize = 64;
109
+ };
110
+
111
+ // Caches some miscellaneous information about TF devices. Thread compatible.
112
+ class DeviceInfoCache {
113
+ public:
114
+ bool IsGpu(DeviceId device) const { return is_gpu_[device.id()]; }
115
+ bool IsCpu(DeviceId device) const { return is_cpu_[device.id()]; }
116
+
117
+ absl::string_view GetNameFor(DeviceId device) const {
118
+ return names_[device.id()];
119
+ }
120
+
121
+ StatusOr<DeviceId> GetIdFor(absl::string_view name);
122
+
123
+ using DeviceRegistration = const XlaOpRegistry::DeviceRegistration;
124
+
125
+ DeviceRegistration* GetCompilationDevice(DeviceId device) const {
126
+ return id_to_compilation_device_[device.id()];
127
+ }
128
+
129
+ StatusOr<DeviceRegistration*> GetCompilationDevice(absl::string_view name) {
130
+ TF_ASSIGN_OR_RETURN(DeviceId device_id, GetIdFor(name));
131
+ return GetCompilationDevice(device_id);
132
+ }
133
+
134
+ const DeviceType& GetDeviceTypeFor(DeviceId device) const {
135
+ return *id_to_device_type_[device.id()];
136
+ }
137
+
138
+ using DeviceTypeConstRef = std::reference_wrapper<const DeviceType>;
139
+
140
+ StatusOr<DeviceTypeConstRef> GetDeviceTypeFor(absl::string_view device_name) {
141
+ TF_ASSIGN_OR_RETURN(DeviceId device_id, GetIdFor(device_name));
142
+ return std::cref(*id_to_device_type_[device_id.id()]);
143
+ }
144
+
145
+ string DebugString(const DeviceSet& device_set) const;
146
+
147
+ private:
148
+ absl::flat_hash_map<string, DeviceId> name_to_id_;
149
+
150
+ // These fields are populated for a device in GetIdFor, *before* we give out a
151
+ // DeviceId.
152
+ std::vector<const XlaOpRegistry::DeviceRegistration*>
153
+ id_to_compilation_device_;
154
+ std::vector<std::unique_ptr<DeviceType>> id_to_device_type_;
155
+ std::vector<string> names_;
156
+ std::vector<bool> is_cpu_;
157
+ std::vector<bool> is_gpu_;
158
+ };
159
+
160
+ } // namespace jit
161
+
162
+ // Returns the DeviceType corresponding to 'device'.
163
+ Status DeviceNameToDeviceType(const string& device, DeviceType* device_type);
164
+
165
+ // Picks the device for which XLA should compile a cluster that contains
166
+ // operations placed in devices in `devices`. For instance a cluster that
167
+ // contains operations solely placed on the CPU will be compiled into a CPU
168
+ // executable by XLA, whereas a cluster that contains operations placed on the
169
+ // CPU and also operations placed on the GPU will be compiled into a GPU
170
+ // executable.
171
+ //
172
+ // Returns a non-OK Status if no unambiguous choice of device exists.
173
+ //
174
+ // We choose the device using the following rules:
175
+ //
176
+ // - It is an error for `device_names` to contain more than one device of the
177
+ // same type.
178
+ // - GPU is preferred over CPU.
179
+ // - If `allow_mixing_unknown_and_cpu` is true then unknown devices are
180
+ // preferred over CPU.
181
+ // - XLA devices count as "unrecognized devices".
182
+ //
183
+ // This set of rules above implicitly assume that XLA:GPU can compile all
184
+ // operations in the cluster that XLA:CPU can compile, and if
185
+ // `allow_mixing_unknown_and_cpu` then the unrecognized device can also compile
186
+ // all operations in the cluster that XLA:CPU can compile.
187
+ //
188
+ // We provide the `allow_mixing_unknown_and_cpu` knob so that we can do both of
189
+ // the following things:
190
+ //
191
+ // - Let MarkForCompilationPass not inject CPU-placed operations into clusters
192
+ // that will run on unknown devices (because the unknown XLA backend may not
193
+ // support every operation supported by CPU).
194
+ // - Let BuildXlaOpsPass successfully infer a compilation device for a cluster
195
+ // that contains nodes placed on both the CPU and on unknown devices. In this
196
+ // case it is the responsibility of the optimization pass that injected the
197
+ // CPU nodes into the cluster to ensure that these nodes can be compiled by
198
+ // the unknown XLA backend.
199
+ StatusOr<jit::DeviceId> PickDeviceForXla(
200
+ const jit::DeviceInfoCache& device_info_cache,
201
+ const jit::DeviceSet& devices, bool allow_mixing_unknown_and_cpu);
202
+
203
+ // This is like `PickDeviceForXla` except that it returns nullopt (instead of a
204
+ // non-OK Status) if no unambiguous choice of device exists.
205
+ //
206
+ // We return a failing Status for errors unrelated to the device choice
207
+ // algorithm itself.
208
+ StatusOr<std::optional<jit::DeviceId>> MaybePickDeviceForXla(
209
+ const jit::DeviceInfoCache& device_info_cache,
210
+ const jit::DeviceSet& devices, bool allow_mixing_unknown_and_cpu);
211
+ } // namespace tensorflow
212
+
213
+ #endif // TENSORFLOW_COMPILER_JIT_DEVICE_UTIL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/encapsulate_subgraphs_pass.h ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ // An optimization pass that groups nodes marked with a common
17
+ // kXlaClusterAttr into functions, and replaces the original nodes by
18
+ // calls. The calls are annotated with kXlaCompiledKernelAttr.
19
+
20
+ #ifndef TENSORFLOW_COMPILER_JIT_ENCAPSULATE_SUBGRAPHS_PASS_H_
21
+ #define TENSORFLOW_COMPILER_JIT_ENCAPSULATE_SUBGRAPHS_PASS_H_
22
+
23
+ #include "tensorflow/core/common_runtime/optimization_registry.h"
24
+ #include "tensorflow/core/framework/function.h"
25
+ #include "tensorflow/core/graph/graph.h"
26
+ #include "tensorflow/core/lib/core/status.h"
27
+
28
+ namespace tensorflow {
29
+
30
+ // EncapsulateSubgraphs pass takes all the nodes with the same cluster ID
31
+ // (derived from kXlaClusterAttr=ID (kXlaClusterAttr) attribute), puts them into
32
+ // a TF function, and replaces the subgraph in the main graph with a call to
33
+ // that TF function annotated with kXlaCompiledKernelAttr (_XlaCompiledKernel).
34
+ class EncapsulateSubgraphsPass : public GraphOptimizationPass {
35
+ public:
36
+ Status Run(const GraphOptimizationPassOptions& options) override;
37
+ };
38
+
39
+ // A rewriting function to apply to each subgraph during encapsulation.
40
+ // 'arg_source_tensors' are the tensors corresponding to the arguments in the
41
+ // original source graph (*not* 'graph').
42
+ //
43
+ // 'graph' is the subgraph. The rewriting may renumber the inputs and outputs;
44
+ // 'input_permutation' is a mapping from old argument numbers to new argument
45
+ // numbers, whereas 'output_permutation' is the same for outputs. Both
46
+ // 'input_permutation' and 'output_permutation' are initialized to the identity
47
+ // permutation. 'nodedef' is the NodeDef for the call to the function under
48
+ // construction, provided to allow additional attributes to be set.
49
+ // The rewrite may also change the NodeDef's operator name, and that
50
+ // name will be used as the name of the generated function.
51
+ typedef std::function<Status(
52
+ const std::vector<OutputTensor>& arg_source_tensors,
53
+ std::unique_ptr<Graph>* graph, std::vector<int>* input_permutation,
54
+ std::vector<int>* output_permutation, NodeDef* node_def)>
55
+ RewriteSubgraphFn;
56
+
57
+ // Transformation that finds subgraphs whose nodes are marked with
58
+ // 'group_attribute', splits those subgraphs into functions, and replaces
59
+ // the originals with function calls.
60
+ //
61
+ // 'group_attribute' must be a string valued-attribute that names the new
62
+ // functions to introduce.
63
+ //
64
+ // If 'rewrite_subgraph_fn' is set, it is applied to each subgraph before
65
+ // function conversion.
66
+ //
67
+ // If 'reuse_existing_functions' is set, use an existing function with the
68
+ // same name, if any.
69
+ //
70
+ // TODO(phawkins): currently, some information in control edges
71
+ // is not preserved. Suppose you have A and B in the main
72
+ // graph, C and D in a subgraph. B and C have control deps from A, D has control
73
+ // dep from B. Originally D must run after C, post-transformation this
74
+ // dependency is lost.
75
+ Status EncapsulateSubgraphsInFunctions(
76
+ string group_attribute, const Graph& graph_in,
77
+ const RewriteSubgraphFn& rewrite_subgraph_fn, bool reuse_existing_functions,
78
+ std::unique_ptr<Graph>* graph_out, FunctionLibraryDefinition* library);
79
+
80
+ // The attribute that marks function calls produced by the encapsulate
81
+ // subgraphs pass and that should in turn be compiled via XlaLaunch operators.
82
+ extern const char* const kXlaCompiledKernelAttr;
83
+
84
+ // Does `node` have the kXlaCompiledKernelAttr attribute?
85
+ bool IsXlaCompiledKernel(const Node& node);
86
+
87
+ // Functions produced by the EncapsulateSubgraphs pass have their arguments in
88
+ // the order:
89
+ // 1) compile-time constant arguments, in host memory,
90
+ // 2) other arguments, in device memory.
91
+ // 3) resource variable arguments, in host memory. Note that only the resource
92
+ // Tensor itself is in host memory; the underlying value may be in device
93
+ // memory.
94
+ // The functions are annotated with the following attributes that describe how
95
+ // many constant and resource arguments there are:
96
+
97
+ // Name of the attribute containing the number of constant arguments.
98
+ extern const char* const kXlaNumConstantArgsAttr;
99
+
100
+ // Name of the attribute containing the number of resource variable arguments.
101
+ extern const char* const kXlaNumResourceArgsAttr;
102
+
103
+ // Name of the attribute defining whether the cluster has reference variables.
104
+ extern const char* const kXlaHasReferenceVarsAttr;
105
+
106
+ } // namespace tensorflow
107
+
108
+ #endif // TENSORFLOW_COMPILER_JIT_ENCAPSULATE_SUBGRAPHS_PASS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/encapsulate_util.h ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ // This file contains some utility functions for encapsulating XLA computation
17
+ // in host graph and encapsulating outside compilation in XLA computation.
18
+
19
+ #ifndef TENSORFLOW_COMPILER_JIT_ENCAPSULATE_UTIL_H_
20
+ #define TENSORFLOW_COMPILER_JIT_ENCAPSULATE_UTIL_H_
21
+
22
+ #include "absl/container/flat_hash_map.h"
23
+ #include "tensorflow/core/graph/graph.h"
24
+
25
+ namespace tensorflow {
26
+
27
+ // Attribute marking output tensor shapes inferred by XLA. Attribute value is
28
+ // a list of PartialTensorShape objects.
29
+ extern const char kXlaInferredShapesAttrName[];
30
+
31
+ // Infers output shapes for all nodes in graph `g`. The output shapes will be
32
+ // stored in node attribute `kXlaInferredShapesAttrName`.
33
+ //
34
+ // We have to perform shape inference before encapsulation because after
35
+ // encapsulation, some nodes will be encapsulated into function call, and shape
36
+ // inference does not handle function call at the moment.
37
+ Status PerformStaticShapeInferenceBeforeEncapsulation(Graph* g);
38
+
39
+ // Attribute indicating that some ops in this node's XLA computation has control
40
+ // dependency on this node. Attribute value will always be "true".
41
+ extern const char kXlaConnectedToXlaComputationAttrName[];
42
+
43
+ // Attribute indicating that this node has control dependency on some ops in
44
+ // this node's XLA computation. Attribute value will always be "true".
45
+ extern const char kXlaConnectedFromXlaComputationAttrName[];
46
+
47
+ // Attribute indicating that this is an Placeholder node added to act as a
48
+ // temporary input node for an outside compilation node. Attribute value will be
49
+ // string (original input node name).
50
+ extern const char kOutsideCompilationOriginalNodeAttrName[];
51
+
52
+ // Attribute indicating that this is an Placeholder node added to act as a
53
+ // temporary input node for an outside compilation node. Attribute value will be
54
+ // int (src_output for original edge).
55
+ extern const char kOutsideCompilationSrcOutputAttrName[];
56
+
57
+ // Attribute indicating that this node has control dependencies on some other
58
+ // nodes within the same XLA cluster. Attribute value will be a list of string
59
+ // (node names).
60
+ extern const char kXlaControlDependenciesWithinXlaClusterAttrName[];
61
+
62
+ // Attribute indicating that this node is an outside compilation node which is
63
+ // lifted out of If/While/function node. Attribute value will always be boolean
64
+ // value "true".
65
+ extern const char kXlaIsLiftedArgAttrName[];
66
+
67
+ // Attribute indicating that this node is a Placeholder node for an _Arg node
68
+ // lifted out of If/While/function node. Attribute value will be a string, which
69
+ // is the outside compilation cluster name sending the lifted arg node to host.
70
+ extern const char kXlaLiftedArgOutsideCompilationAttrName[];
71
+
72
+ // Attribute indicating that this is an IdentityN node receiving inputs for a
73
+ // outside compilation Placeholder node (the original outside compilation node
74
+ // is moved out of TPU computation, and we left a Placeholder node there).
75
+ // Attribute value will be a string, which is the outside compilation cluster
76
+ // name for the outside compilation Placeholder node.
77
+ extern const char kXlaOutsideCompilationInputsAttrName[];
78
+
79
+ // Attribute indicating that this is a Placeholder node for an _Arg node used in
80
+ // outside compilation. We should not move this node out of XLA computation.
81
+ // Attribute value will always be boolean value "true".
82
+ extern const char kXlaIsPlaceholderForArg[];
83
+
84
+ // Information for XLA computation.
85
+ struct XlaClusterInfo {
86
+ // Add an explicitly-defined default constructor for this class.
87
+ //
88
+ // The compiler may delete the default constructor here because
89
+ // host_compute_core is a const member whose type (std::map) doesn't
90
+ // necessarily have a user provided constructor -- while libc++ and
91
+ // libstdc++ 4.8 provide a user defined default constructor, libstdc++ at
92
+ // least >= 7.3 does not. See also c++11 [class.ctor] p5.
93
+ //
94
+ // TODO(klimek): In c++17 we'll be able to initialize host_compute_core
95
+ // without losing aggregate initialization, which allows us to get rid of
96
+ // the constructor definitions again.
97
+ XlaClusterInfo() {}
98
+ XlaClusterInfo(const string& cluster_name,
99
+ const NameAttrList& func_name_attrs, Node* node,
100
+ const std::map<string, int>& host_compute_core)
101
+ : cluster_name(cluster_name),
102
+ func_name_attrs(func_name_attrs),
103
+ node(node),
104
+ host_compute_core(host_compute_core) {}
105
+ // XLA cluster name. It might be different from `func_name`.
106
+ const string cluster_name;
107
+ // Name and attributes of XLA computation function.
108
+ const NameAttrList func_name_attrs;
109
+ // The XLA computation node in the graph.
110
+ Node* node;
111
+ // A mapping from outside compilation cluster name to its device assignment.
112
+ const std::map<string, int> host_compute_core;
113
+ };
114
+
115
+ // Finds dependencies between outside compilation clusters, including both data
116
+ // dependencies and control dependencies. cluster_deps maps the name name of an
117
+ // outside compilation cluster to a set of names of outside compilation clusters
118
+ // that it depends on.
119
+ tsl::StatusOr<std::unique_ptr<absl::flat_hash_map<string, std::vector<string>>>>
120
+ OutsideCompilationClusterDependencies(
121
+ const Graph* g, const string& outside_compilation_attr_name);
122
+
123
+ // Preprocesses edges within the same XLA cluster. It will perform the following
124
+ // operations in order:
125
+ //
126
+ // 0. Remove edges from source node to outside compilation nodes, and edges
127
+ // from outside compilation nodes to sink node.
128
+ // 1a. For edges between different outside compilation clusters, remove the edge
129
+ // and add attr "kXlaControlDependenciesWithinXlaClusterAttrName = src node
130
+ // name" to dst node.
131
+ // 1b. For control edges between outside compilation and its XLA computation,
132
+ // add attr "kXlaConnected{From, To}XlaComputationAttrName = true" to the
133
+ // outside compilation node.
134
+ // 2. For data edges between different outside compilations, remove the edge
135
+ // and create a Placeholder node as dst node's input.
136
+ Status PreprocessEdgesBetweenOutsideCompilations(
137
+ Graph* g, const string& outside_compilation_attr_name);
138
+
139
+ // Postprocesses edges within the same XLA cluster. This function reverts what
140
+ // `PreprocessEdgesBetweenOutsideCompilations` did. It will perform the
141
+ // following operations in order:
142
+ //
143
+ // 1. Remove Placeholder nodes between different outside compilations (created
144
+ // in `PreprocessEdgesBetweenOutsideCompilations` step 2).
145
+ // 2a. Reconnect control edges between different outside compilations (marked by
146
+ // `PreprocessEdgesBetweenOutsideCompilations` step 1a).
147
+ // Notice that control edges marked by
148
+ // `PreprocessEdgesBetweenOutsideCompilations` step 1b are not handled here.
149
+ // They are handled in `RewriteOutsideCompilationSubgraphFn`.
150
+ Status PostprocessEdgesBetweenOutsideCompilations(
151
+ Graph* g, const string& outside_compilation_attr_name);
152
+ } // namespace tensorflow
153
+
154
+ #endif // TENSORFLOW_COMPILER_JIT_ENCAPSULATE_UTIL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/encapsulate_xla_computations_pass.h ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+ // Rewrites computations generated by the xla.compile() Python code into
16
+ // XlaLaunch nodes.
17
+ //
18
+ // xla.compile() does two main things:
19
+ // a) marks operators that make up an XLA computation with the attribute
20
+ // _xla_compile_id=XYZ, where XYZ is a unique key.
21
+ // b) adds XlaClusterOutput nodes to represent outputs of the computation.
22
+ // These nodes are not marked with the _xla_compile_id attribute.
23
+
24
+ #ifndef TENSORFLOW_COMPILER_JIT_ENCAPSULATE_XLA_COMPUTATIONS_PASS_H_
25
+ #define TENSORFLOW_COMPILER_JIT_ENCAPSULATE_XLA_COMPUTATIONS_PASS_H_
26
+
27
+ #include <functional>
28
+ #include <string>
29
+
30
+ #include "tensorflow/core/common_runtime/optimization_registry.h"
31
+ #include "tensorflow/core/graph/graph.h"
32
+ #include "tensorflow/core/platform/env.h"
33
+ #include "tensorflow/core/platform/statusor.h"
34
+
35
+ namespace tensorflow {
36
+
37
+ // Encapsulates nodes marked with the _xla_compile_id attribute into
38
+ // XlaLaunch operators.
39
+ class EncapsulateXlaComputationsPass : public GraphOptimizationPass {
40
+ public:
41
+ Status Run(const GraphOptimizationPassOptions& options) override;
42
+
43
+ // The following methods are public only for unit tests.
44
+
45
+ // This pass has two stages:
46
+ // a) first, we call EncapsulateSubgraphsPass to encapsulate all nodes
47
+ // marked with the same _xla_compile_id attribute into functions. These
48
+ // functions contain the computations to be passed to XlaLaunch. During
49
+ // encapsulation, we sort the arguments into the order expected by
50
+ // XlaLaunch.
51
+ static Status Encapsulate(std::unique_ptr<Graph>* graph,
52
+ FunctionLibraryDefinition* flib_def);
53
+
54
+ // b) we rewrite the function calls generated in phase (a) into XlaLaunch
55
+ // operators. We also convert the XlaClusterOutput output nodes of the
56
+ // function call into the outputs of the XlaLaunch operator.
57
+ static Status BuildXlaLaunchOps(Graph* graph);
58
+
59
+ struct XlaFunctionInfo {
60
+ int variable_start_index = -1;
61
+ std::string function_name;
62
+ };
63
+
64
+ // We need to introduce this version to adapt to the output of gpu inference
65
+ // converter. The single argument overload version calls this function.
66
+ //
67
+ // When add_edges_to_output_of_downstream_nodes is true, the output edges of
68
+ // the xla_launch_node's immediate downstream nodes would be attached to the
69
+ // generated xla node. For example, if the original graph is
70
+ // StatefulPartitionedCall{_xla_compile_id=1} -> XlaClusterOutput -> NodeA
71
+ // The output graph of this function would look like the following when
72
+ // add_edges_to_output_of_downstream_nodes is true:
73
+ // XlaLaunch -> NodeA
74
+ static Status BuildXlaLaunchOps(
75
+ Graph* graph,
76
+ const std::function<StatusOr<bool>(const Node&)>& is_xla_launch_node,
77
+ const std::function<StatusOr<XlaFunctionInfo>(const Node&)>&
78
+ get_xla_function_info,
79
+ bool add_edges_to_output_of_downstream_nodes);
80
+ };
81
+
82
+ } // namespace tensorflow
83
+
84
+ #endif // TENSORFLOW_COMPILER_JIT_ENCAPSULATE_XLA_COMPUTATIONS_PASS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/extract_outside_compilation_pass.h ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_EXTRACT_OUTSIDE_COMPILATION_PASS_H_
17
+ #define TENSORFLOW_COMPILER_JIT_EXTRACT_OUTSIDE_COMPILATION_PASS_H_
18
+
19
+ #include "absl/types/optional.h"
20
+ #include "tensorflow/compiler/jit/encapsulate_util.h"
21
+ #include "xla/status_macros.h"
22
+ #include "tensorflow/core/graph/graph.h"
23
+
24
+ namespace tensorflow {
25
+
26
+ // Rewrite function for outside compilation subgraphs. It will perform the
27
+ // following steps:
28
+ //
29
+ // 1. Add a XLA computation key placeholder node (it will be used as input for
30
+ // XlaRecvAtHost and XlaSendFromHost);
31
+ // 2. Replace all _Arg nodes with one single XlaRecvAtHost node;
32
+ // 3. Replace all _Retval nodes with one single XlaSendFromHost node;
33
+ // 4. Mark all nodes except key placeholder with attr `xla_cluster_attr_name`
34
+ // and `outside_compilation_attr_name`;
35
+ // 5. For nodes marked with attr kXlaConnectedToXlaComputationAttrName, add a
36
+ // control edge from the node to XlaSendFromHost; for nodes marked with attr
37
+ // kXlaConnectedFromXlaComputationAttrName, add a control edge from
38
+ // XlaRecvAtHost node to the node;
39
+ // 6. Try pruning XlaRecvAtHost/XlaSendFromHost/key placeholder node.
40
+ // 7. Add necessary attributes to `node_def`, so we can replace it with a
41
+ // XlaHostCompute node later. If all input shapes for XlaSendFromHost are
42
+ // known, "shapes" attr will be set to the list of input shapes; otherwise
43
+ // "shape_inference_graph" attr will be set to shape inference function name.
44
+ class RewriteOutsideCompilationSubgraphFn {
45
+ public:
46
+ RewriteOutsideCompilationSubgraphFn(
47
+ const string& xla_cluster_attr_name,
48
+ const string& outside_compilation_attr_name,
49
+ const string& xla_cluster_name, const string& new_function_name)
50
+ : xla_cluster_attr_name_(xla_cluster_attr_name),
51
+ outside_compilation_attr_name_(outside_compilation_attr_name),
52
+ xla_cluster_name_(xla_cluster_name),
53
+ new_function_name_(new_function_name) {}
54
+
55
+ Status operator()(const std::vector<OutputTensor>&,
56
+ std::unique_ptr<Graph>* graph,
57
+ std::vector<int>* input_permutation,
58
+ std::vector<int>* output_permutation, NodeDef* node_def);
59
+
60
+ private:
61
+ string xla_cluster_attr_name_;
62
+ string outside_compilation_attr_name_;
63
+ string xla_cluster_name_;
64
+ string new_function_name_;
65
+ };
66
+
67
+ // For an XLA computation function, replace all outside compilations with
68
+ // XlaHostCompute nodes. Each outside compilation subgraph will be rewritten by
69
+ // `RewriteOutsideCompilationSubgraphFn`, and they will be merged into one
70
+ // single host side graph (`host_graph`).
71
+ //
72
+ // xla_cluster_attr_name and outside_compilation_attr_name: attr name for XLA
73
+ // computation and outside compilation. Required for
74
+ // `RewriteOutsideCompilationSubgraphFn`.
75
+ // xla_cluster_name: XLA cluster name for this XLA computation. We need it
76
+ // because XLA cluster name might be different from `func_name`.
77
+ // func_name_attrs: they will be used to instantiate the XLA computation func.
78
+ // new_func_name: new function name for rewritten XLA computation func.
79
+ // host_compute_core: mapping from outside compilation cluster name to XLA
80
+ // device assignment.
81
+ // fld: FunctionLibraryDefinition object.
82
+ // host_graph: Graph object to store host side graph for all outside
83
+ // compilations within this XLA computation func. If there is no outside
84
+ // compilation, it will be empty.
85
+ // shape_inference_graphs: a list of outside compilation shape inference
86
+ // function names. These functions need to be rewritten later.
87
+ // has_outside_compilation: a bool indicating whether this function has any
88
+ // outside compilation nodes.
89
+ Status ExtractOutsideCompilationForFunction(
90
+ const string& xla_cluster_attr_name,
91
+ const string& outside_compilation_attr_name, const string& xla_cluster_name,
92
+ const NameAttrList& func_name_attrs, const string& new_func_name,
93
+ const string& host_graph_func_name,
94
+ const std::map<string, int>& host_compute_core, FunctionLibraryRuntime* flr,
95
+ FunctionLibraryDefinition* fld, std::vector<string>* shape_inference_graphs,
96
+ bool* has_outside_compilation);
97
+
98
+ // Rewrites XLA computation in `clusters` to replace outside compilation nodes
99
+ // with XlaHostCompute, and moves those outside compilations into `g`. If shapes
100
+ // of outside compilation outputs cannot be determined now, we will store shape
101
+ // inference graph into `fld`.
102
+ Status ExtractOutsideCompilation(
103
+ const string& xla_cluster_attr_name,
104
+ const string& outside_compilation_attr_name,
105
+ const std::unordered_map<string, XlaClusterInfo>& clusters, Graph* g,
106
+ FunctionLibraryRuntime* flr, FunctionLibraryDefinition* fld,
107
+ bool* modified);
108
+
109
+ } // namespace tensorflow
110
+
111
+ #endif // TENSORFLOW_COMPILER_JIT_EXTRACT_OUTSIDE_COMPILATION_PASS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/flags.h ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_FLAGS_H_
17
+ #define TENSORFLOW_COMPILER_JIT_FLAGS_H_
18
+
19
+ #include <cstdint>
20
+ #include <optional>
21
+ #include <string>
22
+ #include <vector>
23
+
24
+ #include "absl/container/flat_hash_set.h"
25
+ #include "absl/types/optional.h"
26
+ #include "tensorflow/core/framework/types.h"
27
+ #include "tensorflow/core/platform/types.h"
28
+ #include "tensorflow/core/protobuf/config.pb.h"
29
+ #include "tensorflow/core/util/command_line_flags.h"
30
+
31
+ namespace tensorflow {
32
+
33
+ struct XlaAutoJitFlag {
34
+ // Control compilation of operators into XLA computations on CPU and GPU
35
+ // devices. 0 = use ConfigProto setting; -1 = off; 1 = on for things very
36
+ // likely to be improved; 2 = on for everything.
37
+ //
38
+ // If all non-CPU ops in the graph being optimized are placed on a single GPU
39
+ // and there is at least one node placed on that GPU then
40
+ // `optimization_level_single_gpu` applies. Otherwise
41
+ // `optimization_level_general` applies.
42
+ //
43
+ // Experimental.
44
+ int32 optimization_level_single_gpu;
45
+ int32 optimization_level_general;
46
+ };
47
+
48
+ // Sets the xla_auto_jit_flag based on the given flag string. Supported syntax
49
+ // is:
50
+ // <number>: sets general and single_gpu setting to the provided number.
51
+ // single-gpu(<number>): sets the single_gpu setting to the provided number.
52
+ bool SetXlaAutoJitFlagFromFlagString(const string& value);
53
+
54
+ // Flags associated with the XLA bridge's mark_for_compilation_pass module.
55
+ struct MarkForCompilationPassFlags {
56
+ XlaAutoJitFlag xla_auto_jit_flag;
57
+
58
+ // Minimum number of operators in an XLA compilation. Ignored for operators
59
+ // placed on an XLA device or operators explicitly marked for compilation.
60
+ int32 tf_xla_min_cluster_size;
61
+
62
+ // Maximum number of operators in an XLA compilation.
63
+ int32 tf_xla_max_cluster_size;
64
+
65
+ // If non-empty, limit XLA clustering to the following TF operations.
66
+ string tf_xla_ops_to_cluster;
67
+
68
+ // If non-empty, remove following operations from XLA clustering excludelist.
69
+ string tf_xla_cluster_exclude_ops;
70
+
71
+ // Dump graphs during XLA compilation.
72
+ bool tf_xla_clustering_debug;
73
+
74
+ // Enables global JIT compilation for CPU via SessionOptions.
75
+ bool tf_xla_cpu_global_jit;
76
+
77
+ // "Compiler fuel" for clustering. Only this many ops will be marked as
78
+ // eligible for clustering.
79
+ int64_t tf_xla_clustering_fuel;
80
+
81
+ // If tf_xla_disable_deadness_safety_checks_for_debugging is set to true then
82
+ // we do not do deadness related safety checks. This is unsound in general,
83
+ // but can be used as a debugging aid.
84
+ bool tf_xla_disable_deadness_safety_checks_for_debugging;
85
+
86
+ // If tf_xla_disable_resource_variable_safety_checks_for_debugging is set to
87
+ // true then we do not do safety checks to preserve TensorFlow's resource
88
+ // variable concurrency semantics. This is unsound in general, but can be
89
+ // used as a debugging aid.
90
+ bool tf_xla_disable_resource_variable_safety_checks_for_debugging;
91
+
92
+ // If true names of clustered operations will be computed deterministically
93
+ // so that they remain stable from run to run of auto clusteing.
94
+ bool tf_xla_deterministic_cluster_names;
95
+
96
+ // If non-empty, JIT-compiled executables are saved to and loaded from the
97
+ // specified file system directory path.
98
+ std::string tf_xla_persistent_cache_directory;
99
+
100
+ // If non-empty, the persistent cache will only be used for the specified
101
+ // devices (comma separated). Each device type should be able to be converted
102
+ // to `DeviceType`.
103
+ std::string tf_xla_persistent_cache_device_types;
104
+
105
+ bool tf_xla_persistent_cache_read_only;
106
+
107
+ // If true, entries loaded into the XLA compile cache will not have their
108
+ // signatures checked strictly. This should generally not be disabled except
109
+ // for debugging. Defaults to false.
110
+ bool tf_xla_disable_strict_signature_checks;
111
+
112
+ // Specifies the persistance cache prefix. Default is "xla_compile_cache"
113
+ string tf_xla_persistent_cache_prefix;
114
+ };
115
+
116
+ // Flags associated with XLA Sparse Core.
117
+ struct XlaSparseCoreFlags {
118
+ // Max level of division to split input data into minibatches.
119
+ int tf_xla_sparse_core_minibatch_max_division_level;
120
+
121
+ // Disable table stacking for all the tables passed to the SparseCore
122
+ // mid level API.
123
+ bool tf_xla_sparse_core_disable_table_stacking;
124
+
125
+ // If non-zero, limits the size of the activations for a given table to
126
+ // be below these many bytes.
127
+ int64_t tf_xla_sparse_core_stacking_mem_limit_bytes;
128
+
129
+ // If non-zero, limits the size of any table shard to be below these
130
+ // many bytes.
131
+ int64_t tf_xla_sparse_core_stacking_table_shard_limit_bytes;
132
+ };
133
+
134
+ // Flags associated with the XLA bridge's xla_device module.
135
+ struct XlaDeviceFlags {
136
+ // Switch the CPU device into "on-demand" mode, where instead of
137
+ // auto-clustering ops are compiled one by one just-in-time.
138
+ // Enabling this mode by a legacy flag is a temporary mechanism. When this
139
+ // feature is battle-tested, we will switch this to be a session option.
140
+ bool tf_xla_compile_on_demand;
141
+
142
+ // Enables "XLA" devices if this flag is set.
143
+ bool tf_xla_enable_xla_devices;
144
+ };
145
+
146
+ // Flags common to the _Xla* ops and their kernels.
147
+ struct XlaOpsCommonFlags {
148
+ // If true, _XlaCompile always refuses to compile the cluster, which means the
149
+ // XLA clusters always run in the TF executor. Defaults to false.
150
+ bool tf_xla_always_defer_compilation;
151
+ // If true, _XlaCompile compiles the cluster asynchronously with respect to
152
+ // the main execution. The fallback path is taken while compilation happens.
153
+ bool tf_xla_async_compilation;
154
+
155
+ class PjRtForSingleDeviceCompilationRollout {
156
+ public:
157
+ // Allow using Device API (PjRt) for `device_type` in the XlaLaunch op.
158
+ // Please note that `enabled_for_xla_launch_` needs to be true in addition
159
+ // to the `device_type` being allowed in order to use the Device API for
160
+ // single device compilation and execution in the XlaLaunch op.
161
+ void AllowForDeviceInXlaLaunch(const DeviceType& device_type) {
162
+ xla_launch_allowed_devices_.insert(device_type.type_string());
163
+ }
164
+
165
+ bool IsEnabledInXlaLaunchForDevice(const DeviceType& device_type) const {
166
+ if (!enabled_for_gpu_ && device_type.type_string() == "GPU") return false;
167
+ return enabled_for_all_ ||
168
+ (enabled_for_xla_launch_ &&
169
+ xla_launch_allowed_devices_.contains(device_type.type_string()));
170
+ }
171
+
172
+ // Allow using Device API (PjRt) for `device_type` in the XlaCompileOnDemand
173
+ // op. Please note that `enabled_for_compile_on_demand_` needs to be true in
174
+ // addition to the `device_type` being allowed in order to use the Device
175
+ // API for single device compilation and execution in the XlaCompileOnDemand
176
+ // op.
177
+ void AllowForDeviceInXlaCompileOnDemand(const DeviceType& device_type) {
178
+ xla_compile_on_demand_allowed_devices_.insert(device_type.type_string());
179
+ }
180
+
181
+ bool IsEnabledInXlaCompileOnDemandForDevice(
182
+ const DeviceType& device_type) const {
183
+ if (!enabled_for_gpu_ && device_type.type_string() == "GPU") return false;
184
+ return enabled_for_all_ ||
185
+ (enabled_for_compile_on_demand_ &&
186
+ xla_compile_on_demand_allowed_devices_.contains(
187
+ device_type.type_string()));
188
+ }
189
+
190
+ // Allow using Device API (PjRt) for `device_type` in the XlaCompile and
191
+ // XlaRun ops. Please note that `enabled_for_compile_and_run_` needs to be
192
+ // true in addition to the `device_type` being allowed in order to use the
193
+ // Device API for single device compilation and execution in the XlaCompile
194
+ // and XlaRun ops.
195
+ void AllowForDeviceInXlaCompileAndRun(const DeviceType& device_type) {
196
+ xla_compile_and_run_allowed_devices_.insert(device_type.type_string());
197
+ }
198
+
199
+ bool IsEnabledInXlaCompileAndRunForDevice(
200
+ const DeviceType& device_type) const {
201
+ if (!enabled_for_gpu_ && device_type.type_string() == "GPU") return false;
202
+ return enabled_for_all_ || (enabled_for_compile_and_run_ &&
203
+ xla_compile_and_run_allowed_devices_.contains(
204
+ device_type.type_string()));
205
+ }
206
+
207
+ bool IsEnabledForGpu() const { return enabled_for_gpu_; }
208
+
209
+ // If true, uses Device API (PjRt) for single device compilation and
210
+ // execution of functions marked for JIT compilation i.e. jit_compile=True.
211
+ // Defaults to false.
212
+ bool enabled_for_xla_launch_;
213
+
214
+ // If true, uses Device API (PjRt) for compiling and executing ops one by
215
+ // one in "on-demand" mode. Defaults to false.
216
+ bool enabled_for_compile_on_demand_;
217
+
218
+ // If true, uses Device API (PjRt) for compilation and execution when
219
+ // auto-clustering is enabled. Defaults to false.
220
+ bool enabled_for_compile_and_run_;
221
+
222
+ // If true, uses Device API (PjRt) for compilation and execution everywhere
223
+ // i.e. for functions marked for JIT compilation, for ops in "on-demand"
224
+ // mode and auto-clustering. Defaults to false.
225
+ //
226
+ // Note that this flag can be overridden by device flag like
227
+ // `enabled_for_gpu_` below.
228
+ bool enabled_for_all_;
229
+
230
+ // If true, enable Device API (PjRt) for TF GPU device. This is a helper
231
+ // flag so that individual tests can turn on PjRt for GPU specifically.
232
+ // Once the rollout to GPU is complete, this flag can be deprecated.
233
+ bool enabled_for_gpu_;
234
+
235
+ private:
236
+ // Devices for which using Device API (PjRt) is allowed in the XlaLaunch op.
237
+ // This can only be modified programmatically.
238
+ absl::flat_hash_set<std::string> xla_launch_allowed_devices_;
239
+ // Devices for which using Device API (PjRt) is allowed in the
240
+ // XlaCompileOnDemand op. This can only be modified programmatically.
241
+ absl::flat_hash_set<std::string> xla_compile_on_demand_allowed_devices_;
242
+ // Devices for which using Device API (PjRt) is allowed in the
243
+ // XlaCompile and XlaRun ops. This can only be modified programmatically.
244
+ absl::flat_hash_set<std::string> xla_compile_and_run_allowed_devices_;
245
+ } tf_xla_use_device_api;
246
+ };
247
+
248
+ // Flags for the XlaCallModule kernel.
249
+ struct XlaCallModuleFlags {
250
+ // Used by XlaCallModuleOp to specify safety checks to disable.
251
+ absl::flat_hash_set<std::string> disabled_checks;
252
+ };
253
+
254
+ // Flags for the build_xla_ops pass.
255
+ struct BuildXlaOpsPassFlags {
256
+ // Enables lazy compilation for TF/XLA (only when auto-clustering) if true.
257
+ // Defaults to true.
258
+ bool tf_xla_enable_lazy_compilation;
259
+
260
+ // If true then insert Print nodes to print out values produced by XLA
261
+ // clusters. Useful for debugging.
262
+ bool tf_xla_print_cluster_outputs;
263
+
264
+ // If true, insert CheckNumerics nodes for every floating point typed input to
265
+ // an XLA cluster.
266
+ bool tf_xla_check_cluster_input_numerics;
267
+
268
+ // If true, insert CheckNumerics nodes for every floating point typed output
269
+ // from an XLA cluster.
270
+ bool tf_xla_check_cluster_output_numerics;
271
+
272
+ // Disables all constant folding. The primary use for this is for testing to
273
+ // guarantee that tests are run on XLA and not on TF's CPU implementation.
274
+ bool tf_xla_disable_constant_folding;
275
+
276
+ // Disables full embedding pipelining when true. Instead, strict SparseCore
277
+ // TensorCore sequencing will be used.
278
+ bool tf_xla_disable_full_embedding_pipelining;
279
+
280
+ // Force the WhileOps in embedding_pipelining and embedding_sequencing to use
281
+ // this many parallel_iterations
282
+ int tf_xla_embedding_parallel_iterations;
283
+ };
284
+
285
+ // Flags for common MLIR configurations.
286
+ struct MlirCommonFlags {
287
+ ConfigProto::Experimental::MlirBridgeRollout tf_mlir_enable_mlir_bridge;
288
+
289
+ bool tf_mlir_enable_merge_control_flow_pass;
290
+ bool tf_mlir_enable_convert_control_to_data_outputs_pass;
291
+ bool tf_mlir_enable_strict_clusters;
292
+ bool tf_mlir_enable_generic_outside_compilation;
293
+ bool tf_mlir_enable_tpu_variable_runtime_reformatting_pass;
294
+ };
295
+
296
+ // Flags for the JitRt pipeline -- see tf_jitrt_pipeline.h for details.
297
+ struct JitRtFlags {
298
+ bool always_specialize;
299
+ bool cost_driven_async_parallel_for;
300
+
301
+ // Enables tracking of the "live" JitRt queries to, on a crash, identify the
302
+ // "query of death". See TfJitRtQueryOfDeathLogger.
303
+ bool log_query_of_death;
304
+
305
+ // Enable vectorization, which requires tiling and peeling on different ops.
306
+ bool vectorize;
307
+
308
+ // Enables crash reproducer for JitRt MLIR pass manager.
309
+ bool enable_crash_reproducer;
310
+ };
311
+
312
+ // Return a pointer to the DumpGraphFlags struct;
313
+ // repeated calls return the same pointer.
314
+ // This should be called only after Flags::Parse() has returned.
315
+
316
+ // Getters for flags structs defined above. The first call to any of these
317
+ // parses TF_XLA_FLAGS for all of them. Those functions which return a pointer
318
+ // always return the same pointer.
319
+ MarkForCompilationPassFlags* GetMarkForCompilationPassFlags();
320
+ BuildXlaOpsPassFlags* GetBuildXlaOpsPassFlags();
321
+ XlaSparseCoreFlags* GetXlaSparseCoreFlags();
322
+ XlaDeviceFlags* GetXlaDeviceFlags();
323
+ XlaOpsCommonFlags* GetXlaOpsCommonFlags();
324
+ XlaCallModuleFlags* GetXlaCallModuleFlags();
325
+
326
+ MlirCommonFlags* GetMlirCommonFlags();
327
+
328
+ void ResetJitCompilerFlags();
329
+
330
+ const JitRtFlags& GetJitRtFlags();
331
+
332
+ // Returns the effective MLIR bridge rollout state based on the flags and the
333
+ // optional configuration.
334
+ ConfigProto::Experimental::MlirBridgeRollout GetMlirBridgeRolloutState(
335
+ std::optional<const ConfigProto> config_proto);
336
+
337
+ // Appends the flag definitions associated with
338
+ // MarkForCompilationPassFlags/DumpGraphFlags to `flag_list`.
339
+ //
340
+ // Has the side-effect of parsing TF_XLA_FLAGS if that hasn't happened yet.
341
+ void AppendMarkForCompilationPassFlags(
342
+ std::vector<tensorflow::Flag>* flag_list);
343
+
344
+ // Disables XLA compilation, forces it to return an error message instead. Can
345
+ // be used by a server to ensure that JIT compilation is opt-in.
346
+ void DisableXlaCompilation();
347
+
348
+ // Enables XLA compilation. Can be used with `DisableXlaCompilation` to
349
+ // enable/disable JIT compilation at different stages.
350
+ void EnableXlaCompilation();
351
+
352
+ // Returns `false` unless `DisableXlaCompilation` was called.
353
+ bool FailOnXlaCompilation();
354
+
355
+ } // namespace tensorflow
356
+
357
+ #endif // TENSORFLOW_COMPILER_JIT_FLAGS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/tensorflow/compiler/jit/force_xla_constants_on_host_pass.h ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef TENSORFLOW_COMPILER_JIT_FORCE_XLA_CONSTANTS_ON_HOST_PASS_H_
17
+ #define TENSORFLOW_COMPILER_JIT_FORCE_XLA_CONSTANTS_ON_HOST_PASS_H_
18
+
19
+ #include "absl/container/flat_hash_set.h"
20
+ #include "tensorflow/compiler/jit/compilability_check_util.h"
21
+ #include "tensorflow/core/common_runtime/optimization_registry.h"
22
+
23
+ namespace tensorflow {
24
+
25
+ // An optimization pass which marks the constants which have to be resolved for
26
+ // XLA compilation with `_input_hostmem`.
27
+ class ForceXlaConstantsOnHostPass : public GraphOptimizationPass {
28
+ public:
29
+ ForceXlaConstantsOnHostPass() = default;
30
+
31
+ Status Run(const GraphOptimizationPassOptions& options) override;
32
+ };
33
+
34
+ } // namespace tensorflow
35
+
36
+ #endif // TENSORFLOW_COMPILER_JIT_FORCE_XLA_CONSTANTS_ON_HOST_PASS_H_