@@ -46,29 +46,31 @@ public class BitwiseOps(
46
46
public val scope: Scope = ops.scope
47
47
48
48
/* *
49
- * Elementwise computes the bitwise AND of ``` x``` and ``` y```.
50
- * The result will have those bits set, that are set in both ``` x``` and ``` y```. The
51
- * computation is performed on the underlying representations of ``` x``` and ``` y```.
52
- * For example:
49
+ * Elementwise computes the bitwise AND of `x` and `y`.
50
+ * The result will have those bits set, that are set in both `x` and `y`. The
51
+ * computation is performed on the underlying representations of `x` and `y`.
53
52
*
54
- * import tensorflow as tf
53
+ * For example:
54
+ * ```
55
+ * import tensorflow as tf
55
56
* from tensorflow.python.ops import bitwise_ops
56
- * dtype_list = [ tf.int8, tf.int16, tf.int32, tf.int64,
57
+ * dtype_list = [ tf.int8, tf.int16, tf.int32, tf.int64,
57
58
* tf.uint8, tf.uint16, tf.uint32, tf.uint64]
58
59
*
59
60
* for dtype in dtype_list:
60
- * lhs = tf.constant([ 0, 5, 3, 14], dtype=dtype)
61
- * rhs = tf.constant([ 5, 0, 7, 11], dtype=dtype)
62
- * exp = tf.constant([ 0, 0, 3, 10], dtype=tf.float32)
61
+ * lhs = tf.constant([ 0, 5, 3, 14], dtype=dtype)
62
+ * rhs = tf.constant([ 5, 0, 7, 11], dtype=dtype)
63
+ * exp = tf.constant([ 0, 0, 3, 10], dtype=tf.float32)
63
64
*
64
65
* res = bitwise_ops.bitwise_and(lhs, rhs)
65
66
* tf.assert_equal(tf.cast(res, tf.float32), exp) # TRUE
66
67
*
68
+ * ```
67
69
*
68
- * @param T data type for ` z` output
70
+ * @param <T> data type for `z` output
69
71
* @param x the x value
70
72
* @param y the y value
71
- * @param T data type for ` BitwiseAnd` output and operands
73
+ * @param <T> data type for `BitwiseAnd` output and operands
72
74
* @return a new instance of BitwiseAnd
73
75
* @see org.tensorflow.op.BitwiseOps.bitwiseAnd
74
76
*/
@@ -79,29 +81,31 @@ public class BitwiseOps(
79
81
)
80
82
81
83
/* *
82
- * Elementwise computes the bitwise OR of ``` x``` and ``` y```.
83
- * The result will have those bits set, that are set in ``` x```, ``` y``` or both. The
84
- * computation is performed on the underlying representations of ``` x``` and ``` y```.
85
- * For example:
84
+ * Elementwise computes the bitwise OR of `x` and `y`.
85
+ * The result will have those bits set, that are set in `x`, `y` or both. The
86
+ * computation is performed on the underlying representations of `x` and `y`.
86
87
*
87
- * import tensorflow as tf
88
+ * For example:
89
+ * ```
90
+ * import tensorflow as tf
88
91
* from tensorflow.python.ops import bitwise_ops
89
- * dtype_list = [ tf.int8, tf.int16, tf.int32, tf.int64,
92
+ * dtype_list = [ tf.int8, tf.int16, tf.int32, tf.int64,
90
93
* tf.uint8, tf.uint16, tf.uint32, tf.uint64]
91
94
*
92
95
* for dtype in dtype_list:
93
- * lhs = tf.constant([ 0, 5, 3, 14], dtype=dtype)
94
- * rhs = tf.constant([ 5, 0, 7, 11], dtype=dtype)
95
- * exp = tf.constant([ 5, 5, 7, 15], dtype=tf.float32)
96
+ * lhs = tf.constant([ 0, 5, 3, 14], dtype=dtype)
97
+ * rhs = tf.constant([ 5, 0, 7, 11], dtype=dtype)
98
+ * exp = tf.constant([ 5, 5, 7, 15], dtype=tf.float32)
96
99
*
97
100
* res = bitwise_ops.bitwise_or(lhs, rhs)
98
101
* tf.assert_equal(tf.cast(res, tf.float32), exp) # TRUE
99
102
*
103
+ * ```
100
104
*
101
- * @param T data type for ` z` output
105
+ * @param <T> data type for `z` output
102
106
* @param x the x value
103
107
* @param y the y value
104
- * @param T data type for ` BitwiseOr` output and operands
108
+ * @param <T> data type for `BitwiseOr` output and operands
105
109
* @return a new instance of BitwiseOr
106
110
* @see org.tensorflow.op.BitwiseOps.bitwiseOr
107
111
*/
@@ -112,29 +116,31 @@ public class BitwiseOps(
112
116
)
113
117
114
118
/* *
115
- * Elementwise computes the bitwise XOR of ``` x``` and ``` y```.
116
- * The result will have those bits set, that are different in ``` x``` and ``` y```. The
117
- * computation is performed on the underlying representations of ``` x``` and ``` y```.
118
- * For example:
119
+ * Elementwise computes the bitwise XOR of `x` and `y`.
120
+ * The result will have those bits set, that are different in `x` and `y`. The
121
+ * computation is performed on the underlying representations of `x` and `y`.
119
122
*
120
- * import tensorflow as tf
123
+ * For example:
124
+ * ```
125
+ * import tensorflow as tf
121
126
* from tensorflow.python.ops import bitwise_ops
122
- * dtype_list = [ tf.int8, tf.int16, tf.int32, tf.int64,
127
+ * dtype_list = [ tf.int8, tf.int16, tf.int32, tf.int64,
123
128
* tf.uint8, tf.uint16, tf.uint32, tf.uint64]
124
129
*
125
130
* for dtype in dtype_list:
126
- * lhs = tf.constant([ 0, 5, 3, 14], dtype=dtype)
127
- * rhs = tf.constant([ 5, 0, 7, 11], dtype=dtype)
128
- * exp = tf.constant([ 5, 5, 4, 5], dtype=tf.float32)
131
+ * lhs = tf.constant([ 0, 5, 3, 14], dtype=dtype)
132
+ * rhs = tf.constant([ 5, 0, 7, 11], dtype=dtype)
133
+ * exp = tf.constant([ 5, 5, 4, 5], dtype=tf.float32)
129
134
*
130
135
* res = bitwise_ops.bitwise_xor(lhs, rhs)
131
136
* tf.assert_equal(tf.cast(res, tf.float32), exp) # TRUE
132
137
*
138
+ * ```
133
139
*
134
- * @param T data type for ` z` output
140
+ * @param <T> data type for `z` output
135
141
* @param x the x value
136
142
* @param y the y value
137
- * @param T data type for ` BitwiseXor` output and operands
143
+ * @param <T> data type for `BitwiseXor` output and operands
138
144
* @return a new instance of BitwiseXor
139
145
* @see org.tensorflow.op.BitwiseOps.bitwiseXor
140
146
*/
@@ -145,51 +151,53 @@ public class BitwiseOps(
145
151
)
146
152
147
153
/* *
148
- * Invert (flip) each bit of supported types; for example, type ``` uint8``` value 01010101
149
- * becomes 10101010.
150
- * Flip each bit of supported types. For example, type ``` int8`` ` (decimal 2) binary 00000010
154
+ * Invert (flip) each bit of supported types; for example, type `uint8` value 01010101 becomes
155
+ * 10101010.
156
+ * Flip each bit of supported types. For example, type `int8` (decimal 2) binary 00000010
151
157
* becomes (decimal -3) binary 11111101.
152
- * This operation is performed on each element of the tensor argument ``` x```.
153
- * Example:
158
+ * This operation is performed on each element of the tensor argument `x`.
154
159
*
155
- * import tensorflow as tf
160
+ * Example:
161
+ * ```
162
+ * import tensorflow as tf
156
163
* from tensorflow.python.ops import bitwise_ops
157
164
*
158
165
* # flip 2 (00000010) to -3 (11111101)
159
166
* tf.assert_equal(-3, bitwise_ops.invert(2))
160
167
*
161
- * dtype_list = [ dtypes.int8, dtypes.int16, dtypes.int32, dtypes.int64,
168
+ * dtype_list = [ dtypes.int8, dtypes.int16, dtypes.int32, dtypes.int64,
162
169
* dtypes.uint8, dtypes.uint16, dtypes.uint32, dtypes.uint64]
163
170
*
164
- * inputs = [ 0, 5, 3, 14]
171
+ * inputs = [ 0, 5, 3, 14]
165
172
* for dtype in dtype_list:
166
173
* # Because of issues with negative numbers, let's test this indirectly.
167
174
* # 1. invert(a) and a = 0
168
175
* # 2. invert(a) or a = invert(0)
169
- * input_tensor = tf.constant([ 0, 5, 3, 14], dtype=dtype)
170
- * not_a_and_a, not_a_or_a, not_0 = [ bitwise_ops.bitwise_and(
176
+ * input_tensor = tf.constant([ 0, 5, 3, 14], dtype=dtype)
177
+ * not_a_and_a, not_a_or_a, not_0 = [ bitwise_ops.bitwise_and(
171
178
* input_tensor, bitwise_ops.invert(input_tensor)),
172
179
* bitwise_ops.bitwise_or(
173
180
* input_tensor, bitwise_ops.invert(input_tensor)),
174
181
* bitwise_ops.invert(
175
182
* tf.constant(0, dtype=dtype))]
176
183
*
177
- * expected = tf.constant([ 0, 0, 0, 0], dtype=tf.float32)
184
+ * expected = tf.constant([ 0, 0, 0, 0], dtype=tf.float32)
178
185
* tf.assert_equal(tf.cast(not_a_and_a, tf.float32), expected)
179
186
*
180
- * expected = tf.cast([ not_0] * 4, tf.float32)
187
+ * expected = tf.cast([ not_0] * 4, tf.float32)
181
188
* tf.assert_equal(tf.cast(not_a_or_a, tf.float32), expected)
182
189
*
183
190
* # For unsigned dtypes let's also check the result directly.
184
191
* if dtype.is_unsigned:
185
192
* inverted = bitwise_ops.invert(input_tensor)
186
- * expected = tf.constant([ dtype.max - x for x in inputs], dtype=tf.float32)
193
+ * expected = tf.constant([ dtype.max - x for x in inputs], dtype=tf.float32)
187
194
* tf.assert_equal(tf.cast(inverted, tf.float32), tf.cast(expected, tf.float32))
188
195
*
196
+ * ```
189
197
*
190
- * @param T data type for ` y` output
198
+ * @param <T> data type for `y` output
191
199
* @param x the x value
192
- * @param T data type for ` Invert` output and operands
200
+ * @param <T> data type for `Invert` output and operands
193
201
* @return a new instance of Invert
194
202
* @see org.tensorflow.op.BitwiseOps.invert
195
203
*/
@@ -198,41 +206,42 @@ public class BitwiseOps(
198
206
)
199
207
200
208
/* *
201
- * Elementwise computes the bitwise left-shift of ``` x``` and ``` y`` `.
202
- * If ``` y``` is negative, or greater than or equal to the width of ``` x`` ` in bits the
209
+ * Elementwise computes the bitwise left-shift of `x` and `y `.
210
+ * If `y` is negative, or greater than or equal to the width of `x ` in bits the
203
211
* result is implementation defined.
204
- * Example:
205
212
*
206
- * import tensorflow as tf
213
+ * Example:
214
+ * ```
215
+ * import tensorflow as tf
207
216
* from tensorflow.python.ops import bitwise_ops
208
217
* import numpy as np
209
- * dtype_list = [ tf.int8, tf.int16, tf.int32, tf.int64]
218
+ * dtype_list = [ tf.int8, tf.int16, tf.int32, tf.int64]
210
219
*
211
220
* for dtype in dtype_list:
212
- * lhs = tf.constant([ -1, -5, -3, -14], dtype=dtype)
213
- * rhs = tf.constant([ 5, 0, 7, 11], dtype=dtype)
221
+ * lhs = tf.constant([ -1, -5, -3, -14], dtype=dtype)
222
+ * rhs = tf.constant([ 5, 0, 7, 11], dtype=dtype)
214
223
*
215
224
* left_shift_result = bitwise_ops.left_shift(lhs, rhs)
216
225
*
217
226
* print(left_shift_result)
218
227
*
219
228
* # This will print:
220
- * # tf.Tensor([ -32 -5 -128 0], shape=(4,), dtype=int8)
221
- * # tf.Tensor([ -32 -5 -384 -28672], shape=(4,), dtype=int16)
222
- * # tf.Tensor([ -32 -5 -384 -28672], shape=(4,), dtype=int32)
223
- * # tf.Tensor([ -32 -5 -384 -28672], shape=(4,), dtype=int64)
229
+ * # tf.Tensor([ -32 -5 -128 0], shape=(4,), dtype=int8)
230
+ * # tf.Tensor([ -32 -5 -384 -28672], shape=(4,), dtype=int16)
231
+ * # tf.Tensor([ -32 -5 -384 -28672], shape=(4,), dtype=int32)
232
+ * # tf.Tensor([ -32 -5 -384 -28672], shape=(4,), dtype=int64)
224
233
*
225
- * lhs = np.array([ -2, 64, 101, 32], dtype=np.int8)
226
- * rhs = np.array([ -1, -5, -3, -14], dtype=np.int8)
234
+ * lhs = np.array([ -2, 64, 101, 32], dtype=np.int8)
235
+ * rhs = np.array([ -1, -5, -3, -14], dtype=np.int8)
227
236
* bitwise_ops.left_shift(lhs, rhs)
228
- * # <tf.Tensor: shape=(4,), dtype=int8, numpy=array([ -2, 64, 101, 32],
229
- * dtype=int8)>
237
+ * # <tf.Tensor: shape=(4,), dtype=int8, numpy=array([ -2, 64, 101, 32], dtype=int8)>
230
238
*
239
+ * ```
231
240
*
232
- * @param T data type for ` z` output
241
+ * @param <T> data type for `z` output
233
242
* @param x the x value
234
243
* @param y the y value
235
- * @param T data type for ` LeftShift` output and operands
244
+ * @param <T> data type for `LeftShift` output and operands
236
245
* @return a new instance of LeftShift
237
246
* @see org.tensorflow.op.BitwiseOps.leftShift
238
247
*/
@@ -243,43 +252,45 @@ public class BitwiseOps(
243
252
)
244
253
245
254
/* *
246
- * Elementwise computes the bitwise right-shift of ``` x``` and ``` y`` `.
255
+ * Elementwise computes the bitwise right-shift of `x` and `y `.
247
256
* Performs a logical shift for unsigned integer types, and an arithmetic shift
248
257
* for signed integer types.
249
- * If ``` y``` is negative, or greater than or equal to than the width of ``` x``` in bits
258
+ *
259
+ * If `y` is negative, or greater than or equal to than the width of `x` in bits
250
260
* the result is implementation defined.
251
- * Example:
252
261
*
253
- * import tensorflow as tf
262
+ * Example:
263
+ * ```
264
+ * import tensorflow as tf
254
265
* from tensorflow.python.ops import bitwise_ops
255
266
* import numpy as np
256
- * dtype_list = [ tf.int8, tf.int16, tf.int32, tf.int64]
267
+ * dtype_list = [ tf.int8, tf.int16, tf.int32, tf.int64]
257
268
*
258
269
* for dtype in dtype_list:
259
- * lhs = tf.constant([ -1, -5, -3, -14], dtype=dtype)
260
- * rhs = tf.constant([ 5, 0, 7, 11], dtype=dtype)
270
+ * lhs = tf.constant([ -1, -5, -3, -14], dtype=dtype)
271
+ * rhs = tf.constant([ 5, 0, 7, 11], dtype=dtype)
261
272
*
262
273
* right_shift_result = bitwise_ops.right_shift(lhs, rhs)
263
274
*
264
275
* print(right_shift_result)
265
276
*
266
277
* # This will print:
267
- * # tf.Tensor([ -1 -5 -1 -1], shape=(4,), dtype=int8)
268
- * # tf.Tensor([ -1 -5 -1 -1], shape=(4,), dtype=int16)
269
- * # tf.Tensor([ -1 -5 -1 -1], shape=(4,), dtype=int32)
270
- * # tf.Tensor([ -1 -5 -1 -1], shape=(4,), dtype=int64)
278
+ * # tf.Tensor([ -1 -5 -1 -1], shape=(4,), dtype=int8)
279
+ * # tf.Tensor([ -1 -5 -1 -1], shape=(4,), dtype=int16)
280
+ * # tf.Tensor([ -1 -5 -1 -1], shape=(4,), dtype=int32)
281
+ * # tf.Tensor([ -1 -5 -1 -1], shape=(4,), dtype=int64)
271
282
*
272
- * lhs = np.array([ -2, 64, 101, 32], dtype=np.int8)
273
- * rhs = np.array([ -1, -5, -3, -14], dtype=np.int8)
283
+ * lhs = np.array([ -2, 64, 101, 32], dtype=np.int8)
284
+ * rhs = np.array([ -1, -5, -3, -14], dtype=np.int8)
274
285
* bitwise_ops.right_shift(lhs, rhs)
275
- * # <tf.Tensor: shape=(4,), dtype=int8, numpy=array([ -2, 64, 101, 32],
276
- * dtype=int8)>
286
+ * # <tf.Tensor: shape=(4,), dtype=int8, numpy=array([ -2, 64, 101, 32], dtype=int8)>
277
287
*
288
+ * ```
278
289
*
279
- * @param T data type for ` z` output
290
+ * @param <T> data type for `z` output
280
291
* @param x the x value
281
292
* @param y the y value
282
- * @param T data type for ` RightShift` output and operands
293
+ * @param <T> data type for `RightShift` output and operands
283
294
* @return a new instance of RightShift
284
295
* @see org.tensorflow.op.BitwiseOps.rightShift
285
296
*/
0 commit comments