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

101 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 

24def recv(tensor_type, tensor_name, send_device, send_device_incarnation, recv_device, client_terminated=False, name=None): 

25 r"""Receives the named tensor from send_device on recv_device. 

26 

27 Args: 

28 tensor_type: A `tf.DType`. 

29 tensor_name: A `string`. The name of the tensor to receive. 

30 send_device: A `string`. The name of the device sending the tensor. 

31 send_device_incarnation: An `int`. The current incarnation of send_device. 

32 recv_device: A `string`. The name of the device receiving the tensor. 

33 client_terminated: An optional `bool`. Defaults to `False`. 

34 If set to true, this indicates that the node was added 

35 to the graph as a result of a client-side feed or fetch of Tensor data, 

36 in which case the corresponding send or recv is expected to be managed 

37 locally by the caller. 

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

39 

40 Returns: 

41 A `Tensor` of type `tensor_type`. 

42 """ 

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

44 tld = _ctx._thread_local_data 

45 if tld.is_eager: 

46 try: 

47 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

48 _ctx, "Recv", name, "tensor_type", tensor_type, "tensor_name", 

49 tensor_name, "send_device", send_device, "send_device_incarnation", 

50 send_device_incarnation, "recv_device", recv_device, 

51 "client_terminated", client_terminated) 

52 return _result 

53 except _core._NotOkStatusException as e: 

54 _ops.raise_from_not_ok_status(e, name) 

55 except _core._FallbackException: 

56 pass 

57 try: 

58 return recv_eager_fallback( 

59 tensor_type=tensor_type, tensor_name=tensor_name, 

60 send_device=send_device, 

61 send_device_incarnation=send_device_incarnation, 

62 recv_device=recv_device, client_terminated=client_terminated, 

63 name=name, ctx=_ctx) 

64 except _core._SymbolicException: 

65 pass # Add nodes to the TensorFlow graph. 

66 # Add nodes to the TensorFlow graph. 

67 tensor_type = _execute.make_type(tensor_type, "tensor_type") 

68 tensor_name = _execute.make_str(tensor_name, "tensor_name") 

69 send_device = _execute.make_str(send_device, "send_device") 

70 send_device_incarnation = _execute.make_int(send_device_incarnation, "send_device_incarnation") 

71 recv_device = _execute.make_str(recv_device, "recv_device") 

72 if client_terminated is None: 

73 client_terminated = False 

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

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

76 "Recv", tensor_type=tensor_type, tensor_name=tensor_name, 

77 send_device=send_device, 

78 send_device_incarnation=send_device_incarnation, 

79 recv_device=recv_device, client_terminated=client_terminated, 

80 name=name) 

81 _result = _outputs[:] 

82 if _execute.must_record_gradient(): 

83 _attrs = ("tensor_type", _op._get_attr_type("tensor_type"), "tensor_name", 

84 _op.get_attr("tensor_name"), "send_device", 

85 _op.get_attr("send_device"), "send_device_incarnation", 

86 _op._get_attr_int("send_device_incarnation"), "recv_device", 

87 _op.get_attr("recv_device"), "client_terminated", 

88 _op._get_attr_bool("client_terminated")) 

89 _inputs_flat = _op.inputs 

90 _execute.record_gradient( 

91 "Recv", _inputs_flat, _attrs, _result) 

92 _result, = _result 

93 return _result 

94 

95Recv = tf_export("raw_ops.Recv")(_ops.to_raw_op(recv)) 

96 

97 

98def recv_eager_fallback(tensor_type, tensor_name, send_device, send_device_incarnation, recv_device, client_terminated, name, ctx): 

99 tensor_type = _execute.make_type(tensor_type, "tensor_type") 

100 tensor_name = _execute.make_str(tensor_name, "tensor_name") 

101 send_device = _execute.make_str(send_device, "send_device") 

102 send_device_incarnation = _execute.make_int(send_device_incarnation, "send_device_incarnation") 

103 recv_device = _execute.make_str(recv_device, "recv_device") 

104 if client_terminated is None: 

105 client_terminated = False 

106 client_terminated = _execute.make_bool(client_terminated, "client_terminated") 

107 _inputs_flat = [] 

