Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/tensorflow/python/ops/gen_count_ops.py: 16%

167 statements  

« prev     ^ index     » next       coverage.py v7.4.0, created at 2024-01-03 07:57 +0000

1"""Python wrappers around TensorFlow ops. 

2 

3This file is MACHINE GENERATED! Do not edit. 

4""" 

5 

6import collections 

7 

8from tensorflow.python import pywrap_tfe as pywrap_tfe 

9from tensorflow.python.eager import context as _context 

10from tensorflow.python.eager import core as _core 

11from tensorflow.python.eager import execute as _execute 

12from tensorflow.python.framework import dtypes as _dtypes 

13from tensorflow.security.fuzzing.py import annotation_types as _atypes 

14 

15from tensorflow.python.framework import op_def_registry as _op_def_registry 

16from tensorflow.python.framework import ops as _ops 

17from tensorflow.python.framework import op_def_library as _op_def_library 

18from tensorflow.python.util.deprecation import deprecated_endpoints 

19from tensorflow.python.util import dispatch as _dispatch 

20from tensorflow.python.util.tf_export import tf_export 

21 

22from typing import TypeVar 

23_DenseCountSparseOutputOutput = collections.namedtuple( 

24 "DenseCountSparseOutput", 

25 ["output_indices", "output_values", "output_dense_shape"]) 

26 

27 

28def dense_count_sparse_output(values, weights, binary_output, minlength=-1, maxlength=-1, name=None): 

29 r"""Performs sparse-output bin counting for a tf.tensor input. 

30 

31 Counts the number of times each value occurs in the input. 

32 

33 Args: 

34 values: A `Tensor`. Must be one of the following types: `int32`, `int64`. 

35 Tensor containing data to count. 

36 weights: A `Tensor`. Must be one of the following types: `int32`, `int64`, `float32`, `float64`. 

37 A Tensor of the same shape as indices containing per-index weight values. May 

38 also be the empty tensor if no weights are used. 

39 binary_output: A `bool`. 

40 Whether to output the number of occurrences of each value or 1. 

41 minlength: An optional `int` that is `>= -1`. Defaults to `-1`. 

42 Minimum value to count. Can be set to -1 for no minimum. 

43 maxlength: An optional `int` that is `>= -1`. Defaults to `-1`. 

44 Maximum value to count. Can be set to -1 for no maximum. 

45 name: A name for the operation (optional). 

46 

47 Returns: 

48 A tuple of `Tensor` objects (output_indices, output_values, output_dense_shape). 

49 

50 output_indices: A `Tensor` of type `int64`. 

51 output_values: A `Tensor`. Has the same type as `weights`. 

52 output_dense_shape: A `Tensor` of type `int64`. 

53 """ 

54 _ctx = _context._context or _context.context() 

55 tld = _ctx._thread_local_data 

56 if tld.is_eager: 

57 try: 

58 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

59 _ctx, "DenseCountSparseOutput", name, values, weights, "minlength", 

60 minlength, "maxlength", maxlength, "binary_output", binary_output) 

61 _result = _DenseCountSparseOutputOutput._make(_result) 

62 return _result 

63 except _core._NotOkStatusException as e: 

64 _ops.raise_from_not_ok_status(e, name) 

65 except _core._FallbackException: 

66 pass 

67 try: 

68 return dense_count_sparse_output_eager_fallback( 

69 values, weights, minlength=minlength, maxlength=maxlength, 

70 binary_output=binary_output, name=name, ctx=_ctx) 

71 except _core._SymbolicException: 

72 pass # Add nodes to the TensorFlow graph. 

73 # Add nodes to the TensorFlow graph. 

74 binary_output = _execute.make_bool(binary_output, "binary_output") 

75 if minlength is None: 

76 minlength = -1 

77 minlength = _execute.make_int(minlength, "minlength") 

78 if maxlength is None: 

79 maxlength = -1 

80 maxlength = _execute.make_int(maxlength, "maxlength") 

81 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

82 "DenseCountSparseOutput", values=values, weights=weights, 

83 binary_output=binary_output, 

84 minlength=minlength, maxlength=maxlength, 

85 name=name) 

86 _result = _outputs[:] 

87 if _execute.must_record_gradient(): 

88 _attrs = ("T", _op._get_attr_type("T"), "minlength", 

89 _op._get_attr_int("minlength"), "maxlength", 

90 _op._get_attr_int("maxlength"), "binary_output", 

91 _op._get_attr_bool("binary_output"), "output_type", 

92 _op._get_attr_type("output_type")) 

