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

Function TEST

tensorflow/c/c_api_experimental_test.cc:32–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30namespace {
31
32TEST(CAPI_EXPERIMENTAL, GetServerDefTest) {
33 const string expected_text_proto(R"(cluster {
34 job {
35 name: "worker"
36 tasks {
37 key: 0
38 value: "tpuserver:0"
39 }
40 tasks {
41 key: 1
42 value: "localhost:1"
43 }
44 }
45}
46job_name: "worker"
47task_index: 1
48protocol: "grpc"
49)");
50
51 TF_Status* status = TF_NewStatus();
52 TF_Buffer* result = TFE_GetServerDef(expected_text_proto.c_str(), status);
53 EXPECT_EQ(TF_GetCode(status), TF_OK);
54
55 ServerDef actual;
56 ASSERT_TRUE(actual.ParseFromArray(result->data, result->length));
57 string actual_text_proto;
58 tensorflow::protobuf::TextFormat::PrintToString(actual, &actual_text_proto);
59 EXPECT_EQ(expected_text_proto, actual_text_proto);
60
61 const string malformed_text_proto(R"(cluster {
62 job {
63 name: "worker")");
64 TF_Buffer* null_result =
65 TFE_GetServerDef(malformed_text_proto.c_str(), status);
66 EXPECT_NE(TF_GetCode(status), TF_OK);
67 EXPECT_TRUE(absl::StrContains(TF_Message(status),
68 "Invalid text proto for ServerDef"));
69 EXPECT_EQ(null_result, nullptr);
70
71 // Cleanup
72 TF_DeleteBuffer(result);
73 TF_DeleteStatus(status);
74}
75
76TEST(CAPI_EXPERIMENTAL, IsStateful) {
77 std::unique_ptr<TF_Status, decltype(&TF_DeleteStatus)> status(

Callers

nothing calls this directly

Calls 15

TF_NewStatusFunction · 0.85
TFE_GetServerDefFunction · 0.85
TF_GetCodeFunction · 0.85
TF_MessageFunction · 0.85
TF_DeleteBufferFunction · 0.85
TF_DeleteStatusFunction · 0.85
TF_OpIsStatefulFunction · 0.85
TFE_NewContextOptionsFunction · 0.85
TFE_NewContextFunction · 0.85
TFE_DeleteContextOptionsFunction · 0.85
TestMatrixTensorHandleFunction · 0.85
TFE_ExecuteOpInNewThreadFunction · 0.85

Tested by

no test coverage detected