| 26 | class ExecutionProfileTest : public ClientLibraryTestBase {}; |
| 27 | |
| 28 | XLA_TEST_F(ExecutionProfileTest, ExecuteWithExecutionProfile) { |
| 29 | Shape shape = ShapeUtil::MakeShape(F32, {256, 256}); |
| 30 | |
| 31 | TF_ASSERT_OK_AND_ASSIGN( |
| 32 | std::unique_ptr<GlobalData> input, |
| 33 | client_->TransferToServer( |
| 34 | LiteralUtil::CreateR2F32Linspace(1e0, 1e5, 256, 256))); |
| 35 | |
| 36 | XlaBuilder b(TestName() + ".add"); |
| 37 | Dot(Parameter(&b, 0, shape, "param_0"), Parameter(&b, 1, shape, "param_1")); |
| 38 | TF_ASSERT_OK_AND_ASSIGN(XlaComputation dot_product, b.Build()); |
| 39 | |
| 40 | ExecutionProfile execution_profile; |
| 41 | TF_ASSERT_OK_AND_ASSIGN( |
| 42 | std::unique_ptr<GlobalData> data, |
| 43 | client_->Execute(dot_product, {input.get(), input.get()}, |
| 44 | &execution_options_, &execution_profile)); |
| 45 | |
| 46 | VLOG(3) << "execution_profile.compute_cycle_count() = " |
| 47 | << execution_profile.compute_cycle_count(); |
| 48 | VLOG(3) << "execution_profile.compute_and_transfer_time_ns() = " |
| 49 | << execution_profile.compute_and_transfer_time_ns(); |
| 50 | VLOG(3) << "execution_profile.compute_time_ns() = " |
| 51 | << execution_profile.compute_time_ns(); |
| 52 | |
| 53 | bool hlo_profiling_enabled = |
| 54 | execution_options_.debug_options().xla_hlo_profile(); |
| 55 | |
| 56 | // If HLO profiling is enabled we always expect cycle count to be populated. |
| 57 | // If HLO profiling is disabled then depending on the backend the cycle count |
| 58 | // may or may not be populated. |
| 59 | if (hlo_profiling_enabled) { |
| 60 | EXPECT_GT(execution_profile.compute_cycle_count(), 0); |
| 61 | } |
| 62 | |
| 63 | EXPECT_GT(execution_profile.compute_and_transfer_time_ns(), 0); |
| 64 | EXPECT_GT(execution_profile.compute_time_ns(), 0); |
| 65 | |
| 66 | TF_ASSERT_OK_AND_ASSIGN(auto computed, client_->Transfer(*data, &shape)); |
| 67 | (void)computed; |
| 68 | } |
| 69 | |
| 70 | } // namespace |
| 71 | } // namespace xla |
nothing calls this directly
no test coverage detected