| 60 | BENCHMARK(BM_InitOp); |
| 61 | |
| 62 | void BM_Execute(int iters, int async) { |
| 63 | tensorflow::testing::StopTiming(); |
| 64 | tensorflow::testing::SetLabel(async ? "ExecuteAsync" : "Execute"); |
| 65 | TF_Status* status = TF_NewStatus(); |
| 66 | TFE_ContextOptions* opts = TFE_NewContextOptions(); |
| 67 | TFE_ContextOptionsSetAsync(opts, static_cast<unsigned char>(async)); |
| 68 | TFE_Context* ctx = TFE_NewContext(opts, status); |
| 69 | CHECK_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); |
| 70 | TFE_DeleteContextOptions(opts); |
| 71 | |
| 72 | TFE_TensorHandle* m = TestMatrixTensorHandle(); |
| 73 | TFE_Op* matmul = MatMulOp(ctx, m, m); |
| 74 | TFE_TensorHandle* retvals[1]; |
| 75 | int num_retvals = 1; |
| 76 | tensorflow::testing::StartTiming(); |
| 77 | for (int i = 0; i < iters; ++i) { |
| 78 | TFE_Execute(matmul, &retvals[0], &num_retvals, status); |
| 79 | CHECK_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); |
| 80 | } |
| 81 | if (async) { |
| 82 | TFE_Executor* executor = TFE_ContextGetExecutorForThread(ctx); |
| 83 | TFE_ExecutorWaitForAllPendingNodes(executor, status); |
| 84 | ASSERT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); |
| 85 | TFE_DeleteExecutor(executor); |
| 86 | } |
| 87 | tensorflow::testing::StopTiming(); |
| 88 | TFE_DeleteOp(matmul); |
| 89 | TFE_DeleteTensorHandle(m); |
| 90 | TFE_DeleteContext(ctx); |
| 91 | CHECK_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); |
| 92 | TF_DeleteStatus(status); |
| 93 | } |
| 94 | BENCHMARK(BM_Execute)->Arg(0)->Arg(1); |
| 95 | |
| 96 | void BM_Execute_Identity(int iters, int async) { |
nothing calls this directly
no test coverage detected