Use C API to implement Operation.name property
This name property is used in many existing tests including those that already run with C API enabled (math_ops_test, framework_ops_test, session_test, session_partial_run_test, math_ops_test_gpu, etc). PiperOrigin-RevId: 159645767
This commit is contained in:
parent
26239c706f
commit
980d3f2be6
@ -63,6 +63,11 @@ tensorflow::ImportNumpy();
|
||||
// Constants used by TensorHandle (get_session_handle).
|
||||
%constant const char* TENSOR_HANDLE_KEY = tensorflow::SessionState::kTensorHandleResourceTypeName;
|
||||
|
||||
// Convert TF_OperationName output to unicode python string
|
||||
%typemap(out) const char* TF_OperationName {
|
||||
$result = PyUnicode_FromString($1);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// BEGIN TYPEMAPS FOR tensorflow::TF_Run_wrapper()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1350,7 +1350,13 @@ class Operation(object):
|
||||
@property
|
||||
def name(self):
|
||||
"""The full name of this operation."""
|
||||
return self._node_def.name
|
||||
if _USE_C_API:
|
||||
# TODO(iga): Remove this assert after converting to C API by default.
|
||||
# Just being a bit paranoid here.
|
||||
assert self._node_def.name == c_api.TF_OperationName(self._c_op)
|
||||
return c_api.TF_OperationName(self._c_op)
|
||||
else:
|
||||
return self._node_def.name
|
||||
|
||||
@property
|
||||
def _id(self):
|
||||
|
Loading…
Reference in New Issue
Block a user