93 _inputs_flat = _op.inputs 

94 _execute.record_gradient( 

95 "DenseCountSparseOutput", _inputs_flat, _attrs, _result) 

96 _result = _DenseCountSparseOutputOutput._make(_result) 

97 return _result 

98 

99DenseCountSparseOutput = tf_export("raw_ops.DenseCountSparseOutput")(_ops.to_raw_op(dense_count_sparse_output)) 

100 

101 

102def dense_count_sparse_output_eager_fallback(values, weights, binary_output, minlength, maxlength, name, ctx): 

103 binary_output = _execute.make_bool(binary_output, "binary_output") 

104 if minlength is None: 

105 minlength = -1 

106 minlength = _execute.make_int(minlength, "minlength") 

107 if maxlength is None: 

108 maxlength = -1 

109 maxlength = _execute.make_int(maxlength, "maxlength") 

110 _attr_T, (values,) = _execute.args_to_matching_eager([values], ctx, [_dtypes.int32, _dtypes.int64, ]) 

111 _attr_output_type, (weights,) = _execute.args_to_matching_eager([weights], ctx, [_dtypes.int32, _dtypes.int64, _dtypes.float32, _dtypes.float64, ]) 

112 _inputs_flat = [values, weights] 

113 _attrs = ("T", _attr_T, "minlength", minlength, "maxlength", maxlength, 

114 "binary_output", binary_output, "output_type", _attr_output_type) 

115 _result = _execute.execute(b"DenseCountSparseOutput", 3, 

116 inputs=_inputs_flat, attrs=_attrs, ctx=ctx, 

117 name=name) 

118 if _execute.must_record_gradient(): 

119 _execute.record_gradient( 

120 "DenseCountSparseOutput", _inputs_flat, _attrs, _result) 

121 _result = _DenseCountSparseOutputOutput._make(_result) 

122 return _result 

123 

124_RaggedCountSparseOutputOutput = collections.namedtuple( 

125 "RaggedCountSparseOutput", 

126 ["output_indices", "output_values", "output_dense_shape"]) 

127 

128 

129def ragged_count_sparse_output(splits, values, weights, binary_output, minlength=-1, maxlength=-1, name=None): 

130 r"""Performs sparse-output bin counting for a ragged tensor input. 

131 

132 Counts the number of times each value occurs in the input. 

133 

134 Args: 

135 splits: A `Tensor` of type `int64`. 

136 Tensor containing the row splits of the ragged tensor to count. 

137 values: A `Tensor`. Must be one of the following types: `int32`, `int64`. 

138 Tensor containing values of the sparse tensor to count. 

139 weights: A `Tensor`. Must be one of the following types: `int32`, `int64`, `float32`, `float64`. 

140 A Tensor of the same shape as indices containing per-index weight values. 

141 May also be the empty tensor if no weights are used. 

142 binary_output: A `bool`. 

143 Whether to output the number of occurrences of each value or 1. 

144 minlength: An optional `int` that is `>= -1`. Defaults to `-1`. 

145 Minimum value to count. Can be set to -1 for no minimum. 

146 maxlength: An optional `int` that is `>= -1`. Defaults to `-1`. 

147 Maximum value to count. Can be set to -1 for no maximum. 

148 name: A name for the operation (optional). 

149 

150 Returns: 

151 A tuple of `Tensor` objects (output_indices, output_values, output_dense_shape). 

152 

153 output_indices: A `Tensor` of type `int64`. 

154 output_values: A `Tensor`. Has the same type as `weights`. 

155 output_dense_shape: A `Tensor` of type `int64`. 

156 """ 

157 _ctx = _context._context or _context.context() 

158 tld = _ctx._thread_local_data 

159 if tld.is_eager: 

160 try: 

161 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

162 _ctx, "RaggedCountSparseOutput", name, splits, values, weights, 

163 "minlength", minlength, "maxlength", maxlength, "binary_output", 

164 binary_output) 

165 _result = _RaggedCountSparseOutputOutput._make(_result) 

166 return _result 

167 except _core._NotOkStatusException as e: 

168 _ops.raise_from_not_ok_status(e, name) 

169 except _core._FallbackException: 

170 pass 

171 try: 

172 return ragged_count_sparse_output_eager_fallback( 

173 splits, values, weights, minlength=minlength, maxlength=maxlength, 

174 binary_output=binary_output, name=name, ctx=_ctx) 

