| 85 | } |
| 86 | |
| 87 | TEST(GrpcSessionTest, BasicNonProtoAPI) { |
| 88 | GraphDef graph; |
| 89 | string node_names[3]; |
| 90 | // c = a * b |
| 91 | CreateGraphDef(&graph, node_names); |
| 92 | |
| 93 | std::unique_ptr<test::TestCluster> cluster; |
| 94 | TF_CHECK_OK(test::TestCluster::MakeTestCluster(Devices(1, 0), 2, &cluster)); |
| 95 | |
| 96 | std::unique_ptr<Session> session( |
| 97 | NewRemote(Options(cluster->targets()[0], 1))); |
| 98 | ASSERT_TRUE(session != nullptr); |
| 99 | |
| 100 | for (int iters = 0; iters < 25; ++iters) { |
| 101 | TF_CHECK_OK(session->Create(graph)); |
| 102 | { |
| 103 | // Just run to target node |
| 104 | std::vector<std::pair<string, Tensor>> inputs; |
| 105 | std::vector<string> targets = {node_names[2]}; |
| 106 | TF_CHECK_OK(session->Run(inputs, {}, targets, nullptr)); |
| 107 | } |
| 108 | { |
| 109 | // Run to a target node and a real tensor |
| 110 | std::vector<std::pair<string, Tensor>> inputs; |
| 111 | std::vector<string> names = {node_names[2] + ":0"}; |
| 112 | std::vector<string> targets = {node_names[1]}; |
| 113 | std::vector<Tensor> outputs; |
| 114 | TF_CHECK_OK(session->Run(inputs, names, targets, &outputs)); |
| 115 | ASSERT_TRUE(outputs[0].IsInitialized()); |
| 116 | ASSERT_EQ(4.0, outputs[0].flat<float>()(0)); |
| 117 | } |
| 118 | |
| 119 | TF_CHECK_OK(session->Close()); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | TEST(GrpcSessionTest, BasicCallable) { |
| 124 | GraphDef graph; |
nothing calls this directly
no test coverage detected