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

Function quick_execute

tensorflow/python/eager/execute.py:33–78  ·  view source on GitHub ↗

Execute a TensorFlow operation. Args: op_name: Name of the TensorFlow operation (see REGISTER_OP in C++ code) to execute. num_outputs: The number of outputs of the operation to fetch. (Explicitly provided instead of being inferred for performance re

(op_name, num_outputs, inputs, attrs, ctx, name=None)

Source from the content-addressed store, hash-verified

31
32
33def quick_execute(op_name, num_outputs, inputs, attrs, ctx, name=None):
34 """Execute a TensorFlow operation.
35
36 Args:
37 op_name: Name of the TensorFlow operation (see REGISTER_OP in C++ code) to
38 execute.
39 num_outputs: The number of outputs of the operation to fetch.
40 (Explicitly provided instead of being inferred for performance
41 reasons).
42 inputs: A list of inputs to the operation. Each entry should be a Tensor, or
43 a value which can be passed to the Tensor constructor to create one.
44 attrs: A tuple with alternating string attr names and attr values for this
45 operation.
46 ctx: The value of context.context().
47 name: Customized name for the operation.
48
49 Returns:
50 List of output Tensor objects. The list is empty if there are no outputs
51
52 Raises:
53 An exception on error.
54 """
55 device_name = ctx.device_name
56 # pylint: disable=protected-access
57 try:
58 ctx.ensure_initialized()
59 tensors = pywrap_tensorflow.TFE_Py_Execute(ctx._handle, device_name,
60 op_name, inputs, attrs,
61 num_outputs)
62 except core._NotOkStatusException as e:
63 if name is not None:
64 message = e.message + " name: " + name
65 else:
66 message = e.message
67 six.raise_from(core._status_to_exception(e.code, message), None)
68 except TypeError as e:
69 keras_symbolic_tensors = [
70 x for x in inputs if ops._is_keras_symbolic_tensor(x)
71 ]
72 if keras_symbolic_tensors:
73 raise core._SymbolicException(
74 "Inputs to eager execution function cannot be Keras symbolic "
75 "tensors, but found {}".format(keras_symbolic_tensors))
76 raise e
77 # pylint: enable=protected-access
78 return tensors
79
80
81def execute_with_cancellation(op_name,

Callers 1

execute_with_callbacksFunction · 0.85

Calls 2

ensure_initializedMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected