提交 beff011a 编写于 作者: xiebaiyuan's avatar xiebaiyuan

run android gpu for super -- update test and fix bug with wh changed

上级 6f4b68b5
cmake_minimum_required(VERSION 3.0.0)
option(USE_OPENMP "openmp support" ON)
option(USE_OPENMP "openmp support" OFF)
option(DEBUGING "enable debug mode" ON)
option(USE_EXCEPTION "use std exception" ON)
option(SYMBOL_HIDDEN "symbol hidden" OFF) # on when use jni or ios io
option(LOG_PROFILE "log profile" OFF)
option(LOG_PROFILE "log profile" ON)
# select the platform to build
option(CPU "armv7 with neon" ON)
option(GPU_MALI "mali gpu" OFF)
option(GPU_CL "opencl gpu" OFF)
option(GPU_CL "opencl gpu" ON)
option(FPGA "fpga" OFF)
if(FPGA)
......
......@@ -551,13 +551,12 @@ void Executor<GPU_CL, float>::SetInput(const Tensor &input,
DLOG << "target_tensor->IsInitialized() " << target_tensor->IsInitialized();
DLOG << "target_tensor->dims() " << target_tensor->dims();
DLOG << "input.dims() " << input.dims();
DLOG << "input_dim_last_ " << input_dim_last_;
if (config_.load_when_predict) {
if (input_dim_last_ != input.dims()) {
if (!target_tensor->IsInitialized()) {
DLOG << "SetInput ---- > resize1";
target_tensor->Resize(input.dims());
target_tensor->mutable_data<float>();
}
DLOG << "SetInput ---- > resize1";
target_tensor->Resize(input.dims());
target_tensor->mutable_data<float>();
InitNoPersistableMemory(*target_tensor);
}
} else {
......@@ -566,7 +565,8 @@ void Executor<GPU_CL, float>::SetInput(const Tensor &input,
DLOG << "SetInput ---- > ShareDataWith";
}
target_tensor->ShareDataWith(input);
input_dim_last_ = input.dims();
auto &dim = input.dims();
input_dim_last_ = static_cast<DDim>(dim);
}
template <typename Device, typename T>
......
......@@ -37,7 +37,7 @@ int main() {
auto time2 = paddle_mobile::time();
std::cout << "load cost :" << paddle_mobile::time_diff(time1, time2) << "ms"
<< std::endl;
// 300*300
std::vector<float> input;
std::vector<int64_t> dims{1, 1, 300, 300};
GetInput<float>(g_test_image_1x3x224x224, &input, dims);
......@@ -51,22 +51,90 @@ int main() {
auto time5 = paddle_mobile::time();
vec_result = paddle_mobile.Predict(input, dims);
auto time6 = paddle_mobile::time();
std::cout << "predict cost :第" << i << ": "
std::cout << "300 predict cost :第" << i << ": "
<< paddle_mobile::time_diff(time5, time6) << "ms" << std::endl;
}
auto time4 = paddle_mobile::time();
std::cout << "predict cost :"
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 << " Max element is " << *biggest << " at position "
std::cout << "300 Max element is " << *biggest << " at position "
<< std::distance(std::begin(vec_result), biggest) << std::endl;
// 500*500
std::vector<float> vec_result2;
std::vector<float> input2;
std::vector<int64_t> dims2{1, 1, 500, 500};
GetInput<float>(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<float> vec_result3;
std::vector<float> input3;
std::vector<int64_t> dims3{1, 1, 1000, 1000};
GetInput<float>(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;
// 224*224
std::vector<float> vec_result4;
std::vector<float> input4;
std::vector<int64_t> dims4{1, 1, 224, 224};
GetInput<float>(g_test_image_1x3x224x224, &input4, dims4);
time3 = 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 << "224*224 predict cost :第" << i << ": "
<< paddle_mobile::time_diff(time5, time6) << "ms" << std::endl;
}
time4 = paddle_mobile::time();
std::cout << "224*224 predict cost :"
<< paddle_mobile::time_diff(time3, time4) / 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;
}
std::cout << "如果结果Nan请查看: test/images/g_test_image_1x3x224x224_banana "
"是否存在?"
<< std::endl;
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册