MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/common_runtime/direct_session_test.cc:693–730  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

691}
692
693TEST(DirectSessionTest, KeepsStateAcrossRunsOfSession) {
694 GraphDef def;
695 Graph g(OpRegistry::Global());
696 Node* var = test::graph::Var(&g, DT_FLOAT, TensorShape({10}));
697 var->set_assigned_device_name("/job:localhost/replica:0/task:0/cpu:0");
698
699 Tensor twenty(DT_FLOAT, TensorShape({10}));
700 for (int i = 0; i < 10; ++i) {
701 twenty.flat<float>()(i) = 20.0;
702 }
703
704 Node* twenty_node = test::graph::Constant(&g, twenty);
705 twenty_node->set_assigned_device_name(
706 "/job:localhost/replica:0/task:0/cpu:0");
707
708 Node* init = test::graph::Assign(&g, var, twenty_node);
709 init->set_assigned_device_name("/job:localhost/replica:0/task:0/cpu:0");
710
711 g.ToGraphDef(&def);
712
713 auto session = CreateSession();
714 ASSERT_TRUE(session != nullptr);
715 TF_ASSERT_OK(session->Create(def));
716
717 std::vector<std::pair<string, Tensor>> inputs;
718 std::vector<Tensor> outputs;
719
720 // Initialize the variable
721 Status s = session->Run(inputs, {init->name()}, {}, &outputs);
722 TF_ASSERT_OK(s);
723
724 // Get the variable's data
725 s = session->Run(inputs, {var->name() + ":0"}, {}, &outputs);
726 TF_ASSERT_OK(s);
727 ASSERT_EQ(1, outputs.size());
728 ASSERT_TRUE(outputs[0].IsInitialized());
729 EXPECT_EQ(20.0, outputs[0].flat<float>()(0));
730}
731
732TEST(DirectSessionTest, MultipleFeedTest) {
733 GraphDef def;

Callers

nothing calls this directly

Calls 15

WrapUniqueFunction · 0.85
HasBeenNotifiedMethod · 0.80
CreateSessionFunction · 0.70
MakeCallableOptionsFunction · 0.70
DefaultSessionOptionsFunction · 0.70
NewSessionFunction · 0.70
ResetFunction · 0.70
SessionOptionsClass · 0.70
GPUDeviceNameFunction · 0.70

Tested by

no test coverage detected