From da63ea3fe367ffdaf6005be152d50cc692fb4cb2 Mon Sep 17 00:00:00 2001 From: Jiaying Zhao Date: Wed, 10 Jul 2019 15:44:32 +0800 Subject: [PATCH] update test_super for 360P, 480P, 576P, 720P (#1741) --- test/net/test_super.cpp | 169 ++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 101 deletions(-) diff --git a/test/net/test_super.cpp b/test/net/test_super.cpp index 6815a886a7..669859f622 100644 --- a/test/net/test_super.cpp +++ b/test/net/test_super.cpp @@ -21,131 +21,98 @@ int main() { paddle_mobile::PaddleMobileConfigInternal config; config.load_when_predict = true; - auto time1 = paddle_mobile::time(); #ifdef PADDLE_MOBILE_CL paddle_mobile::PaddleMobile paddle_mobile(config); paddle_mobile.SetCLPath("/data/local/tmp/bin"); #else - paddle_mobile::PaddleMobile paddle_mobile(config); + paddle_mobile::PaddleMobile paddle_mobile; #endif // paddle_mobile.SetThreadNum(4); + int max = 10; + auto time1 = paddle_mobile::time(); auto isok = paddle_mobile.Load(std::string(g_super) + "/model", std::string(g_super) + "/params", true, false, 1, false); - // auto isok = paddle_mobile.Load(std::string(g_mobilenet_mul), true); if (isok) { auto time2 = paddle_mobile::time(); std::cout << "load cost :" << paddle_mobile::time_diff(time1, time2) << "ms" << std::endl; - // 300*300 - // std::vector input; - // std::vector dims{1, 1, 300, 300}; - // GetInput(g_test_image_1x3x224x224, &input, dims); - // - // std::vector vec_result; + // 300 * 300 + std::vector input; + std::vector dims{1, 1, 300, 300}; + GetInput(g_test_image_1x3x224x224, &input, dims); + paddle_mobile.Predict(input, dims); + + // 640 * 360 (360P) + std::vector input1; + std::vector dims1{1, 1, 640, 360}; + GetInput(g_test_image_1x3x224x224, &input1, dims1); auto time3 = paddle_mobile::time(); - int max = 1; + for (int i = 0; i < max; ++i) { + auto time1 = paddle_mobile::time(); + paddle_mobile.Predict(input1, dims1); + auto time2 = paddle_mobile::time(); + std::cout << "640 * 360 predict cost :第" << i << ": " + << paddle_mobile::time_diff(time1, time2) << "ms" << std::endl; + } + auto time4 = paddle_mobile::time(); + std::cout << "640 * 360 predict cost :" + << paddle_mobile::time_diff(time3, time4) / max << "ms" + << std::endl; - // for (int i = 0; i < max; ++i) { - // auto time5 = paddle_mobile::time(); - // vec_result = paddle_mobile.Predict(input, dims); - // auto time6 = paddle_mobile::time(); - // std::cout << "300 predict cost :第" << i << ": " - // << paddle_mobile::time_diff(time5, time6) << "ms" << - // std::endl; - // } - // auto time4 = paddle_mobile::time(); - // - // std::cout << "300 predict cost :" - // << paddle_mobile::time_diff(time3, time4) / max << "ms" - // << std::endl; - // auto biggest = - // std::max_element(std::begin(vec_result), std::end(vec_result)); - // std::cout << "300 Max element is " << *biggest << " at position " - // << std::distance(std::begin(vec_result), biggest) << - // std::endl; - // - // // 500*500 - // std::vector vec_result2; - // - // std::vector input2; - // std::vector dims2{1, 1, 500, 500}; - // GetInput(g_test_image_1x3x224x224, &input2, dims2); - // - // time3 = paddle_mobile::time(); - // for (int i = 0; i < max; ++i) { - // auto time5 = paddle_mobile::time(); - // vec_result2 = paddle_mobile.Predict(input2, dims2); - // auto time6 = paddle_mobile::time(); - // std::cout << "500 predict cost :第" << i << ": " - // << paddle_mobile::time_diff(time5, time6) << "ms" << - // std::endl; - // } - // - // time4 = paddle_mobile::time(); - // std::cout << "500 predict cost :" - // << paddle_mobile::time_diff(time3, time4) / max << "ms" - // << std::endl; - // biggest = std::max_element(std::begin(vec_result2), - // std::end(vec_result2)); std::cout << "500 Max element is " << *biggest - // << " at position " - // << std::distance(std::begin(vec_result2), biggest) << - // std::endl; - // - // // 1000*1000 - // - // std::vector vec_result3; - // std::vector input3; - // std::vector dims3{1, 1, 1000, 1000}; - // GetInput(g_test_image_1x3x224x224, &input3, dims3); - // - // time3 = paddle_mobile::time(); - // - // for (int i = 0; i < max; ++i) { - // auto time5 = paddle_mobile::time(); - // vec_result3 = paddle_mobile.Predict(input3, dims3); - // auto time6 = paddle_mobile::time(); - // std::cout << "1000*1000 predict cost :第" << i << ": " - // << paddle_mobile::time_diff(time5, time6) << "ms" << - // std::endl; - // } - // time4 = paddle_mobile::time(); - // std::cout << "1000*1000 predict cost :" - // << paddle_mobile::time_diff(time3, time4) / max << "ms" - // << std::endl; - // biggest = std::max_element(std::begin(vec_result3), - // std::end(vec_result3)); std::cout << "1000*1000 Max element is " << - // *biggest << " at position " - // << std::distance(std::begin(vec_result3), biggest) << - // std::endl; + // 720 * 480 (480P) + std::vector input2; + std::vector dims2{1, 1, 720, 480}; + GetInput(g_test_image_1x3x224x224, &input2, dims2); + auto time5 = paddle_mobile::time(); + for (int i = 0; i < max; ++i) { + auto time1 = paddle_mobile::time(); + paddle_mobile.Predict(input2, dims2); + auto time2 = paddle_mobile::time(); + std::cout << "720 * 480 predict cost :第" << i << ": " + << paddle_mobile::time_diff(time1, time2) << "ms" << std::endl; + } + auto time6 = paddle_mobile::time(); + std::cout << "720 * 480 predict cost :" + << paddle_mobile::time_diff(time5, time6) / max << "ms" + << std::endl; + + // 1024 * 576 (576P) + std::vector input3; + std::vector dims3{1, 1, 1024, 576}; + GetInput(g_test_image_1x3x224x224, &input3, dims3); + auto time7 = paddle_mobile::time(); + for (int i = 0; i < max; ++i) { + auto time1 = paddle_mobile::time(); + paddle_mobile.Predict(input3, dims3); + auto time2 = paddle_mobile::time(); + std::cout << "1024 * 576 predict cost :第" << i << ": " + << paddle_mobile::time_diff(time1, time2) << "ms" << std::endl; + } + auto time8 = paddle_mobile::time(); + std::cout << "1024 * 576 predict cost :" + << paddle_mobile::time_diff(time7, time8) / max << "ms" + << std::endl; - // 224*224 - std::vector vec_result4; + // 1280 * 720 std::vector input4; - std::vector dims4{1, 1, 300, 300}; + std::vector dims4{1, 1, 1280, 720}; GetInput(g_test_image_1x3x224x224, &input4, dims4); - - time3 = paddle_mobile::time(); + auto time9 = paddle_mobile::time(); for (int i = 0; i < max; ++i) { - auto time5 = paddle_mobile::time(); - vec_result4 = paddle_mobile.Predict(input4, dims4); - auto time6 = paddle_mobile::time(); - std::cout << "300*300 predict cost :第" << i << ": " - << paddle_mobile::time_diff(time5, time6) << "ms" << std::endl; + auto time1 = paddle_mobile::time(); + paddle_mobile.Predict(input4, dims4); + auto time2 = paddle_mobile::time(); + std::cout << "1280 * 720 predict cost :第" << i << ": " + << paddle_mobile::time_diff(time1, time2) << "ms" << std::endl; } - - auto time4 = paddle_mobile::time(); - std::cout << "300*300 predict cost :" - << paddle_mobile::time_diff(time3, time4) / max << "ms" + auto time10 = paddle_mobile::time(); + std::cout << "1280 * 720 predict cost :" + << paddle_mobile::time_diff(time9, time10) / max << "ms" << std::endl; - // biggest = std::max_element(std::begin(vec_result4), - // std::end(vec_result4)); std::cout << "224*224 Max element is " << - // *biggest << " at position " - // << std::distance(std::begin(vec_result4), biggest) << - // std::endl; } return 0; -- GitLab