提交 127f0944 编写于 作者: D dolphin8

rewrite some code in io.cpp & fix CMakeLists.txt in test

上级 fd7dab06
...@@ -172,22 +172,17 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::Load( ...@@ -172,22 +172,17 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::Load(
// //
DLOG << "n_ops: " << (*c_program->blocks)->n_ops; DLOG << "n_ops: " << (*c_program->blocks)->n_ops;
// //
std::shared_ptr<framework::ProgramDesc> originProgramDesc = auto originProgramDesc = std::make_shared<framework::ProgramDesc>(c_program);
std::make_shared<framework::ProgramDesc>(c_program);
framework::Program<Dtype, P> program; framework::Program<Dtype, P> program;
program.model_path = dirname; program.model_path = dirname;
program.originProgram = originProgramDesc; program.originProgram = originProgramDesc;
std::shared_ptr<framework::Scope> scope = auto scope = std::make_shared<framework::Scope>();
std::make_shared<framework::Scope>();
program.scope = scope; program.scope = scope;
originProgramDesc->Block(0);
for (const auto &block : originProgramDesc->Blocks()) { for (const auto &block : originProgramDesc->Blocks()) {
for (int i = 0; i < block->Vars().size(); ++i) { for (auto var_desc : block->Vars()) {
std::shared_ptr<framework::VarDesc> var_desc = block->Vars()[i];
// DLOG << "var name-- " << var_desc->Name();
auto var = scope->Var(var_desc->Name()); auto var = scope->Var(var_desc->Name());
if (var_desc->Type() == framework::VARTYPE_TYPE_LOD_TENSOR) { if (var_desc->Type() == framework::VARTYPE_TYPE_LOD_TENSOR) {
......
...@@ -122,13 +122,9 @@ else () ...@@ -122,13 +122,9 @@ else ()
target_link_libraries(test-enforce paddle-mobile) target_link_libraries(test-enforce paddle-mobile)
# gen test - test if openmp works # 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) 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 # gen test
ADD_EXECUTABLE(test-mobilenetssd net/test_mobilenet+ssd.cpp test_helper.h test_include.h executor_for_test.h) 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) target_link_libraries(test-mobilenetssd paddle-mobile)
......
...@@ -16,11 +16,13 @@ limitations under the License. */ ...@@ -16,11 +16,13 @@ limitations under the License. */
#include <iostream> #include <iostream>
int main(void) { int main(void) {
#ifdef PADDLE_MOBILE_USE_OPENMP
#pragma omp parallel num_threads(2) #pragma omp parallel num_threads(2)
{ {
int thread_id = omp_get_thread_num(); int thread_id = omp_get_thread_num();
int nthreads = omp_get_num_threads(); int nthreads = omp_get_num_threads();
std::cout << "Hello, OMP " << thread_id << "/" << nthreads << "\n"; std::cout << "Hello, OMP " << thread_id << "/" << nthreads << "\n";
} }
#endif
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册