commit
fb413508e2
@ -1,28 +1,48 @@
|
||||
| Github account | name |
|
||||
|---|---|
|
||||
| reyoung | Yang Yu |
|
||||
| backyes | Yan-Fei Wang |
|
||||
| beckett1124 | Bin Qi |
|
||||
| Canpio | Jia-Yi Feng |
|
||||
| chengxiaohua1105 | Xiao-Hua Cheng |
|
||||
| cxwangyi, yiwangbaidu, wangkuiyi | Yi Wang |
|
||||
| cxysteven | Xing-Yi Cheng |
|
||||
| dzhwinter | Zhi-Hong Dong |
|
||||
| emailweixu | Wei Xu |
|
||||
| gangliao | Gang Liao |
|
||||
| luotao01 | Tao Luo |
|
||||
| jacquesqiao | Long-Fei Qiao |
|
||||
| qingqing01 | Qing-Qing Dang |
|
||||
| gongweibao | Wei-Bao Gong |
|
||||
| Guo Sheng | Sheng Guo |
|
||||
| Haichao-Zhang | Hai-Chao Zhang |
|
||||
| hedaoyuan | Dao-Yuan He |
|
||||
| wangyang59 | Yang Wang |
|
||||
| helinwang | He-Lin Wang |
|
||||
| jacquesqiao | Long-Fei Qiao |
|
||||
| kuke | Yi-Bing Liu |
|
||||
| lcy-seso | Ying Cao |
|
||||
| lipeng-unisound | Peng Li |
|
||||
| liuyuan | Yuan Liu |
|
||||
| livc | Zhao Li |
|
||||
| llxxxll | Yong-Feng Liu |
|
||||
| luotao01 | Tao Luo |
|
||||
| lzhao4ever | Liang Zhao |
|
||||
| NHZlX | Zhao-Long Xing |
|
||||
| pakchoi | Chuan-Jiang Song |
|
||||
| pengli09 | Peng Li |
|
||||
| pkuyym | Ya-Ming Yang |
|
||||
| QiJune | Jun Qi |
|
||||
| qingqing01 | Qing-Qing Dang |
|
||||
| reyoung | Yang Yu |
|
||||
| Superjom | Chun-Wei Yan |
|
||||
| tianbingsz | Tian-Bing Xu |
|
||||
| cxwangyi, yiwangbaidu, wangkuiyi | Yi Wang |
|
||||
| typhoonzero | Yi Wu |
|
||||
| backyes | Yan-Fei Wang |
|
||||
| pengli09 | Peng Li |
|
||||
| livc | Zhao Li |
|
||||
| wanghaoshuang | Hao-Shuang Wang |
|
||||
| wangyang59 | Yang Wang |
|
||||
| wangzhen-nlp | Zhen Wang |
|
||||
| wen-bo-yang | Wen-Bo Yang |
|
||||
| wwhu | Wei-Wei Hu |
|
||||
| xinghai-sun | Xing-Hai Sun |
|
||||
| Xreki | Yi-Qun Liu |
|
||||
| xujun05 | Jun Xu |
|
||||
| xushaoyong | Shao-Yong Xu |
|
||||
| Yancey1989 | Xu Yan |
|
||||
| emailweixu | Wei Xu |
|
||||
| wen-bo-yang | Wen-Bo Yang |
|
||||
| helinwang | He-Lin Wang |
|
||||
| lcy-seso | Ying Cao |
|
||||
| Zrachel | Rui-Qing Zhang |
|
||||
| Haichao-Zhang | Hai-Chao Zhang |
|
||||
| gongweibao | Wei-Bao Gong |
|
||||
| lzhao4ever | Liang Zhao |
|
||||
| zhaopu7 | Pu Zhao |
|
||||
| zhouxiao-coder | Xiao Zhou |
|
||||
| lipeng-unisound | Peng Li |
|
||||
| Zrachel | Rui-Qing Zhang |
|
||||
|
@ -0,0 +1,2 @@
|
||||
vendor/
|
||||
.glide/
|
@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
add_subdirectory(pserver/client/c)
|
||||
add_subdirectory(cmd/pserver)
|
||||
add_subdirectory(cmd/master)
|
||||
add_subdirectory(master/c)
|
@ -0,0 +1,15 @@
|
||||
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
go_binary(master SRC master.go)
|
@ -0,0 +1,15 @@
|
||||
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
go_binary(pserver SRCS pserver.go)
|
@ -0,0 +1,61 @@
|
||||
hash: b8f18ce6784bd3fadd9fed0b8443e7b658234ea785ae1f220723ae2c1f652aa7
|
||||
updated: 2017-06-27T14:05:48.925262819+08:00
|
||||
imports:
|
||||
- name: github.com/coreos/etcd
|
||||
version: 61fc123e7a8b14a0a258aa3f5c4159861b1ec2e7
|
||||
subpackages:
|
||||
- auth/authpb
|
||||
- clientv3
|
||||
- clientv3/concurrency
|
||||
- etcdserver/api/v3rpc/rpctypes
|
||||
- etcdserver/etcdserverpb
|
||||
- mvcc/mvccpb
|
||||
- name: github.com/golang/protobuf
|
||||
version: 4bd1920723d7b7c925de087aa32e2187708897f7
|
||||
subpackages:
|
||||
- jsonpb
|
||||
- proto
|
||||
- name: github.com/golang/snappy
|
||||
version: 553a641470496b2327abcac10b36396bd98e45c9
|
||||
- name: github.com/namsral/flag
|
||||
version: 71ceffbeb0ba60fccc853971bb3ed4d7d90bfd04
|
||||
- name: github.com/PaddlePaddle/recordio
|
||||
version: edfb82af0739c84f241c87390ec5649c7b28c129
|
||||
- name: github.com/sirupsen/logrus
|
||||
version: 202f25545ea4cf9b191ff7f846df5d87c9382c2b
|
||||
- name: golang.org/x/net
|
||||
version: c8c74377599bd978aee1cf3b9b63a8634051cec2
|
||||
subpackages:
|
||||
- context
|
||||
- http2
|
||||
- http2/hpack
|
||||
- idna
|
||||
- internal/timeseries
|
||||
- lex/httplex
|
||||
- trace
|
||||
- name: golang.org/x/sys
|
||||
version: f7928cfef4d09d1b080aa2b6fd3ca9ba1567c733
|
||||
subpackages:
|
||||
- unix
|
||||
- name: golang.org/x/text
|
||||
version: 4e9ab9ee170f2a39bd66c92b3e0a47ff47a4bc77
|
||||
subpackages:
|
||||
- secure/bidirule
|
||||
- transform
|
||||
- unicode/bidi
|
||||
- unicode/norm
|
||||
- name: google.golang.org/grpc
|
||||
version: 8050b9cbc271307e5a716a9d782803d09b0d6f2d
|
||||
subpackages:
|
||||
- codes
|
||||
- credentials
|
||||
- grpclog
|
||||
- internal
|
||||
- keepalive
|
||||
- metadata
|
||||
- naming
|
||||
- peer
|
||||
- stats
|
||||
- tap
|
||||
- transport
|
||||
testImports: []
|
@ -0,0 +1,12 @@
|
||||
package: github.com/PaddlePaddle/Paddle/go
|
||||
import:
|
||||
- package: github.com/PaddlePaddle/recordio
|
||||
- package: github.com/coreos/etcd
|
||||
version: ^3.2.1
|
||||
subpackages:
|
||||
- clientv3
|
||||
- clientv3/concurrency
|
||||
- package: github.com/namsral/flag
|
||||
version: ^1.7.4-pre
|
||||
- package: github.com/sirupsen/logrus
|
||||
version: ^1.0.0
|
@ -1,3 +1 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
go_library(paddle_master SHARED)
|
||||
|
@ -1,3 +0,0 @@
|
||||
go_library(paddle_pserver_cclient STATIC)
|
||||
|
||||
add_subdirectory(test)
|
@ -1,117 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libpaddle_pserver_cclient.h"
|
||||
|
||||
typedef float real;
|
||||
|
||||
void fail() {
|
||||
// TODO(helin): fix: gtest using cmake is not working, using this
|
||||
// hacky way for now.
|
||||
printf("test failed.\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
void print_parameter(paddle_gradient* param) {
|
||||
if (param == NULL) {
|
||||
printf("param is NULL!!\n");
|
||||
} else {
|
||||
printf("==== parameter ====\n");
|
||||
printf("name: %s\n", param->name);
|
||||
printf("content_len: %d\n", param->content_len);
|
||||
printf("content_type: %d\n", param->element_type);
|
||||
int i;
|
||||
for (i = 0; i < param->content_len / (int)sizeof(real); ++i) {
|
||||
printf("%f ", ((float*)param->content)[i]);
|
||||
}
|
||||
printf("\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
char addr[] = "localhost:3000";
|
||||
paddle_pserver_client c = paddle_new_pserver_client(addr, 1);
|
||||
|
||||
char* names[] = {"param_a", "param_b"};
|
||||
|
||||
retry:
|
||||
printf("init parameter to pserver:\n");
|
||||
|
||||
real param_content1[] = {0.1, 0.2, 0.3};
|
||||
real param_content2[] = {0.4, 0.5, 0.6};
|
||||
paddle_parameter** params =
|
||||
(paddle_parameter**)malloc(sizeof(paddle_parameter*) * 2);
|
||||
params[0] = (paddle_parameter*)malloc(sizeof(paddle_parameter));
|
||||
params[0]->name = names[0];
|
||||
params[0]->content = (unsigned char*)param_content1;
|
||||
params[0]->content_len = 3 * sizeof(real);
|
||||
params[0]->element_type = PADDLE_ELEMENT_TYPE_FLOAT32;
|
||||
|
||||
params[1] = (paddle_parameter*)malloc(sizeof(paddle_parameter));
|
||||
params[1]->name = names[1];
|
||||
params[1]->content = (unsigned char*)param_content2;
|
||||
params[1]->content_len = 3 * sizeof(real);
|
||||
params[1]->element_type = PADDLE_ELEMENT_TYPE_INT32;
|
||||
|
||||
if (paddle_begin_init_params(c)) {
|
||||
if (paddle_init_param(c, *params[0], NULL, 0) != 0) {
|
||||
goto retry;
|
||||
}
|
||||
if (paddle_init_param(c, *params[1], NULL, 0) != 0) {
|
||||
goto retry;
|
||||
}
|
||||
if (paddle_finish_init_params(c) != 0) {
|
||||
goto retry;
|
||||
}
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
|
||||
printf("get inited parameters from pserver:\n");
|
||||
// get parameters again by reusing the allocated parameter buffers.
|
||||
if (paddle_get_params(c, params, 2) != 0) {
|
||||
fail();
|
||||
}
|
||||
print_parameter(params[0]);
|
||||
print_parameter(params[1]);
|
||||
|
||||
printf("send gradient to pserver:\n");
|
||||
real gradient_content1[] = {0.01, 0.02, 0.03};
|
||||
real gradinet_content2[] = {0.04, 0.05, 0.06};
|
||||
|
||||
paddle_gradient** grads =
|
||||
(paddle_gradient**)malloc(sizeof(paddle_gradient*) * 2);
|
||||
grads[0] = (paddle_gradient*)malloc(sizeof(paddle_gradient));
|
||||
grads[0]->name = names[0];
|
||||
grads[0]->content = (unsigned char*)gradient_content1;
|
||||
grads[0]->content_len = 3 * sizeof(real);
|
||||
grads[0]->element_type = PADDLE_ELEMENT_TYPE_FLOAT32;
|
||||
|
||||
grads[1] = (paddle_gradient*)malloc(sizeof(paddle_gradient));
|
||||
grads[1]->name = names[1];
|
||||
grads[1]->content = (unsigned char*)gradinet_content2;
|
||||
grads[1]->content_len = 3 * sizeof(real);
|
||||
grads[1]->element_type = PADDLE_ELEMENT_TYPE_INT32;
|
||||
|
||||
printf("print gradient sent to pserver:\n");
|
||||
print_parameter(grads[0]);
|
||||
print_parameter(grads[1]);
|
||||
|
||||
if (paddle_send_grads(c, grads, 2) != 0) {
|
||||
fail();
|
||||
}
|
||||
|
||||
printf("get updated parameters from pserver:\n");
|
||||
// get parameters again by reusing the allocated parameter buffers.
|
||||
if (paddle_get_params(c, params, 2) != 0) {
|
||||
fail();
|
||||
}
|
||||
print_parameter(params[0]);
|
||||
print_parameter(params[1]);
|
||||
|
||||
if (paddle_save_model(c, "/tmp/") != 0) {
|
||||
fail();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
cc_library(paddle_go_optimizer DEPS paddle_optimizer paddle_proto glog gflags protobuf)
|
||||
go_library(paddle_pserver_cclient STATIC DEPS paddle_go_optimizer)
|
||||
if(WITH_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
@ -1,3 +1,2 @@
|
||||
|
||||
cc_binary(main SRCS main.c DEPS paddle_pserver_cclient)
|
||||
cc_test(test_cclient SRCS test_cclient.c DEPS paddle_pserver_cclient)
|
||||
add_style_check_target(test_cclient test_cclient.c)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue