Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
4f1f7e90
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4f1f7e90
编写于
8月 10, 2017
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete c-api interface, paddle_gradient_machine_load_parameter_from_buffer, and
related codes in Paddle core.
上级
9dccdd77
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
18 addition
and
90 deletion
+18
-90
paddle/capi/gradient_machine.cpp
paddle/capi/gradient_machine.cpp
+0
-9
paddle/capi/gradient_machine.h
paddle/capi/gradient_machine.h
+0
-9
paddle/gserver/gradientmachines/GradientMachine.cpp
paddle/gserver/gradientmachines/GradientMachine.cpp
+0
-43
paddle/gserver/gradientmachines/GradientMachine.h
paddle/gserver/gradientmachines/GradientMachine.h
+0
-2
paddle/parameter/Parameter.cpp
paddle/parameter/Parameter.cpp
+18
-22
paddle/parameter/Parameter.h
paddle/parameter/Parameter.h
+0
-5
未找到文件。
paddle/capi/gradient_machine.cpp
浏览文件 @
4f1f7e90
...
...
@@ -93,15 +93,6 @@ paddle_error paddle_gradient_machine_load_parameter_from_disk(
return
kPD_NO_ERROR
;
}
paddle_error
paddle_gradient_machine_load_parameter_from_buffer
(
paddle_gradient_machine
machine
,
const
char
*
buf
,
uint64_t
length
)
{
auto
m
=
cast
(
machine
);
if
(
m
==
nullptr
||
buf
==
nullptr
||
m
->
machine
==
nullptr
)
return
kPD_NULLPTR
;
m
->
machine
->
loadParameters
(
buf
,
length
);
return
kPD_NO_ERROR
;
}
paddle_error
paddle_gradient_machine_forward
(
paddle_gradient_machine
machine
,
paddle_arguments
inArgs
,
paddle_arguments
outArgs
,
...
...
paddle/capi/gradient_machine.h
浏览文件 @
4f1f7e90
...
...
@@ -57,15 +57,6 @@ paddle_gradient_machine_create_for_inference_with_parameters(
PD_API
paddle_error
paddle_gradient_machine_load_parameter_from_disk
(
paddle_gradient_machine
machine
,
const
char
*
path
);
/**
* @brief Load parameter from buffer.
* @param machine Gradient Machine.
* @param buffer containing all parameters.
* @return paddle_error
*/
PD_API
paddle_error
paddle_gradient_machine_load_parameter_from_buffer
(
paddle_gradient_machine
machine
,
const
char
*
buf
,
uint64_t
length
);
/**
* @brief Forward a gradient machine
* @param machine Gradient machine
...
...
paddle/gserver/gradientmachines/GradientMachine.cpp
浏览文件 @
4f1f7e90
...
...
@@ -14,7 +14,6 @@ limitations under the License. */
#include "GradientMachine.h"
#include <string.h>
#include <fstream>
#include "paddle/utils/Logging.h"
...
...
@@ -82,48 +81,6 @@ void GradientMachine::loadParameters(const std::string& dir) {
}
}
void
GradientMachine
::
loadParameters
(
const
char
*
buf
,
uint64_t
length
)
{
LOG
(
INFO
)
<<
"Loading parameter from pre-load buffer"
;
CHECK_NOTNULL
(
buf
);
CHECK_GE
(
length
,
static_cast
<
uint64_t
>
(
sizeof
(
uint64_t
)));
uint64_t
numFiles
=
0
;
memcpy
(
&
numFiles
,
buf
,
sizeof
(
uint64_t
));
uint64_t
position
=
sizeof
(
uint64_t
);
LOG
(
INFO
)
<<
"numFiles: "
<<
numFiles
<<
", position: "
<<
position
;
std
::
map
<
std
::
string
,
char
*>
offsets
;
std
::
map
<
std
::
string
,
uint64_t
>
lengths
;
for
(
uint64_t
i
=
0
;
i
<
numFiles
;
i
++
)
{
std
::
string
filename
(
buf
+
position
);
position
+=
filename
.
size
()
+
1
;
LOG
(
INFO
)
<<
"filename: "
<<
filename
<<
", position: "
<<
position
;
uint64_t
size
=
0
;
memcpy
(
&
size
,
buf
+
position
,
sizeof
(
uint64_t
));
position
+=
sizeof
(
uint64_t
);
offsets
[
filename
]
=
const_cast
<
char
*>
(
buf
+
position
);
lengths
[
filename
]
=
size
;
position
+=
size
;
CHECK_GE
(
length
,
position
);
}
CHECK_GE
(
offsets
.
size
(),
parameters_
.
size
());
for
(
auto
&
para
:
parameters_
)
{
std
::
string
filename
=
para
->
getName
();
if
(
para
->
isFullSize
())
{
if
(
offsets
.
end
()
==
offsets
.
find
(
filename
))
{
para
->
loadMiss
(
filename
);
}
else
{
std
::
istringstream
stream
(
std
::
string
(
offsets
[
filename
],
lengths
[
filename
]));
para
->
load
(
stream
);
}
}
}
}
void
GradientMachine
::
randParameters
()
{
LOG
(
INFO
)
<<
"Initing parameters.."
;
...
...
paddle/gserver/gradientmachines/GradientMachine.h
浏览文件 @
4f1f7e90
...
...
@@ -221,8 +221,6 @@ public:
void
loadParameters
(
const
std
::
string
&
dir
);
void
loadParameters
(
const
char
*
buf
,
uint64_t
length
);
void
randParameters
();
virtual
void
getStats
(
real
&
cost
,
int64_t
&
numProcessed
)
{
...
...
paddle/parameter/Parameter.cpp
浏览文件 @
4f1f7e90
...
...
@@ -314,31 +314,27 @@ bool Parameter::save(std::ostream& s) const {
/**
* Load parameter value from a file
*/
bool
Parameter
::
loadMiss
(
const
std
::
string
&
filename
)
{
LOG
(
INFO
)
<<
"missing parameters ["
<<
filename
<<
"] while loading model."
;
if
(
kMissParameterFail
==
FLAGS_load_missing_parameter_strategy
)
{
LOG
(
FATAL
)
<<
getName
()
<<
" missing, not allowed."
;
return
false
;
}
if
(
kMissParameterRand
==
FLAGS_load_missing_parameter_strategy
)
{
LOG
(
INFO
)
<<
getName
()
<<
" missing, set to random."
;
randomize
();
return
true
;
}
if
(
kMissParameterZero
==
FLAGS_load_missing_parameter_strategy
)
{
LOG
(
INFO
)
<<
getName
()
<<
" missing, set to zero."
;
zeroMem
();
return
true
;
}
LOG
(
FATAL
)
<<
"unsupported load_missing_parameter_strategy: "
<<
FLAGS_load_missing_parameter_strategy
;
return
false
;
}
bool
Parameter
::
load
(
const
std
::
string
&
filename
)
{
std
::
ifstream
fs
(
filename
,
std
::
ios_base
::
binary
);
if
(
!
fs
)
{
loadMiss
(
filename
);
LOG
(
INFO
)
<<
"missing parameters ["
<<
filename
<<
"] while loading model."
;
if
(
kMissParameterFail
==
FLAGS_load_missing_parameter_strategy
)
{
LOG
(
FATAL
)
<<
getName
()
<<
" missing, not allowed."
;
return
false
;
}
if
(
kMissParameterRand
==
FLAGS_load_missing_parameter_strategy
)
{
LOG
(
INFO
)
<<
getName
()
<<
" missing, set to random."
;
randomize
();
return
true
;
}
if
(
kMissParameterZero
==
FLAGS_load_missing_parameter_strategy
)
{
LOG
(
INFO
)
<<
getName
()
<<
" missing, set to zero."
;
zeroMem
();
return
true
;
}
LOG
(
FATAL
)
<<
"unsupported load_missing_parameter_strategy: "
<<
FLAGS_load_missing_parameter_strategy
;
return
false
;
}
return
load
(
fs
);
}
...
...
paddle/parameter/Parameter.h
浏览文件 @
4f1f7e90
...
...
@@ -201,11 +201,6 @@ public:
*/
bool
save
(
std
::
ostream
&
s
)
const
;
/**
* Fill parameter when file is missed
*/
bool
loadMiss
(
const
std
::
string
&
filename
);
/**
* Load parameter value from a file
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录