| 29 | namespace tests { |
| 30 | |
| 31 | TEST(API, scale) { |
| 32 | auto x = experimental::full({3, 4}, 1.0, phi::DataType::FLOAT32, CPUPlace()); |
| 33 | |
| 34 | const size_t cycles = 300; |
| 35 | phi::tests::Timer timer; |
| 36 | double t1{}, t2{}, t3{}; |
| 37 | |
| 38 | for (size_t i = 0; i < cycles; ++i) { |
| 39 | timer.tic(); |
| 40 | for (size_t i = 0; i < cycles; ++i) { |
| 41 | auto out = experimental::scale_kernel_context(x, 2.0, 1.0, true); |
| 42 | } |
| 43 | t1 += timer.toc(); |
| 44 | |
| 45 | timer.tic(); |
| 46 | for (size_t i = 0; i < cycles; ++i) { |
| 47 | auto out = experimental::scale(x, 2.0, 1.0, true); |
| 48 | } |
| 49 | t2 += timer.toc(); |
| 50 | |
| 51 | timer.tic(); |
| 52 | for (size_t i = 0; i < cycles; ++i) { |
| 53 | auto out = experimental::scale_switch_case(x, 2.0, 1.0, true); |
| 54 | } |
| 55 | t3 += timer.toc(); |
| 56 | } |
| 57 | |
| 58 | LOG(INFO) << "The cost of kernel_context is " << t1 << "ms."; |
| 59 | LOG(INFO) << "The cost of variadic_args_kernel_fn is " << t2 << "ms."; |
| 60 | LOG(INFO) << "The cost of switch_case is " << t3 << "ms."; |
| 61 | } |
| 62 | |
| 63 | } // namespace tests |
| 64 | } // namespace paddle |
nothing calls this directly
no test coverage detected