diff options
-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. |