From 262bab3d97d9d41c04a223169fcfe61475b0b61c Mon Sep 17 00:00:00 2001 From: liuruilong Date: Fri, 8 Jun 2018 10:59:31 +0800 Subject: [PATCH] format files --- src/common/protobuf-c.c | 2 +- src/framework/program/block_desc.cpp | 11 ++++------ src/framework/program/block_desc.h | 2 +- .../program/program-optimize/node.cpp | 2 +- src/framework/program/program-optimize/node.h | 4 ++-- src/framework/program/program.h | 1 + src/framework/tensor.h | 2 +- src/io/io.cpp | 22 +++++++++---------- src/io/io.h | 3 ++- test/framework/test_load.cpp | 3 ++- test/net/test_googlenet.cpp | 4 ++-- 11 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/common/protobuf-c.c b/src/common/protobuf-c.c index a058ac65c9..1092e3f78b 100644 --- a/src/common/protobuf-c.c +++ b/src/common/protobuf-c.c @@ -2095,4 +2095,4 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) { /* === services === */ typedef void (*GenericHandler)(void *service, const ProtobufCMessage *input, - ProtobufCClosure closure, void *closure_data); \ No newline at end of file + ProtobufCClosure closure, void *closure_data); diff --git a/src/framework/program/block_desc.cpp b/src/framework/program/block_desc.cpp index 4281121919..4b45ab305b 100644 --- a/src/framework/program/block_desc.cpp +++ b/src/framework/program/block_desc.cpp @@ -17,9 +17,7 @@ limitations under the License. */ namespace paddle_mobile { namespace framework { -std::vector> BlockDesc::Vars() const { - return vars_; -} +std::vector> BlockDesc::Vars() const { return vars_; } std::vector> BlockDesc::Ops() const { return ops_; } @@ -30,11 +28,10 @@ BlockDesc::BlockDesc(PaddleMobile__Framework__Proto__BlockDesc *desc) vars_.emplace_back(std::shared_ptr(new VarDesc(var_desc))); } - std::sort(vars_.begin(), - vars_.end(), - [](std::shared_ptr left, std::shared_ptr right){ + std::sort(vars_.begin(), vars_.end(), + [](std::shared_ptr left, std::shared_ptr right) { return left->Name() < right->Name(); - }); + }); for (int j = 0; j < desc->n_ops; ++j) { PaddleMobile__Framework__Proto__OpDesc *op_desc = desc->ops[j]; diff --git a/src/framework/program/block_desc.h b/src/framework/program/block_desc.h index 0775211b32..dd33a27426 100644 --- a/src/framework/program/block_desc.h +++ b/src/framework/program/block_desc.h @@ -36,7 +36,7 @@ class BlockDesc { for (int i = 0; i < block_desc.vars_.size(); ++i) { auto &var_desc = block_desc.vars_[i]; - vars_.emplace_back(std::make_shared(*var_desc)) ; + vars_.emplace_back(std::make_shared(*var_desc)); } } diff --git a/src/framework/program/program-optimize/node.cpp b/src/framework/program/program-optimize/node.cpp index 73de146743..4ea45ec0a8 100644 --- a/src/framework/program/program-optimize/node.cpp +++ b/src/framework/program/program-optimize/node.cpp @@ -91,7 +91,7 @@ int Node::Depth(int begin) { } Node &Node::Folder( - int size, std::string type, + int size, std::string type, std::map> change, std::vector> *removed_nodes) { std::shared_ptr op_desc = diff --git a/src/framework/program/program-optimize/node.h b/src/framework/program/program-optimize/node.h index a830a27e2f..7236ffdd17 100644 --- a/src/framework/program/program-optimize/node.h +++ b/src/framework/program/program-optimize/node.h @@ -14,10 +14,10 @@ limitations under the License. */ #pragma once +#include #include #include #include -#include #include "common/log.h" #include "framework/program/op_desc.h" @@ -42,7 +42,7 @@ class Node { std::shared_ptr To(int size); int Depth(int begin = 0); Node &Folder( - int size, std::string type, + int size, std::string type, std::map> change_map, std::vector> *removed_nodes); std::vector> OpDescs(int size); diff --git a/src/framework/program/program.h b/src/framework/program/program.h index 3930936b5c..bb82fa7334 100644 --- a/src/framework/program/program.h +++ b/src/framework/program/program.h @@ -30,6 +30,7 @@ class Program { std::string model_path; std::string para_path; bool is_commbine = false; + private: }; diff --git a/src/framework/tensor.h b/src/framework/tensor.h index cc84f7d449..a5f9afebdd 100644 --- a/src/framework/tensor.h +++ b/src/framework/tensor.h @@ -23,9 +23,9 @@ limitations under the License. */ #include "common/enforce.h" #include "common/enforce.h" +#include "framework/data_layout.h" #include "framework/ddim.h" #include "memory/t_malloc.h" -#include "framework/data_layout.h" namespace paddle_mobile { namespace framework { diff --git a/src/io/io.cpp b/src/io/io.cpp index b07ad26651..465f28bc83 100644 --- a/src/io/io.cpp +++ b/src/io/io.cpp @@ -164,9 +164,9 @@ const framework::Program Loader::Load( } template -const framework::Program Loader::Load(const std::string &model_path, - const std::string ¶_path, - bool optimize){ +const framework::Program Loader::Load( + const std::string &model_path, const std::string ¶_path, + bool optimize) { auto program = this->LoadProgram(model_path, optimize); program.para_path = para_path; program.is_commbine = true; @@ -174,9 +174,8 @@ const framework::Program Loader::Load(const std::string &mod } template -const framework::Program Loader::LoadProgram(const std::string &model_path, - bool optimize){ - +const framework::Program Loader::LoadProgram( + const std::string &model_path, bool optimize) { std::string model_filename = model_path; PaddleMobile__Framework__Proto__ProgramDesc *c_program; uint8_t *buf = NULL; @@ -185,7 +184,7 @@ const framework::Program Loader::LoadProgram(const std::stri PADDLE_MOBILE_ENFORCE(buf != NULL, "read from __model__ is null"); c_program = paddle_mobile__framework__proto__program_desc__unpack( - NULL, read_size, buf); + NULL, read_size, buf); // PADDLE_MOBILE_ENFORCE(c_program != NULL, "program is null"); // @@ -228,7 +227,7 @@ const framework::Program Loader::LoadProgram(const std::stri if (optimize) { framework::ProgramOptimize program_optimize; program.optimizeProgram = - program_optimize.FushionOptimize(originProgramDesc); + program_optimize.FushionOptimize(originProgramDesc); } if (optimize) { program.optimizeProgram->Description("optimize: "); @@ -276,14 +275,12 @@ Executor::Executor(const framework::Program p, int batch_size, } else { InitMemory(); } - } template void Executor::LoadMemory(const framework::VarDesc var_desc, framework::LoDTensor *tensor, const std::string &file_path, char *data) { - // 1. version uint32_t version = *(uint32_t *)data; data += sizeof(uint32_t); @@ -383,7 +380,8 @@ void Executor::InitMemory() { continue; } - char *origin_data = Get_binary_data(program_.model_path + "/" + var_desc->Name()); + char *origin_data = + Get_binary_data(program_.model_path + "/" + var_desc->Name()); LoadMemory(*var_desc, tensor, program_.model_path + "/" + var_desc->Name(), origin_data); delete origin_data; @@ -399,7 +397,7 @@ void Executor::InitMemory() { } template -void Executor::InitCombineMemory(){ +void Executor::InitCombineMemory() { char *origin_data = Get_binary_data(program_.para_path); for (const auto &block : to_predict_program_->Blocks()) { diff --git a/src/io/io.h b/src/io/io.h index 9d26a4c7b5..f89ccc8b2e 100644 --- a/src/io/io.h +++ b/src/io/io.h @@ -63,7 +63,8 @@ class Executor { void InitMemory(); void LoadMemory(const framework::VarDesc var_desc, - framework::LoDTensor *tensor, const std::string &file_path, char *data); + framework::LoDTensor *tensor, const std::string &file_path, + char *data); void InitCombineMemory(); framework::Program program_; int batch_size_ = 1; diff --git a/test/framework/test_load.cpp b/test/framework/test_load.cpp index 6c91c4450f..2300f05c99 100644 --- a/test/framework/test_load.cpp +++ b/test/framework/test_load.cpp @@ -20,7 +20,8 @@ int main() { // ../../../test/models/googlenet // ../../../test/models/mobilenet auto program = loader.Load(g_resnet, true); - loader.Load(g_googlenet_combine + "/model", g_googlenet_combine + "/params", true); + loader.Load(g_googlenet_combine + "/model", g_googlenet_combine + "/params", + true); program.originProgram->Description("program desc: "); return 0; diff --git a/test/net/test_googlenet.cpp b/test/net/test_googlenet.cpp index 84114e8418..210f9643a1 100644 --- a/test/net/test_googlenet.cpp +++ b/test/net/test_googlenet.cpp @@ -22,8 +22,8 @@ int main() { auto time1 = time(); auto program = loader.Load(g_googlenet, optimize); -// auto program = loader.Load(g_googlenet_combine + "/model", -// g_googlenet_combine + "/params", optimize); + // auto program = loader.Load(g_googlenet_combine + "/model", + // g_googlenet_combine + "/params", optimize); auto time2 = time(); DLOG << "load cost :" << time_diff(time1, time2) << "ms\n"; paddle_mobile::Executor executor(program, 1, optimize); -- GitLab