aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/common_runtime/simple_placer_test.cc
diff options
context:
space:
mode:
authorGravatar Derek Murray <mrry@google.com>2016-03-11 17:04:00 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-03-11 20:45:42 -0800
commit9849c30bb441d8bc07b5a5bb2efe0640ce46c97c (patch)
treea0d8a43eb332597500beb65f0e12a77aba84499b /tensorflow/core/common_runtime/simple_placer_test.cc
parentc5fc107300f7c89befcedf605622b571dd8b9f71 (diff)
Improve SimplePlacer error message when a device does not exist.
This change distinguishes between the case where a device in the NodeDef refers to an unknown device, and when it refers to a device that exists but doesn't support a particular node. Change: 117022320
Diffstat (limited to 'tensorflow/core/common_runtime/simple_placer_test.cc')
-rw-r--r--tensorflow/core/common_runtime/simple_placer_test.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/tensorflow/core/common_runtime/simple_placer_test.cc b/tensorflow/core/common_runtime/simple_placer_test.cc
index bb0bdcc216..cbc1c8341d 100644
--- a/tensorflow/core/common_runtime/simple_placer_test.cc
+++ b/tensorflow/core/common_runtime/simple_placer_test.cc
@@ -927,6 +927,32 @@ TEST_F(SimplePlacerTest, TestUnsupportedDeviceNoAllowSoftPlacement) {
StringPiece(s.error_message())
.contains(
"Could not satisfy explicit device specification '/cpu:0'"));
+ EXPECT_TRUE(
+ StringPiece(s.error_message())
+ .contains("no supported kernel for CPU devices is available"));
+}
+
+// Test that placement fails when a node requests an explicit device that is not
+// supported by the registered kernels if allow_soft_placement is no set.
+TEST_F(SimplePlacerTest, TestNonExistentDevice) {
+ Graph g(OpRegistry::Global());
+ { // Scope for temporary variables used to construct g.
+ GraphDefBuilder b(GraphDefBuilder::kFailImmediately);
+ ops::SourceOp("VariableGPU",
+ b.opts().WithName("var").WithDevice("/job:foo/replica:17"));
+ TF_EXPECT_OK(BuildGraph(b, &g));
+ }
+
+ SessionOptions options;
+ Status s = Place(&g, &options);
+ EXPECT_EQ(error::INVALID_ARGUMENT, s.code());
+ LOG(WARNING) << s.error_message();
+ EXPECT_TRUE(
+ StringPiece(s.error_message())
+ .contains("Could not satisfy explicit device specification "
+ "'/job:foo/replica:17' "
+ "because no devices matching that specification are "
+ "registered in this process"));
}
TEST_F(SimplePlacerTest, TestUnsupportedDeviceAllowSoftPlacement) {