175 except _core._SymbolicException: 

176 pass # Add nodes to the TensorFlow graph. 

177 # Add nodes to the TensorFlow graph. 

178 binary_output = _execute.make_bool(binary_output, "binary_output") 

179 if minlength is None: 

180 minlength = -1 

181 minlength = _execute.make_int(minlength, "minlength") 

182 if maxlength is None: 

183 maxlength = -1 

184 maxlength = _execute.make_int(maxlength, "maxlength") 

185 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

186 "RaggedCountSparseOutput", splits=splits, values=values, 

187 weights=weights, 

188 binary_output=binary_output, 

189 minlength=minlength, maxlength=maxlength, 

190 name=name) 

191 _result = _outputs[:] 

192 if _execute.must_record_gradient(): 

193 _attrs = ("T", _op._get_attr_type("T"), "minlength", 

194 _op._get_attr_int("minlength"), "maxlength", 

195 _op._get_attr_int("maxlength"), "binary_output", 

196 _op._get_attr_bool("binary_output"), "output_type", 

197 _op._get_attr_type("output_type")) 

198 _inputs_flat = _op.inputs 

199 _execute.record_gradient( 

200 "RaggedCountSparseOutput", _inputs_flat, _attrs, _result) 

201 _result = _RaggedCountSparseOutputOutput._make(_result) 

202 return _result 

203 

204RaggedCountSparseOutput = tf_export("raw_ops.RaggedCountSparseOutput")(_ops.to_raw_op(ragged_count_sparse_output)) 

205 

206 

207def ragged_count_sparse_output_eager_fallback(splits, values, weights, binary_output, minlength, maxlength, name, ctx): 

208 binary_output = _execute.make_bool(binary_output, "binary_output") 

209 if minlength is None: 

210 minlength = -1 

211 minlength = _execute.make_int(minlength, "minlength") 

212 if maxlength is None: 

213 maxlength = -1 

214 maxlength = _execute.make_int(maxlength, "maxlength") 

215 _attr_T, (values,) = _execute.args_to_matching_eager([values], ctx, [_dtypes.int32, _dtypes.int64, ]) 

216 _attr_output_type, (weights,) = _execute.args_to_matching_eager([weights], ctx, [_dtypes.int32, _dtypes.int64, _dtypes.float32, _dtypes.float64, ]) 

217 splits = _ops.convert_to_tensor(splits, _dtypes.int64) 

218 _inputs_flat = [splits, values, weights] 

219 _attrs = ("T", _attr_T, "minlength", minlength, "maxlength", maxlength, 

220 "binary_output", binary_output, "output_type", _attr_output_type) 

221 _result = _execute.execute(b"RaggedCountSparseOutput", 3, 

222 inputs=_inputs_flat, attrs=_attrs, ctx=ctx, 

223 name=name) 

224 if _execute.must_record_gradient(): 

225 _execute.record_gradient( 

226 "RaggedCountSparseOutput", _inputs_flat, _attrs, _result) 

227 _result = _RaggedCountSparseOutputOutput._make(_result) 

228 return _result 

229 

230_SparseCountSparseOutputOutput = collections.namedtuple( 

231 "SparseCountSparseOutput", 

232 ["output_indices", "output_values", "output_dense_shape"]) 

233 

234 

235def sparse_count_sparse_output(indices, values, dense_shape, weights, binary_output, minlength=-1, maxlength=-1, name=None): 

236 r"""Performs sparse-output bin counting for a sparse tensor input. 

237 

238 Counts the number of times each value occurs in the input. 

239 

240 Args: 

241 indices: A `Tensor` of type `int64`. 

242 Tensor containing the indices of the sparse tensor to count. 

243 values: A `Tensor`. Must be one of the following types: `int32`, `int64`. 

244 Tensor containing values of the sparse tensor to count. 

245 dense_shape: A `Tensor` of type `int64`. 

246 Tensor containing the dense shape of the sparse tensor to count. 

247 weights: A `Tensor`. Must be one of the following types: `int32`, `int64`, `float32`, `float64`. 

248 A Tensor of the same shape as indices containing per-index weight values. 

249 May also be the empty tensor if no weights are used. 

250 binary_output: A `bool`. 

251 Whether to output the number of occurrences of each value or 1. 

252 minlength: An optional `int` that is `>= -1`. Defaults to `-1`. 

253 Minimum value to count. Can be set to -1 for no minimum. 

254 maxlength: An optional `int` that is `>= -1`. Defaults to `-1`. 

255 Maximum value to count. Can be set to -1 for no maximum. 

256 name: A name for the operation (optional). 

257 

258 Returns: 

259 A tuple of `Tensor` objects (output_indices, output_values, output_dense_shape). 

260 

261 output_indices: A `Tensor` of type `int64`. 

262 output_values: A `Tensor`. Has the same type as `weights`. 

263 output_dense_shape: A `Tensor` of type `int64`. 

264 """ 

