提交 ae28d245 编写于 作者: Z zhaojiaying01

update unit test of mobilenet and mobilenetssd

上级 7ba460cd
...@@ -32,10 +32,14 @@ int main() { ...@@ -32,10 +32,14 @@ int main() {
std::vector<int64_t> dims{1, 3, 300, 300}; std::vector<int64_t> dims{1, 3, 300, 300};
GetInput<float>(g_hand, &input, dims); GetInput<float>(g_hand, &input, dims);
// 预热一次
auto output = paddle_mobile.Predict(input, dims);
auto time3 = time(); auto time3 = time();
for (int i = 0; i < 10; ++i) {
auto output = paddle_mobile.Predict(input, dims); auto output = paddle_mobile.Predict(input, dims);
}
auto time4 = time(); auto time4 = time();
std::cout << "predict cost :" << time_diff(time3, time4) << "ms" std::cout << "predict cost :" << time_diff(time3, time4) / 10 << "ms"
<< std::endl; << std::endl;
} }
return 0; return 0;
......
...@@ -26,19 +26,22 @@ int main() { ...@@ -26,19 +26,22 @@ int main() {
std::vector<float> input; std::vector<float> input;
std::vector<int64_t> dims{1, 3, 224, 224}; std::vector<int64_t> dims{1, 3, 224, 224};
GetInput<float>(g_test_image_1x3x224x224, &input, dims); GetInput<float>(g_test_image_1x3x224x224_banana, &input, dims);
for (int i = 0; i < 10; ++i) { // 预热一次
auto time3 = time();
auto vec_result = paddle_mobile.Predict(input, dims); auto vec_result = paddle_mobile.Predict(input, dims);
auto time4 = time();
std::vector<float>::iterator biggest = std::vector<float>::iterator biggest =
std::max_element(std::begin(vec_result), std::end(vec_result)); std::max_element(std::begin(vec_result), std::end(vec_result));
std::cout << " Max element is " << *biggest << " at position " std::cout << " Max element is " << *biggest << " at position "
<< std::distance(std::begin(vec_result), biggest) << std::endl; << std::distance(std::begin(vec_result), biggest) << std::endl;
std::cout << "predict cost :" << time_diff(time3, time4) << "ms"
<< std::endl; auto time3 = time();
for (int i = 0; i < 10; ++i) {
auto vec_result = paddle_mobile.Predict(input, dims);
} }
auto time4 = time();
std::cout << "predict cost :" << time_diff(time3, time4) / 10 << "ms"
<< std::endl;
} }
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册