| 94 | BENCHMARK(BM_Execute)->Arg(0)->Arg(1); |
| 95 | |
| 96 | void 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 | } |
| 129 | BENCHMARK(BM_Execute_Identity)->Arg(0)->Arg(1); |
| 130 | |
| 131 | TEST(CAPI, Context) { |
nothing calls this directly
no test coverage detected