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
This commit is contained in:
Vijay Vasudevan 2017-05-17 12:18:25 -07:00 committed by TensorFlower Gardener
parent 9ca8a151b1
commit 1390dd68fe
3 changed files with 16 additions and 9 deletions

View File

@ -208,9 +208,8 @@ TEST_F(NodeDefBuilderTest, OpDoesNotExist) {
.ControlInput("y") .ControlInput("y")
.Attr("foo", 12) .Attr("foo", 12)
.Device("device"); .Device("device");
ExpectFailure( ExpectFailures(builder, {"Op type not registered 'Op Does Not Exist'",
builder, "while building NodeDef 'n'"});
"Op type not registered 'Op Does Not Exist' while building NodeDef 'n'");
} }
TEST_F(NodeDefBuilderTest, Polymorphic) { TEST_F(NodeDefBuilderTest, Polymorphic) {

View File

@ -21,6 +21,7 @@ limitations under the License.
#include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/gtl/map_util.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/logging.h"
#include "tensorflow/core/platform/mutex.h" #include "tensorflow/core/platform/mutex.h"
#include "tensorflow/core/platform/protobuf.h" #include "tensorflow/core/platform/protobuf.h"
@ -83,7 +84,10 @@ Status OpRegistry::LookUp(const string& op_type_name,
first_unregistered = false; first_unregistered = false;
} }
Status status = 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(); VLOG(1) << status.ToString();
return status; return status;
} }
@ -225,7 +229,10 @@ Status OpListOpRegistry::LookUp(const string& op_type_name,
auto iter = index_.find(op_type_name); auto iter = index_.find(op_type_name);
if (iter == index_.end()) { if (iter == index_.end()) {
*op_reg_data = nullptr; *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; *op_reg_data = iter->second;
return Status::OK(); return Status::OK();

View File

@ -93,10 +93,11 @@ TEST(ShapeInferenceTestutilTest, Failures) {
RunInferShapes(op, "[1];[2];[1]", "e", fn_copy_input_0)); RunInferShapes(op, "[1];[2];[1]", "e", fn_copy_input_0));
EXPECT_CONTAINS(RunInferShapes(op, "[1];[2];[1]", "[1];[2]", fn_copy_input_0), EXPECT_CONTAINS(RunInferShapes(op, "[1];[2];[1]", "[1];[2]", fn_copy_input_0),
"wrong number of outputs"); "wrong number of outputs");
EXPECT_EQ("Op type not registered 'NoSuchOp'", auto error_message = ShapeInferenceTestutil::InferShapes(
ShapeInferenceTestutil::InferShapes( ShapeInferenceTestOp("NoSuchOp"), "", "")
ShapeInferenceTestOp("NoSuchOp"), "", "") .error_message();
.error_message()); EXPECT_TRUE(StringPiece(error_message)
.starts_with("Op type not registered 'NoSuchOp'"));
// Wrong shape error messages. // Wrong shape error messages.
EXPECT_CONTAINS(RunInferShapes(op, "[1];[2];[1]", "?", fn_copy_input_0), EXPECT_CONTAINS(RunInferShapes(op, "[1];[2];[1]", "?", fn_copy_input_0),