Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
22b5a388
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
22b5a388
编写于
6月 13, 2017
作者:
H
Helin Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix according to comments
上级
0e71ab29
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
43 deletion
+29
-43
go/pserver/cclient/cclient.go
go/pserver/cclient/cclient.go
+29
-43
未找到文件。
go/pserver/cclient/cclient.go
浏览文件 @
22b5a388
...
...
@@ -20,6 +20,8 @@ typedef struct {
} paddle_parameter, paddle_gradient;
typedef int paddle_pserver_client;
#define PSERVER_ERROR -1
#define PSERVER_OK 0
*/
import
"C"
...
...
@@ -115,7 +117,7 @@ func paddle_begin_init_params(client C.paddle_pserver_client) C.int {
if
selected
:=
c
.
BeginInitParams
();
selected
{
return
1
}
return
0
return
C
.
PSERVER_OK
}
//export paddle_init_param
...
...
@@ -133,13 +135,13 @@ func paddle_init_param(client C.paddle_pserver_client, param C.paddle_parameter,
if
err
!=
nil
{
if
err
.
Error
()
==
pserver
.
AlreadyInitialized
{
log
.
Printf
(
"parameter %s already initialized, treat paddle_init_param as sucessful.
\n
"
,
name
)
return
0
return
C
.
PSERVER_OK
}
log
.
Println
(
err
)
return
-
1
return
C
.
PSERVER_ERROR
}
return
0
return
C
.
PSERVER_OK
}
//export paddle_finish_init_params
...
...
@@ -149,14 +151,14 @@ func paddle_finish_init_params(client C.paddle_pserver_client) C.int {
if
err
!=
nil
{
if
err
.
Error
()
==
pserver
.
AlreadyInitialized
{
log
.
Println
(
"parameters already initialized, treat paddle_finish_init_params as sucessful."
)
return
0
return
C
.
PSERVER_OK
}
log
.
Println
(
err
)
return
-
1
return
C
.
PSERVER_ERROR
}
return
0
return
C
.
PSERVER_OK
}
//export paddle_send_grads
...
...
@@ -174,10 +176,10 @@ func paddle_send_grads(client C.paddle_pserver_client, grads *C.paddle_gradient,
err
:=
c
.
SendGrads
(
gs
)
if
err
!=
nil
{
log
.
Println
(
err
)
return
-
1
return
C
.
PSERVER_ERROR
}
return
0
return
C
.
PSERVER_OK
}
//export paddle_get_params
...
...
@@ -191,42 +193,26 @@ func paddle_get_params(client C.paddle_pserver_client, dst **C.paddle_parameter,
ps
,
err
:=
c
.
GetParams
(
ns
)
if
err
!=
nil
{
log
.
Println
(
err
)
return
-
1
}
names
:=
func
()
(
string
,
string
)
{
retNames
:=
""
for
_
,
p
:=
range
ps
{
if
retNames
==
""
{
retNames
=
p
.
Name
}
else
{
retNames
=
", "
+
p
.
Name
}
}
requestedNames
:=
""
for
_
,
n
:=
range
ns
{
if
requestedNames
==
""
{
requestedNames
=
n
}
else
{
requestedNames
=
", "
+
n
}
}
return
requestedNames
,
retNames
return
C
.
PSERVER_ERROR
}
if
len
(
ps
)
!=
len
(
ns
)
{
requestedNames
,
retNames
:=
names
()
log
.
Printf
(
"pserver returned wrong number of parameters. Requested: %s, returned: %s.
\n
"
,
retNames
,
requestedNames
)
return
-
1
pn
:=
make
([]
string
,
len
(
ps
))
for
i
,
p
:=
range
ps
{
pn
[
i
]
=
p
.
Name
}
log
.
Printf
(
"pserver returned wrong number of parameters. Requested: %s, returned: %s.
\n
"
,
strings
.
Join
(
pn
,
", "
),
strings
.
Join
(
ns
,
", "
))
return
C
.
PSERVER_ERROR
}
for
i
:=
range
ps
{
if
ns
[
i
]
!=
ps
[
i
]
.
Name
{
requestedNames
,
retNames
:=
names
()
log
.
Printf
(
"pserver returned wrong parameters, or not in requested order. Requested: %s, returned: %s.
\n
"
,
retNames
,
requestedNames
)
return
-
1
pn
:=
make
([]
string
,
len
(
ps
))
for
i
,
p
:=
range
ps
{
pn
[
i
]
=
p
.
Name
}
log
.
Printf
(
"pserver returned wrong parameters, or not in requested order. Requested: %s, returned: %s.
\n
"
,
strings
.
Join
(
pn
,
", "
),
strings
.
Join
(
ns
,
", "
))
return
C
.
PSERVER_ERROR
}
}
...
...
@@ -236,12 +222,12 @@ func paddle_get_params(client C.paddle_pserver_client, dst **C.paddle_parameter,
if
unsafe
.
Pointer
(
param
)
==
nullPtr
{
log
.
Println
(
"must pre-allocate parameter."
)
return
-
1
return
C
.
PSERVER_ERROR
}
else
{
if
unsafe
.
Pointer
(
param
.
content
)
!=
nullPtr
{
if
int
(
param
.
content_len
)
!=
len
(
p
.
Content
)
{
log
.
Printf
(
"the pre-allocated content len does not match parameter content len. Pre-allocated len: %d, returned len: %d"
,
param
.
content_len
,
len
(
p
.
Content
))
return
-
1
return
C
.
PSERVER_ERROR
}
}
}
...
...
@@ -251,7 +237,7 @@ func paddle_get_params(client C.paddle_pserver_client, dst **C.paddle_parameter,
param
.
element_type
=
C
.
paddle_element_type
(
p
.
ElementType
)
}
return
0
return
C
.
PSERVER_OK
}
//export paddle_save_model
...
...
@@ -261,10 +247,10 @@ func paddle_save_model(client C.paddle_pserver_client, path *C.char) C.int {
err
:=
c
.
Save
(
p
)
if
err
!=
nil
{
log
.
Println
(
err
)
return
-
1
return
C
.
PSERVER_ERROR
}
return
0
return
C
.
PSERVER_OK
}
func
main
()
{}
// Required but ignored
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录