diff --git a/tensorflow/python/eager/pywrap_tfe_src.cc b/tensorflow/python/eager/pywrap_tfe_src.cc index 128fb09d114..4bc327adc33 100644 --- a/tensorflow/python/eager/pywrap_tfe_src.cc +++ b/tensorflow/python/eager/pywrap_tfe_src.cc @@ -3606,16 +3606,18 @@ PyObject* TFE_Py_FastPathExecute_C(PyObject* args) { } TFE_Op* op = GetOp(ctx, op_name, op_exec_info.device_name, status); - tensorflow::unwrap(op)->SetStackTrace(tensorflow::GetStackTrace()); auto cleaner = tensorflow::gtl::MakeCleanup([status, ctx, op] { ReturnStatus(status); ReturnOp(ctx, op); }); + if (MaybeRaiseExceptionFromTFStatus(status, nullptr)) { return nullptr; } + tensorflow::unwrap(op)->SetStackTrace(tensorflow::GetStackTrace()); + const tensorflow::OpDef* op_def = tensorflow::unwrap(op)->OpDef(); if (op_def == nullptr) return nullptr;