From 1390dd68fe5f2f83138e19a86b6699254ad38734 Mon Sep 17 00:00:00 2001 From: Vijay Vasudevan Date: Wed, 17 May 2017 12:18:25 -0700 Subject: [PATCH] When Op Type is not registered, log the hostname of the machine that it is running on in the error message, since the message could be routed back during a failure on a remote binary, and it is hard to tell which machine it came from. Ideally, we'd somehow log the name of the binary running instead, but we don't have a function to get that right now. PiperOrigin-RevId: 156337679 --- tensorflow/core/framework/node_def_builder_test.cc | 5 ++--- tensorflow/core/framework/op.cc | 11 +++++++++-- .../core/framework/shape_inference_testutil_test.cc | 9 +++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tensorflow/core/framework/node_def_builder_test.cc b/tensorflow/core/framework/node_def_builder_test.cc index 196e5e46edb..e836873f667 100644 --- a/tensorflow/core/framework/node_def_builder_test.cc +++ b/tensorflow/core/framework/node_def_builder_test.cc @@ -208,9 +208,8 @@ TEST_F(NodeDefBuilderTest, OpDoesNotExist) { .ControlInput("y") .Attr("foo", 12) .Device("device"); - ExpectFailure( - builder, - "Op type not registered 'Op Does Not Exist' while building NodeDef 'n'"); + ExpectFailures(builder, {"Op type not registered 'Op Does Not Exist'", + "while building NodeDef 'n'"}); } TEST_F(NodeDefBuilderTest, Polymorphic) { diff --git a/tensorflow/core/framework/op.cc b/tensorflow/core/framework/op.cc index 6bff192b1ec..5ddac6b1982 100644 --- a/tensorflow/core/framework/op.cc +++ b/tensorflow/core/framework/op.cc @@ -21,6 +21,7 @@ limitations under the License. #include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/lib/gtl/map_util.h" +#include "tensorflow/core/platform/host_info.h" #include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/mutex.h" #include "tensorflow/core/platform/protobuf.h" @@ -83,7 +84,10 @@ Status OpRegistry::LookUp(const string& op_type_name, first_unregistered = false; } Status status = - errors::NotFound("Op type not registered '", op_type_name, "'"); + errors::NotFound("Op type not registered '", op_type_name, + "' in binary running on ", port::Hostname(), ". ", + "Make sure the Op and Kernel are registered in the " + "binary running in this process."); VLOG(1) << status.ToString(); return status; } @@ -225,7 +229,10 @@ Status OpListOpRegistry::LookUp(const string& op_type_name, auto iter = index_.find(op_type_name); if (iter == index_.end()) { *op_reg_data = nullptr; - return errors::NotFound("Op type not registered '", op_type_name, "'"); + return errors::NotFound("Op type not registered '", op_type_name, + "' in binary running on ", port::Hostname(), ". ", + "Make sure the Op and Kernel are registered in the " + "binary running in this process."); } *op_reg_data = iter->second; return Status::OK(); diff --git a/tensorflow/core/framework/shape_inference_testutil_test.cc b/tensorflow/core/framework/shape_inference_testutil_test.cc index b0af0e5bd91..de14c071b46 100644 --- a/tensorflow/core/framework/shape_inference_testutil_test.cc +++ b/tensorflow/core/framework/shape_inference_testutil_test.cc @@ -93,10 +93,11 @@ TEST(ShapeInferenceTestutilTest, Failures) { RunInferShapes(op, "[1];[2];[1]", "e", fn_copy_input_0)); EXPECT_CONTAINS(RunInferShapes(op, "[1];[2];[1]", "[1];[2]", fn_copy_input_0), "wrong number of outputs"); - EXPECT_EQ("Op type not registered 'NoSuchOp'", - ShapeInferenceTestutil::InferShapes( - ShapeInferenceTestOp("NoSuchOp"), "", "") - .error_message()); + auto error_message = ShapeInferenceTestutil::InferShapes( + ShapeInferenceTestOp("NoSuchOp"), "", "") + .error_message(); + EXPECT_TRUE(StringPiece(error_message) + .starts_with("Op type not registered 'NoSuchOp'")); // Wrong shape error messages. EXPECT_CONTAINS(RunInferShapes(op, "[1];[2];[1]", "?", fn_copy_input_0),