Add call in eager mode for error logging.

PiperOrigin-RevId: 515437167
This commit is contained in:
A. Unique TensorFlower 2023-03-09 14:12:18 -08:00 committed by TensorFlower Gardener
parent b01db583ac
commit a35eb03c6d
2 changed files with 14 additions and 3 deletions

View File

@ -16,6 +16,7 @@
from tensorflow.python import pywrap_tfe
from tensorflow.python.framework import errors
from tensorflow.python.platform import tf_logging as logging
# Trace of execution and memory usage.
_active_trace = None
@ -24,10 +25,15 @@ _active_trace = None
def _status_to_exception(status):
try:
error_class = errors.exception_type_from_error_code(status.code)
return error_class(None, None, status.message, status.payloads)
e = error_class(None, None, status.message, status.payloads)
logging.error_log("%s: %s" % (e.__class__.__name__, e))
return e
except KeyError:
return errors.UnknownError(None, None, status.message, status.code,
status.payloads)
e = errors.UnknownError(
None, None, status.message, status.code, status.payloads
)
logging.error_log("%s: %s" % (e.__class__.__name__, e))
return e
class _NotOkStatusException(Exception):

View File

@ -364,3 +364,8 @@ tf_export(v1=['logging.ERROR']).export_constant(__name__, 'ERROR')
tf_export(v1=['logging.FATAL']).export_constant(__name__, 'FATAL')
tf_export(v1=['logging.INFO']).export_constant(__name__, 'INFO')
tf_export(v1=['logging.WARN']).export_constant(__name__, 'WARN')
def error_log(error_msg, level=ERROR):
"""Empty helper method."""
del error_msg, level