265 _ctx = _context._context or _context.context() 

266 tld = _ctx._thread_local_data 

267 if tld.is_eager: 

268 try: 

269 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

270 _ctx, "SparseCountSparseOutput", name, indices, values, dense_shape, 

271 weights, "minlength", minlength, "maxlength", maxlength, 

272 "binary_output", binary_output) 

273 _result = _SparseCountSparseOutputOutput._make(_result) 

274 return _result 

275 except _core._NotOkStatusException as e: 

276 _ops.raise_from_not_ok_status(e, name) 

277 except _core._FallbackException: 

278 pass 

279 try: 

280 return sparse_count_sparse_output_eager_fallback( 

281 indices, values, dense_shape, weights, minlength=minlength, 

282 maxlength=maxlength, binary_output=binary_output, name=name, 

283 ctx=_ctx) 

284 except _core._SymbolicException: 

285 pass # Add nodes to the TensorFlow graph. 

286 # Add nodes to the TensorFlow graph. 

287 binary_output = _execute.make_bool(binary_output, "binary_output") 

288 if minlength is None: 

289 minlength = -1 

290 minlength = _execute.make_int(minlength, "minlength") 

291 if maxlength is None: 

292 maxlength = -1 

293 maxlength = _execute.make_int(maxlength, "maxlength") 

294 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

295 "SparseCountSparseOutput", indices=indices, values=values, 

296 dense_shape=dense_shape, weights=weights, 

297 binary_output=binary_output, 

298 minlength=minlength, maxlength=maxlength, 

299 name=name) 

300 _result = _outputs[:] 

301 if _execute.must_record_gradient(): 

302 _attrs = ("T", _op._get_attr_type("T"), "minlength", 

303 _op._get_attr_int("minlength"), "maxlength", 

304 _op._get_attr_int("maxlength"), "binary_output", 

305 _op._get_attr_bool("binary_output"), "output_type", 

306 _op._get_attr_type("output_type")) 

307 _inputs_flat = _op.inputs 

308 _execute.record_gradient( 

309 "SparseCountSparseOutput", _inputs_flat, _attrs, _result) 

310 _result = _SparseCountSparseOutputOutput._make(_result) 

311 return _result 

312 

313SparseCountSparseOutput = tf_export("raw_ops.SparseCountSparseOutput")(_ops.to_raw_op(sparse_count_sparse_output)) 

314 

315 

316def sparse_count_sparse_output_eager_fallback(indices, values, dense_shape, weights, binary_output, minlength, maxlength, name, ctx): 

317 binary_output = _execute.make_bool(binary_output, "binary_output") 

318 if minlength is None: 

319 minlength = -1 

320 minlength = _execute.make_int(minlength, "minlength") 

321 if maxlength is None: 

322 maxlength = -1 

323 maxlength = _execute.make_int(maxlength, "maxlength") 

324 _attr_T, (values,) = _execute.args_to_matching_eager([values], ctx, [_dtypes.int32, _dtypes.int64, ]) 

325 _attr_output_type, (weights,) = _execute.args_to_matching_eager([weights], ctx, [_dtypes.int32, _dtypes.int64, _dtypes.float32, _dtypes.float64, ]) 

326 indices = _ops.convert_to_tensor(indices, _dtypes.int64) 

327 dense_shape = _ops.convert_to_tensor(dense_shape, _dtypes.int64) 

328 _inputs_flat = [indices, values, dense_shape, weights] 

329 _attrs = ("T", _attr_T, "minlength", minlength, "maxlength", maxlength, 

330 "binary_output", binary_output, "output_type", _attr_output_type) 

331 _result = _execute.execute(b"SparseCountSparseOutput", 3, 

332 inputs=_inputs_flat, attrs=_attrs, ctx=ctx, 

333 name=name) 

334 if _execute.must_record_gradient(): 

335 _execute.record_gradient( 

336 "SparseCountSparseOutput", _inputs_flat, _attrs, _result) 

337 _result = _SparseCountSparseOutputOutput._make(_result) 

338 return _result 

339