From 4f366be4e298db78c7438f60d72fddf39b2b6ccc Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Sat, 10 Jun 2017 21:23:02 +0800 Subject: [PATCH] clang format --- go/pserver/cclient/test/main.c | 2 +- go/pserver/cclient/test/test_cclient.c | 4 ++-- go/pserver/optimizer.c | 6 +++--- paddle/trainer/NewRemoteParameterUpdater.h | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/go/pserver/cclient/test/main.c b/go/pserver/cclient/test/main.c index a074808b16a..72ec3590768 100644 --- a/go/pserver/cclient/test/main.c +++ b/go/pserver/cclient/test/main.c @@ -41,7 +41,7 @@ retry: unsigned char content[] = {0x00, 0x11, 0x22}; paddle_gradient** grads = - (paddle_gradient**)malloc(sizeof(paddle_gradient*) * 2); + (paddle_gradient**)malloc(sizeof(paddle_gradient*) * 2); grads[0] = (paddle_gradient*)malloc(sizeof(paddle_gradient)); grads[0]->name = "param_a"; grads[0]->content = content; diff --git a/go/pserver/cclient/test/test_cclient.c b/go/pserver/cclient/test/test_cclient.c index 4d6fca29fbe..82cef386d75 100644 --- a/go/pserver/cclient/test/test_cclient.c +++ b/go/pserver/cclient/test/test_cclient.c @@ -20,8 +20,8 @@ void print_parameter(paddle_gradient* param) { printf("name: %s\n", param->name); printf("content_len: %d\n", param->content_len); printf("content_type: %d\n", param->element_type); - for (int i = 0; i < param->content_len/sizeof(real); ++i) { - printf("%f ", ((float *)param->content)[i]); + for (int i = 0; i < param->content_len / sizeof(real); ++i) { + printf("%f ", ((float*)param->content)[i]); } printf("\n\n"); } diff --git a/go/pserver/optimizer.c b/go/pserver/optimizer.c index 5d0b1017ce3..47fe1efbf59 100644 --- a/go/pserver/optimizer.c +++ b/go/pserver/optimizer.c @@ -33,10 +33,10 @@ int update_SGD(void* optimizer, int num_bytes) { SGD_optimizer* o = (SGD_optimizer*)optimizer; // TODO(a simple SGD implement) - float* parameter = (float *)buffer; - float* grad = (float *)gradient; + float* parameter = (float*)buffer; + float* grad = (float*)gradient; - for(int i = 0; i < num_bytes/sizeof(float); ++i) { + for (int i = 0; i < num_bytes / sizeof(float); ++i) { parameter[i] -= o->learning_rate * grad[i]; } return 0; diff --git a/paddle/trainer/NewRemoteParameterUpdater.h b/paddle/trainer/NewRemoteParameterUpdater.h index db9b44af194..b7c0425982b 100644 --- a/paddle/trainer/NewRemoteParameterUpdater.h +++ b/paddle/trainer/NewRemoteParameterUpdater.h @@ -89,7 +89,8 @@ private: new_params[i]->name = (char*)param->getName().c_str(); new_params[i]->content = (unsigned char*)(param->getBuf(type).get()->getData()); - new_params[i]->content_len = (int)param->getBuf(type).get()->getSize() * sizeof(real); + new_params[i]->content_len = + (int)param->getBuf(type).get()->getSize() * sizeof(real); } return new_params; } -- GitLab