Added a helper function for handling _NotOkStatusException
PiperOrigin-RevId: 267579737
This commit is contained in:
parent
dfc3eb8936
commit
1605d17783
tensorflow/python/framework
@ -6675,3 +6675,10 @@ def to_raw_op(f):
|
||||
f = types.FunctionType(f.__code__, f.__globals__, f.__name__, f.__defaults__,
|
||||
f.__closure__)
|
||||
return kwarg_only(do_not_generate_docs(f))
|
||||
|
||||
|
||||
def raise_from_not_ok_status(e, name):
|
||||
message = e.message + (" name: " + name if name is not None else "")
|
||||
# pylint: disable=protected-access
|
||||
six.raise_from(core._status_to_exception(e.code, message), None)
|
||||
# pylint: enable=protected-access
|
||||
|
@ -819,14 +819,8 @@ void GenEagerPythonOp::AddEagerFastPathExecute() {
|
||||
// _NotOkStatusException.
|
||||
strings::StrAppend(&result_, " ",
|
||||
"except _core._NotOkStatusException as e:\n");
|
||||
strings::StrAppend(&result_, " ", "if name is not None:\n");
|
||||
strings::StrAppend(&result_, " ",
|
||||
"message = e.message + \" name: \" + name\n");
|
||||
strings::StrAppend(&result_, " ", "else:\n");
|
||||
strings::StrAppend(&result_, " ", "message = e.message\n");
|
||||
strings::StrAppend(
|
||||
&result_, " ",
|
||||
"_six.raise_from(_core._status_to_exception(e.code, message), None)\n");
|
||||
strings::StrAppend(&result_, " ",
|
||||
"_ops.raise_from_not_ok_status(e, name)\n");
|
||||
}
|
||||
|
||||
void GenEagerPythonOp::AddEagerInferredAttrs(const string& indentation) {
|
||||
@ -1000,7 +994,6 @@ This file is MACHINE GENERATED! Do not edit.
|
||||
strings::StrAppend(&result, R"("""
|
||||
|
||||
import collections
|
||||
import six as _six
|
||||
|
||||
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
|
||||
from tensorflow.python.eager import context as _context
|
||||
@ -1018,7 +1011,6 @@ from tensorflow.python.util.deprecation import deprecated_endpoints
|
||||
from tensorflow.python.util import dispatch as _dispatch
|
||||
from tensorflow.python.util.tf_export import tf_export
|
||||
|
||||
|
||||
)");
|
||||
|
||||
// We'll make a copy of ops that filters out descriptions.
|
||||
|
Loading…
Reference in New Issue
Block a user