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

Function BM_Execute_Identity

tensorflow/c/eager/c_api_test.cc:96–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94BENCHMARK(BM_Execute)->Arg(0)->Arg(1);
95
96void BM_Execute_Identity(int iters, int async) {
97 tensorflow::testing::StopTiming();
98 tensorflow::testing::SetLabel(async ? "ExecuteIdentityAsync"
99 : "ExecuteIdentity");
100 TF_Status* status = TF_NewStatus();
101 TFE_ContextOptions* opts = TFE_NewContextOptions();
102 TFE_ContextOptionsSetAsync(opts, static_cast<unsigned char>(async));
103 TFE_Context* ctx = TFE_NewContext(opts, status);
104 CHECK_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
105 TFE_DeleteContextOptions(opts);
106
107 TFE_TensorHandle* m = TestMatrixTensorHandle();
108 TFE_Op* identity = IdentityOp(ctx, m);
109 TFE_TensorHandle* retvals[1];
110 int num_retvals = 1;
111 tensorflow::testing::StartTiming();
112 for (int i = 0; i < iters; ++i) {
113 TFE_Execute(identity, &retvals[0], &num_retvals, status);
114 CHECK_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
115 }
116 if (async) {
117 TFE_Executor* executor = TFE_ContextGetExecutorForThread(ctx);
118 TFE_ExecutorWaitForAllPendingNodes(executor, status);
119 ASSERT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
120 TFE_DeleteExecutor(executor);
121 }
122 tensorflow::testing::StopTiming();
123 TFE_DeleteOp(identity);
124 TFE_DeleteTensorHandle(m);
125 TFE_DeleteContext(ctx);
126 CHECK_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
127 TF_DeleteStatus(status);
128}
129BENCHMARK(BM_Execute_Identity)->Arg(0)->Arg(1);
130
131TEST(CAPI, Context) {

Callers

nothing calls this directly

Calls 15

StopTimingFunction · 0.85
SetLabelFunction · 0.85
TF_NewStatusFunction · 0.85
TFE_NewContextOptionsFunction · 0.85
TFE_NewContextFunction · 0.85
TF_GetCodeFunction · 0.85
TF_MessageFunction · 0.85
TFE_DeleteContextOptionsFunction · 0.85
TestMatrixTensorHandleFunction · 0.85
StartTimingFunction · 0.85
TFE_ExecuteFunction · 0.85

Tested by

no test coverage detected