MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _call_flat

Method _call_flat

tensorflow/python/eager/function.py:1143–1237  ·  view source on GitHub ↗

Executes the wrapped function. Args: args: a list of Tensors or Variables. Any CompositeTensors should be expanded before calling this method. captured_inputs: the captured inputs that are also part of the input args to the actual execution. By default, it should be

(self, args, captured_inputs, cancellation_manager=None)

Source from the content-addressed store, hash-verified

1141 self.captured_inputs)
1142
1143 def _call_flat(self, args, captured_inputs, cancellation_manager=None):
1144 """Executes the wrapped function.
1145
1146 Args:
1147 args: a list of Tensors or Variables. Any CompositeTensors should be
1148 expanded before calling this method.
1149 captured_inputs: the captured inputs that are also part of the input args
1150 to the actual execution. By default, it should be self._captured_inputs.
1151 cancellation_manager: (Optional.) A `CancellationManager` that can be
1152 used to cancel function invocation.
1153
1154 Returns:
1155 The result of applying the TF function to `args`.
1156
1157 Raises:
1158 ValueError: If `args` contains anything other than Tensors or Variables.
1159 """
1160 args = list(args)
1161 ctx = context.context()
1162 executing_eagerly = ctx.executing_eagerly()
1163
1164 # Copy saveable status of function's graph to current FuncGraph.
1165 default_graph = ops.get_default_graph()
1166 if default_graph.building_function and not self._func_graph.saveable:
1167 default_graph.mark_as_unsaveable(self._func_graph.saving_errors)
1168
1169 if any(isinstance(a, composite_tensor.CompositeTensor) for a in args):
1170 raise AssertionError("Expected all args to be Tensors or Variables; "
1171 "but got CompositeTensor: %r" % args)
1172
1173 if (tape.could_possibly_record() or
1174 hasattr(ops.get_default_graph(), "watch_variable")):
1175 for v in self._func_graph.variables:
1176 resource_variable_ops.variable_accessed(v)
1177
1178 tensor_inputs = []
1179 variables_used = object_identity.ObjectIdentitySet([])
1180 for i, arg in enumerate(args):
1181 if isinstance(arg, resource_variable_ops.BaseResourceVariable):
1182 # We can pass a variable more than once, and in this case we need to
1183 # pass its handle only once.
1184 if arg.handle in variables_used:
1185 continue
1186 resource_variable_ops.variable_accessed(arg)
1187 tensor_inputs.append(arg.handle)
1188 variables_used.add(arg.handle)
1189 elif isinstance(arg, ops.Tensor):
1190 tensor_inputs.append(arg)
1191 if not executing_eagerly:
1192 # If we're graph building, shape inference is on. We check for input
1193 # compatibility up front to avoid hard to debug incompatibilities
1194 # later.
1195 graph_input_shape = tensor_shape.TensorShape(
1196 self._func_graph.inputs[i].shape)
1197 if not graph_input_shape.is_compatible_with(arg.shape):
1198 if self._arg_keywords:
1199 arg_name = "'{}'".format(self._arg_keywords[i])
1200 else:

Callers 4

_call_implMethod · 0.95
_filtered_callMethod · 0.95

Calls 14

addMethod · 0.95
is_compatible_withMethod · 0.95
_build_call_outputsMethod · 0.95
anyFunction · 0.85
executing_eagerlyMethod · 0.80
mark_as_unsaveableMethod · 0.80
gradient_override_mapMethod · 0.80
contextMethod · 0.45
appendMethod · 0.45
formatMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected