From: Jeremy Lau Date: Sat, 14 Apr 2018 00:36:00 +0000 (-0700) Subject: VLOG(1) all OutOfRange CtxFailures, and LOG(WARNING) all other CtxFailures. This X-Git-Tag: upstream/v1.9.0_rc1~287^2~1^2~69 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a4b408543dd3b882131f522359bcb547c7972e4f;p=platform%2Fupstream%2Ftensorflow.git VLOG(1) all OutOfRange CtxFailures, and LOG(WARNING) all other CtxFailures. This unifies the logging behavior of the OP_REQUIRES and OP_REQUIRES_OK macros. PiperOrigin-RevId: 192848921 --- diff --git a/tensorflow/core/framework/op_kernel.cc b/tensorflow/core/framework/op_kernel.cc index 0517100..ca91d68 100644 --- a/tensorflow/core/framework/op_kernel.cc +++ b/tensorflow/core/framework/op_kernel.cc @@ -1273,51 +1273,59 @@ const Eigen::SyclDevice& OpKernelContext::eigen_device() const { } #endif +namespace { +template +void CtxFailureInternal(OpKernelT* op_kernel, const char* file, int line, + const Status& s) { + const string logging_prefix = + file == nullptr ? "CtxFailure: " + : strings::StrCat("CtxFailure at ", io::Basename(file), + ":", line, ": "); + + if (errors::IsOutOfRange(s)) { + // VLOG OutOfRange errors. Dataset ops create OutOfRange errors when they + // reach end-of-sequence. + VLOG(1) << logging_prefix << s; + } else { + LOG(WARNING) << logging_prefix << s; + } + op_kernel->SetStatus(s); +} +} // anonymous namespace + void OpKernelConstruction::CtxFailure(const Status& s) { - VLOG(1) << s; - SetStatus(s); + CtxFailureInternal(this, nullptr, 0, s); } void OpKernelConstruction::CtxFailureWithWarning(const Status& s) { - LOG(WARNING) << s; - SetStatus(s); + CtxFailureInternal(this, nullptr, 0, s); } void OpKernelConstruction::CtxFailure(const char* file, int line, const Status& s) { - VLOG(1) << "OP_REQUIRES failed at " << io::Basename(file) << ":" << line - << " : " << s; - SetStatus(s); + CtxFailureInternal(this, file, line, s); } void OpKernelConstruction::CtxFailureWithWarning(const char* file, int line, const Status& s) { - LOG(WARNING) << "OP_REQUIRES failed at " << io::Basename(file) << ":" << line - << " : " << s; - SetStatus(s); + CtxFailureInternal(this, file, line, s); } void OpKernelContext::CtxFailure(const Status& s) { - VLOG(1) << s; - SetStatus(s); + CtxFailureInternal(this, nullptr, 0, s); } void OpKernelContext::CtxFailureWithWarning(const Status& s) { - LOG(WARNING) << s; - SetStatus(s); + CtxFailureInternal(this, nullptr, 0, s); } void OpKernelContext::CtxFailure(const char* file, int line, const Status& s) { - VLOG(1) << "OP_REQUIRES failed at " << io::Basename(file) << ":" << line - << " : " << s; - SetStatus(s); + CtxFailureInternal(this, file, line, s); } void OpKernelContext::CtxFailureWithWarning(const char* file, int line, const Status& s) { - LOG(WARNING) << "OP_REQUIRES failed at " << io::Basename(file) << ":" << line - << " : " << s; - SetStatus(s); + CtxFailureInternal(this, file, line, s); } } // namespace tensorflow