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

56 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_RaggedRangeOutput = collections.namedtuple( 

24 "RaggedRange", 

25 ["rt_nested_splits", "rt_dense_values"]) 

26 

27 

28def ragged_range(starts, limits, deltas, Tsplits=_dtypes.int64, name=None): 

29 r"""Returns a `RaggedTensor` containing the specified sequences of numbers. 

30 

31  

32 Returns a `RaggedTensor` `result` composed from `rt_dense_values` and 

33 `rt_nested_splits`, such that 

34 `result[i] = range(starts[i], limits[i], deltas[i])`. 

35 

36 ```python 

37 (rt_nested_splits, rt_dense_values) = ragged_range( 

38 starts=[2, 5, 8], limits=[3, 5, 12], deltas=1) 

39 result = tf.ragged.from_row_splits(rt_dense_values, rt_nested_splits) 

40 print(result) 

41 <tf.RaggedTensor [[2], [], [8, 9, 10, 11]] > 

42 ``` 

43 

44 The input tensors `starts`, `limits`, and `deltas` may be scalars or vectors. 

45 The vector inputs must all have the same size. Scalar inputs are broadcast 

46 to match the size of the vector inputs. 

47 

48 Args: 

49 starts: A `Tensor`. Must be one of the following types: `bfloat16`, `float32`, `float64`, `int32`, `int64`. 

50 The starts of each range. 

51 limits: A `Tensor`. Must have the same type as `starts`. 

52 The limits of each range. 

53 deltas: A `Tensor`. Must have the same type as `starts`. 

54 The deltas of each range. 

55 Tsplits: An optional `tf.DType` from: `tf.int32, tf.int64`. Defaults to `tf.int64`. 

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

57 

58 Returns: 

59 A tuple of `Tensor` objects (rt_nested_splits, rt_dense_values). 

60 

61 rt_nested_splits: A `Tensor` of type `Tsplits`. 

62 rt_dense_values: A `Tensor`. Has the same type as `starts`. 

63 """ 

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

65 tld = _ctx._thread_local_data 

66 if tld.is_eager: 

67 try: 

68 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

69 _ctx, "RaggedRange", name, starts, limits, deltas, "Tsplits", Tsplits) 

70 _result = _RaggedRangeOutput._make(_result) 

71 return _result 

72 except _core._NotOkStatusException as e: 

73 _ops.raise_from_not_ok_status(e, name) 

74 except _core._FallbackException: 

75 pass 

76 try: 

77 return ragged_range_eager_fallback( 

78 starts, limits, deltas, Tsplits=Tsplits, name=name, ctx=_ctx) 

79 except _core._SymbolicException: 

80 pass # Add nodes to the TensorFlow graph. 

81 # Add nodes to the TensorFlow graph. 

82 if Tsplits is None: 

83 Tsplits = _dtypes.int64 

84 Tsplits = _execute.make_type(Tsplits, "Tsplits") 

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

86 "RaggedRange", starts=starts, limits=limits, deltas=deltas, 

87 Tsplits=Tsplits, name=name) 

88 _result = _outputs[:] 

89 if _execute.must_record_gradient(): 

90 _attrs = ("T", _op._get_attr_type("T"), "Tsplits", 

91 _op._get_attr_type("Tsplits")) 

92 _inputs_flat = _op.inputs 

93 _execute.record_gradient( 

94 "RaggedRange", _inputs_flat, _attrs, _result) 

95 _result = _RaggedRangeOutput._make(_result) 

96 return _result 

97 

98RaggedRange = tf_export("raw_ops.RaggedRange")(_ops.to_raw_op(ragged_range)) 

99 

100 

101def ragged_range_eager_fallback(starts, limits, deltas, Tsplits, name, ctx): 

102 if Tsplits is None: 

103 Tsplits = _dtypes.int64 

104 Tsplits = _execute.make_type(Tsplits, "Tsplits") 

105 _attr_T, _inputs_T = _execute.args_to_matching_eager([starts, limits, deltas], ctx, [_dtypes.bfloat16, _dtypes.float32, _dtypes.float64, _dtypes.int32, _dtypes.int64, ], _dtypes.int32) 

106 (starts, limits, deltas) = _inputs_T 

107 _inputs_flat = [starts, limits, deltas] 

108 _attrs = ("T", _attr_T, "Tsplits", Tsplits) 

109 _result = _execute.execute(b"RaggedRange", 2, inputs=_inputs_flat, 

110 attrs=_attrs, ctx=ctx, name=name) 

111 if _execute.must_record_gradient(): 

112 _execute.record_gradient( 

113 "RaggedRange", _inputs_flat, _attrs, _result) 

114 _result = _RaggedRangeOutput._make(_result) 

115 return _result 

116