| 38 | #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) |
| 39 | |
| 40 | TEST(Benchmark, EagerScaleCUDA) { |
| 41 | eager_test::InitEnv(phi::GPUPlace()); |
| 42 | |
| 43 | for (const std::string mode : {"Accuracy", "WarmUp", "Performance"}) { |
| 44 | phi::DDim ddim = common::make_ddim({2, 4, 4, 4}); |
| 45 | paddle::Tensor tensor = |
| 46 | eager_test::CreateTensorWithValue(ddim, |
| 47 | phi::GPUPlace(), |
| 48 | phi::DataType::FLOAT32, |
| 49 | phi::DataLayout::NCHW, |
| 50 | 5.0 /*value*/, |
| 51 | true /*is_leaf*/); |
| 52 | RetainGradForTensor(tensor); |
| 53 | |
| 54 | if (mode == "Accuracy") { |
| 55 | benchmark_eager_scale(tensor, true /* accuracy_check */); |
| 56 | |
| 57 | } else if (mode == "WarmUp") { |
| 58 | benchmark_eager_scale(tensor); |
| 59 | |
| 60 | } else if (mode == "Performance") { |
| 61 | auto t_start = std::chrono::high_resolution_clock::now(); |
| 62 | #ifdef WITH_GPERFTOOLS |
| 63 | ProfilerStart("eager_scale_cuda.out"); |
| 64 | #endif |
| 65 | benchmark_eager_scale(tensor); |
| 66 | |
| 67 | #ifdef WITH_GPERFTOOLS |
| 68 | ProfilerStop(); |
| 69 | #endif |
| 70 | auto t_end = std::chrono::high_resolution_clock::now(); |
| 71 | double elapsed_time_ms = |
| 72 | std::chrono::duration<double, std::milli>(t_end - t_start).count(); |
| 73 | std::cout << "Duration: " << elapsed_time_ms << " ms" << std::endl; |
| 74 | |
| 75 | } else { |
| 76 | PADDLE_THROW(common::errors::Fatal("Unknown benchmark mode")); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | TEST(Benchmark, EagerMatmulCUDA) { |
| 82 | phi::GPUPlace place; |
nothing calls this directly
no test coverage detected