108 _attrs = ("tensor_type", tensor_type, "tensor_name", tensor_name, 

109 "send_device", send_device, "send_device_incarnation", 

110 send_device_incarnation, "recv_device", recv_device, "client_terminated", 

111 client_terminated) 

112 _result = _execute.execute(b"Recv", 1, inputs=_inputs_flat, attrs=_attrs, 

113 ctx=ctx, name=name) 

114 if _execute.must_record_gradient(): 

115 _execute.record_gradient( 

116 "Recv", _inputs_flat, _attrs, _result) 

117 _result, = _result 

118 return _result 

119 

120 

121def send(tensor, tensor_name, send_device, send_device_incarnation, recv_device, client_terminated=False, name=None): 

122 r"""Sends the named tensor from send_device to recv_device. 

123 

124 Args: 

125 tensor: A `Tensor`. The tensor to send. 

126 tensor_name: A `string`. The name of the tensor to send. 

127 send_device: A `string`. The name of the device sending the tensor. 

128 send_device_incarnation: An `int`. The current incarnation of send_device. 

129 recv_device: A `string`. The name of the device receiving the tensor. 

130 client_terminated: An optional `bool`. Defaults to `False`. 

131 If set to true, this indicates that the node was added 

132 to the graph as a result of a client-side feed or fetch of Tensor data, 

133 in which case the corresponding send or recv is expected to be managed 

134 locally by the caller. 

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

136 

137 Returns: 

138 The created Operation. 

139 """ 

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

141 tld = _ctx._thread_local_data 

142 if tld.is_eager: 

143 try: 

144 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

145 _ctx, "Send", name, tensor, "tensor_name", tensor_name, "send_device", 

146 send_device, "send_device_incarnation", send_device_incarnation, 

147 "recv_device", recv_device, "client_terminated", client_terminated) 

148 return _result 

149 except _core._NotOkStatusException as e: 

150 _ops.raise_from_not_ok_status(e, name) 

151 except _core._FallbackException: 

152 pass 

153 try: 

154 return send_eager_fallback( 

155 tensor, tensor_name=tensor_name, send_device=send_device, 

156 send_device_incarnation=send_device_incarnation, 

157 recv_device=recv_device, client_terminated=client_terminated, 

158 name=name, ctx=_ctx) 

159 except _core._SymbolicException: 

160 pass # Add nodes to the TensorFlow graph. 

161 # Add nodes to the TensorFlow graph. 

162 tensor_name = _execute.make_str(tensor_name, "tensor_name") 

163 send_device = _execute.make_str(send_device, "send_device") 

164 send_device_incarnation = _execute.make_int(send_device_incarnation, "send_device_incarnation") 

165 recv_device = _execute.make_str(recv_device, "recv_device") 

166 if client_terminated is None: 

167 client_terminated = False 

168 client_terminated = _execute.make_bool(client_terminated, "client_terminated") 

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

170 "Send", tensor=tensor, tensor_name=tensor_name, 

171 send_device=send_device, 

172 send_device_incarnation=send_device_incarnation, 

173 recv_device=recv_device, client_terminated=client_terminated, 

174 name=name) 

175 return _op 

176Send = tf_export("raw_ops.Send")(_ops.to_raw_op(send)) 

177 

178 

179def send_eager_fallback(tensor, tensor_name, send_device, send_device_incarnation, recv_device, client_terminated, name, ctx): 

180 tensor_name = _execute.make_str(tensor_name, "tensor_name") 

181 send_device = _execute.make_str(send_device, "send_device") 

182 send_device_incarnation = _execute.make_int(send_device_incarnation, "send_device_incarnation") 

183 recv_device = _execute.make_str(recv_device, "recv_device") 

184 if client_terminated is None: 

185 client_terminated = False 

186 client_terminated = _execute.make_bool(client_terminated, "client_terminated") 

187 _attr_T, (tensor,) = _execute.args_to_matching_eager([tensor], ctx, []) 

188 _inputs_flat = [tensor] 

189 _attrs = ("T", _attr_T, "tensor_name", tensor_name, "send_device", 

190 send_device, "send_device_incarnation", send_device_incarnation, 

191 "recv_device", recv_device, "client_terminated", client_terminated) 

192 _result = _execute.execute(b"Send", 0, inputs=_inputs_flat, attrs=_attrs, 

193 ctx=ctx, name=name) 

194 _result = None 

195 return _result 

196