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

Function TEST

test/cpp/eager/performance_tests/benchmark_eager_cpu.cc:39–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37using namespace egr_utils_api; // NOLINT
38
39TEST(Benchmark, EagerScaleCPU) {
40 // Prepare Device Contexts
41 eager_test::InitEnv(phi::CPUPlace());
42
43 for (const std::string mode : {"Accuracy", "Performance"}) {
44 phi::DDim ddim = common::make_ddim({2, 4, 4, 4});
45 paddle::Tensor tensor =
46 eager_test::CreateTensorWithValue(ddim,
47 phi::CPUPlace(),
48 phi::DataType::FLOAT32,
49 phi::DataLayout::NCHW,
50 5.0,
51 true);
52 RetainGradForTensor(tensor);
53
54 if (mode == "Accuracy") {
55 benchmark_eager_scale(tensor, true /* accuracy_check*/);
56
57 } else if (mode == "Performance") {
58 auto t_start = std::chrono::high_resolution_clock::now();
59#ifdef WITH_GPERFTOOLS
60 ProfilerStart("eager_scale_cpu.out");
61#endif
62 benchmark_eager_scale(tensor);
63
64#ifdef WITH_GPERFTOOLS
65 ProfilerStop();
66#endif
67 auto t_end = std::chrono::high_resolution_clock::now();
68 double elapsed_time_ms =
69 std::chrono::duration<double, std::milli>(t_end - t_start).count();
70
71 std::cout << "Duration: " << elapsed_time_ms << " ms" << std::endl;
72
73 } else {
74 PADDLE_THROW(common::errors::Fatal("Unknown benchmark mode"));
75 }
76 }
77}
78
79TEST(Benchmark, EagerMatmulCPU) {
80 // Prepare Device Contexts

Callers

nothing calls this directly

Calls 14

InitEnvFunction · 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
CPUPlaceClass · 0.50

Tested by

no test coverage detected