提交 4f366be4 编写于 作者: Q qiaolongfei

clang format

上级 39d0b3de
......@@ -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;
......
......@@ -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");
}
......
......@@ -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;
......
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册