MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / TEST

Function TEST

test/cpp/eager/performance_tests/benchmark_eager_cuda.cc:40–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
39
40TEST(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
81TEST(Benchmark, EagerMatmulCUDA) {
82 phi::GPUPlace place;

Callers

nothing calls this directly

Calls 15

InitEnvFunction · 0.85
GPUPlaceClass · 0.85
make_ddimFunction · 0.85
CreateTensorWithValueFunction · 0.85
RetainGradForTensorFunction · 0.85
benchmark_eager_scaleFunction · 0.85
ProfilerStartFunction · 0.85
ProfilerStopFunction · 0.85
benchmark_eager_matmulFunction · 0.85
SetCurrentTracerFunction · 0.85

Tested by

no test coverage detected