From 127f0944fc4c39143c5125c654426349de102345 Mon Sep 17 00:00:00 2001 From: dolphin8 Date: Thu, 7 Jun 2018 11:13:57 +0800 Subject: [PATCH] rewrite some code in io.cpp & fix CMakeLists.txt in test --- src/io/io.cpp | 11 +++-------- test/CMakeLists.txt | 6 +----- test/common/test_openmp.cpp | 2 ++ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/io/io.cpp b/src/io/io.cpp index 5eb1582a70..ad1650a266 100644 --- a/src/io/io.cpp +++ b/src/io/io.cpp @@ -172,22 +172,17 @@ const framework::Program Loader::Load( // DLOG << "n_ops: " << (*c_program->blocks)->n_ops; // - std::shared_ptr originProgramDesc = - std::make_shared(c_program); + auto originProgramDesc = std::make_shared(c_program); framework::Program program; program.model_path = dirname; program.originProgram = originProgramDesc; - std::shared_ptr scope = - std::make_shared(); + auto scope = std::make_shared(); program.scope = scope; - originProgramDesc->Block(0); for (const auto &block : originProgramDesc->Blocks()) { - for (int i = 0; i < block->Vars().size(); ++i) { - std::shared_ptr var_desc = block->Vars()[i]; - // DLOG << "var name-- " << var_desc->Name(); + for (auto var_desc : block->Vars()) { auto var = scope->Var(var_desc->Name()); if (var_desc->Type() == framework::VARTYPE_TYPE_LOD_TENSOR) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7bde05f70c..124e1c2d60 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -122,13 +122,9 @@ else () target_link_libraries(test-enforce paddle-mobile) # gen test - test if openmp works - ADD_EXECUTABLE(test-openmp common/test_openmp.cc test_helper.h test_include.h executor_for_test.h) + ADD_EXECUTABLE(test-openmp common/test_openmp.cpp test_helper.h test_include.h executor_for_test.h) target_link_libraries(test-openmp paddle-mobile) - # gen test - ADD_EXECUTABLE(test-yolo net/test_yolo.cpp test_helper.h test_include.h executor_for_test.h) - target_link_libraries(test-yolo paddle-mobile) - # gen test ADD_EXECUTABLE(test-mobilenetssd net/test_mobilenet+ssd.cpp test_helper.h test_include.h executor_for_test.h) target_link_libraries(test-mobilenetssd paddle-mobile) diff --git a/test/common/test_openmp.cpp b/test/common/test_openmp.cpp index 7393810a3c..ad8cbf73d1 100644 --- a/test/common/test_openmp.cpp +++ b/test/common/test_openmp.cpp @@ -16,11 +16,13 @@ limitations under the License. */ #include int main(void) { +#ifdef PADDLE_MOBILE_USE_OPENMP #pragma omp parallel num_threads(2) { int thread_id = omp_get_thread_num(); int nthreads = omp_get_num_threads(); std::cout << "Hello, OMP " << thread_id << "/" << nthreads << "\n"; } +#endif return 0; } -- GitLab