Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
1a02369a
P
Paddle
项目概览
Crayon鑫
/
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看板
提交
1a02369a
编写于
12月 30, 2017
作者:
H
hedaoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add releaseOutput interface for release the output memory of the middle layer.
上级
a096c58e
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
47 addition
and
0 deletion
+47
-0
paddle/gserver/gradientmachines/GradientMachine.h
paddle/gserver/gradientmachines/GradientMachine.h
+7
-0
paddle/gserver/gradientmachines/NeuralNetwork.cpp
paddle/gserver/gradientmachines/NeuralNetwork.cpp
+32
-0
paddle/gserver/gradientmachines/NeuralNetwork.h
paddle/gserver/gradientmachines/NeuralNetwork.h
+8
-0
未找到文件。
paddle/gserver/gradientmachines/GradientMachine.h
浏览文件 @
1a02369a
...
@@ -233,6 +233,13 @@ public:
...
@@ -233,6 +233,13 @@ public:
(
void
)
numProcessed
;
(
void
)
numProcessed
;
}
}
/**
* @brief Release the middle layer's output memory.
*
* @note This function is used for memory optimization in inference.
*/
virtual
void
releaseOutput
()
{}
protected:
protected:
virtual
void
onLoadParameter
()
{}
virtual
void
onLoadParameter
()
{}
...
...
paddle/gserver/gradientmachines/NeuralNetwork.cpp
浏览文件 @
1a02369a
...
@@ -187,6 +187,31 @@ void NeuralNetwork::init(const ModelConfig& config,
...
@@ -187,6 +187,31 @@ void NeuralNetwork::init(const ModelConfig& config,
CHECK
(
it
!=
layerMap_
.
end
());
CHECK
(
it
!=
layerMap_
.
end
());
outputLayers_
.
push_back
(
it
->
second
);
outputLayers_
.
push_back
(
it
->
second
);
}
}
for
(
const
auto
&
layer
:
layers_
)
{
const
auto
name
&
=
layer
->
getName
();
bool
isMiddleLayer
=
true
;
// if data layer
for
(
const
auto
&
dataLayer
:
dataLayers_
)
{
if
(
name
==
dataLayer
->
getName
())
{
isMiddleLayer
=
false
;
break
;
}
}
// if output layer
for
(
const
auto
&
dataLayer
:
outputLayers_
)
{
if
(
name
==
dataLayer
->
getName
())
{
isMiddleLayer
=
false
;
break
;
}
}
if
(
isMiddleLayer
)
{
middleLayers_
.
push_back
(
layer
);
}
}
}
}
void
NeuralNetwork
::
connect
(
LayerPtr
agentLayer
,
void
NeuralNetwork
::
connect
(
LayerPtr
agentLayer
,
...
@@ -327,6 +352,13 @@ void NeuralNetwork::onPassEnd() {
...
@@ -327,6 +352,13 @@ void NeuralNetwork::onPassEnd() {
}
}
}
}
void
NeuralNetwork
::
releaseOutput
()
{
for
(
auto
&
layer
:
middleLayers_
)
{
Argument
&
arg
=
layer
->
getOutput
();
arg
.
value
.
reset
();
}
}
#ifndef PADDLE_MOBILE_INFERENCE
#ifndef PADDLE_MOBILE_INFERENCE
class
CombinedEvaluator
:
public
Evaluator
{
class
CombinedEvaluator
:
public
Evaluator
{
...
...
paddle/gserver/gradientmachines/NeuralNetwork.h
浏览文件 @
1a02369a
...
@@ -137,6 +137,13 @@ public:
...
@@ -137,6 +137,13 @@ public:
/// some finish work, like convert the weight format of MKLDNNLayers
/// some finish work, like convert the weight format of MKLDNNLayers
void
finish
();
void
finish
();
/**
* @brief Release the middle layer's output memory.
*
* @note This function is used for memory optimization in inference.
*/
void
releaseOutput
();
protected:
protected:
/**
/**
* The constructor of NeuralNetwork.
* The constructor of NeuralNetwork.
...
@@ -158,6 +165,7 @@ protected:
...
@@ -158,6 +165,7 @@ protected:
std
::
vector
<
DataLayerPtr
>
dataLayers_
;
std
::
vector
<
DataLayerPtr
>
dataLayers_
;
std
::
vector
<
LayerPtr
>
outputLayers_
;
std
::
vector
<
LayerPtr
>
outputLayers_
;
std
::
vector
<
LayerPtr
>
middleLayers_
;
static
std
::
map
<
std
::
string
,
bool
>
dllInitMap
;
static
std
::
map
<
std
::
string
,
bool
>
dllInitMap
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录