diff options
author | A. Unique TensorFlower <nobody@tensorflow.org> | 2016-04-09 07:07:24 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-04-09 08:12:54 -0700 |
commit | 8f8b8d6ddcc36345659470a2950d587ddc6d37d7 (patch) | |
tree | 6a6cce1062b2aed0022896b959420d85035bf3ca | |
parent | 01e089636c66457c7c82f6e6473c2a82215d37a8 (diff) |
Return correct status with error when Graph creation fails.
Change: 119448828
-rw-r--r-- | tensorflow/core/common_runtime/direct_session.cc | 2 | ||||
-rw-r--r-- | tensorflow/core/common_runtime/direct_session_test.cc | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/tensorflow/core/common_runtime/direct_session.cc b/tensorflow/core/common_runtime/direct_session.cc index 00f1edd0ba..b6e2988f3b 100644 --- a/tensorflow/core/common_runtime/direct_session.cc +++ b/tensorflow/core/common_runtime/direct_session.cc @@ -911,7 +911,7 @@ Status DirectSession::CreateGraphs(gtl::ArraySlice<string> feeds, // allow. device_opts.allow_internal_ops = true; device_opts.expect_device_spec = true; - Status s = ConvertGraphDefToGraph(device_opts, *graph_def, device_graph); + s = ConvertGraphDefToGraph(device_opts, *graph_def, device_graph); if (!s.ok()) { delete device_graph; break; diff --git a/tensorflow/core/common_runtime/direct_session_test.cc b/tensorflow/core/common_runtime/direct_session_test.cc index b0255fe118..37e0ff11d4 100644 --- a/tensorflow/core/common_runtime/direct_session_test.cc +++ b/tensorflow/core/common_runtime/direct_session_test.cc @@ -564,6 +564,28 @@ TEST(DirectSessionTest, PartialRunMultiOutputFeed) { ASSERT_EQ(true, outputs[0].flat<bool>()(0)); } +TEST(DirectSessionTest, CreateGraphFailsWhenAssigningAFedVar) { + Graph graph(OpRegistry::Global()); + + Node* a = test::graph::Var(&graph, DT_FLOAT, {}); + Node* b = test::graph::Constant(&graph, {}); + + Tensor zero(DT_FLOAT, {}); + test::FillValues<float>(&zero, {0}); + + // a = b + Node* assign = test::graph::Assign(&graph, a, b); + + std::unique_ptr<Session> session(CreateSession()); + ASSERT_TRUE(session != nullptr); + + // The graph is invalid since a constant cannot be assigned to a constant. + // The return Status of session->Run should flag this as an invalid argument. + std::vector<Tensor> outputs; + Status s = session->Run({{a->name(), zero}}, {assign->name()}, {}, &outputs); + ASSERT_TRUE(errors::IsInvalidArgument(s)); +} + TEST(DirectSessionTest, TimeoutSession) { GraphDef graph; // Creates a graph with one FIFOQueue and one dequeue op. |