Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
e4791d88
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e4791d88
编写于
11月 25, 2021
作者:
X
xiongkun
提交者:
GitHub
11月 25, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix test rnn memory helper op (#37474)
* clear LoDTensorArray * fix bugs * fix * fix gpu
上级
81861f69
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
17 addition
and
7 deletion
+17
-7
paddle/fluid/framework/new_executor/interpretercore.cc
paddle/fluid/framework/new_executor/interpretercore.cc
+1
-3
paddle/fluid/framework/new_executor/interpretercore_garbage_collector.cc
...amework/new_executor/interpretercore_garbage_collector.cc
+1
-0
paddle/fluid/framework/new_executor/interpretercore_util.cc
paddle/fluid/framework/new_executor/interpretercore_util.cc
+1
-0
paddle/fluid/operators/rnn_memory_helper_op.cc
paddle/fluid/operators/rnn_memory_helper_op.cc
+5
-1
paddle/fluid/operators/sum_op.h
paddle/fluid/operators/sum_op.h
+9
-3
未找到文件。
paddle/fluid/framework/new_executor/interpretercore.cc
浏览文件 @
e4791d88
...
...
@@ -343,7 +343,6 @@ void InterpreterCore::RunInstruction(const Instruction& instr_node) {
Scope
*
local_scope
=
create_local_scope_
?
global_scope_
->
GetMutableLocalScope
()
:
global_scope_
->
GetMutableScope
();
auto
op_with_kernel
=
dynamic_cast
<
const
framework
::
OperatorWithKernel
*>
(
op
);
{
platform
::
RecordEvent
infershape_event
(
"InferShape"
);
...
...
@@ -354,8 +353,7 @@ void InterpreterCore::RunInstruction(const Instruction& instr_node) {
if
(
op_with_kernel
!=
nullptr
&&
FLAGS_new_executor_use_inplace
)
{
// TODO(xiongkun03) Does operator
// base support
// inplace ?
// base support inplace ?
for
(
auto
&
pair
:
instr_node
.
InplaceInfo
())
{
const
auto
&
in
=
paddle
::
framework
::
details
::
GetTensorFromVar
(
pair
.
first
);
auto
*
out
=
...
...
paddle/fluid/framework/new_executor/interpretercore_garbage_collector.cc
浏览文件 @
e4791d88
...
...
@@ -79,6 +79,7 @@ void InterpreterCoreGarbageCollector::Add(paddle::framework::Variable* var,
for
(
auto
&
t
:
*
tensor_arr
)
{
Add
(
t
.
MoveMemoryHolder
(),
event
,
ctx
);
}
tensor_arr
->
clear
();
}
else
if
(
var
->
IsType
<
std
::
vector
<
Scope
*>>
())
{
// NOTE(@xiongkun03) conditional_op / while_op will create a STEP_SCOPE
// refer to executor.cc to see what old garbage collector does.
...
...
paddle/fluid/framework/new_executor/interpretercore_util.cc
浏览文件 @
e4791d88
...
...
@@ -411,6 +411,7 @@ void build_op_func_list(const platform::Place& place,
for
(
auto
&
t
:
*
lod_tensor_arr
)
{
garbages
->
emplace_back
(
t
.
MoveMemoryHolder
());
}
lod_tensor_arr
->
clear
();
}
else
{
PADDLE_THROW
(
platform
::
errors
::
Unimplemented
(
"Type %s of variable %s is not supported eager deletion."
,
...
...
paddle/fluid/operators/rnn_memory_helper_op.cc
浏览文件 @
e4791d88
...
...
@@ -109,7 +109,11 @@ class RNNMemoryHelperGradOp : public framework::OperatorBase {
platform
::
DeviceContextPool
&
pool
=
platform
::
DeviceContextPool
::
Instance
();
auto
&
dev_ctx
=
*
pool
.
Get
(
dev_place
);
if
(
out_grad_var
==
nullptr
)
{
// NOTE(xiongkun03): In standalone executor, after each run, the
// var.tensor.holder will be delete instead of variable. So we need exam the
// IsInitialized().
if
(
out_grad_var
==
nullptr
||
!
out_grad_var
->
Get
<
framework
::
LoDTensor
>
().
IsInitialized
())
{
VLOG
(
5
)
<<
"Using fill constant 0 as starting gradient"
;
auto
in_var_name
=
Input
(
"X"
);
auto
*
in_var
=
scope
.
FindVar
(
in_var_name
);
...
...
paddle/fluid/operators/sum_op.h
浏览文件 @
e4791d88
...
...
@@ -129,6 +129,7 @@ template <typename DeviceContext, typename T>
class
SumKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
VLOG
(
10
)
<<
"start sum kernel"
;
auto
in_vars
=
context
.
MultiInputVar
(
"X"
);
size_t
in_num
=
in_vars
.
size
();
auto
out_var
=
context
.
OutputVar
(
"Out"
);
...
...
@@ -138,7 +139,8 @@ class SumKernel : public framework::OpKernel<T> {
if
(
out_var
->
IsType
<
framework
::
LoDTensor
>
())
{
auto
*
out
=
out_var
->
GetMutable
<
framework
::
LoDTensor
>
();
auto
*
out_ptr
=
out
->
mutable_data
<
T
>
(
context
.
GetPlace
());
if
(
in_num
>=
1
&&
in_vars
[
0
]
->
IsType
<
framework
::
LoDTensor
>
())
{
if
(
in_num
>=
1
&&
in_vars
[
0
]
->
IsType
<
framework
::
LoDTensor
>
()
&&
in_vars
[
0
]
->
Get
<
framework
::
LoDTensor
>
().
IsInitialized
())
{
auto
&
in_0_tensor
=
in_vars
[
0
]
->
Get
<
framework
::
LoDTensor
>
();
if
(
in_0_tensor
.
numel
()
>
0
)
{
in_place
=
(
in_0_tensor
.
data
<
T
>
()
==
out_ptr
);
...
...
@@ -151,7 +153,9 @@ class SumKernel : public framework::OpKernel<T> {
int
start
=
in_place
?
1
:
0
;
if
(
!
in_place
)
{
if
((
in_num
>=
2
)
&&
in_vars
[
0
]
->
IsType
<
framework
::
LoDTensor
>
()
&&
in_vars
[
1
]
->
IsType
<
framework
::
LoDTensor
>
())
{
in_vars
[
1
]
->
IsType
<
framework
::
LoDTensor
>
()
&&
in_vars
[
0
]
->
Get
<
framework
::
LoDTensor
>
().
IsInitialized
()
&&
in_vars
[
1
]
->
Get
<
framework
::
LoDTensor
>
().
IsInitialized
())
{
auto
&
in_0
=
in_vars
[
0
]
->
Get
<
framework
::
LoDTensor
>
();
auto
&
in_1
=
in_vars
[
1
]
->
Get
<
framework
::
LoDTensor
>
();
if
(
in_0
.
numel
()
&&
in_1
.
numel
())
{
...
...
@@ -162,6 +166,7 @@ class SumKernel : public framework::OpKernel<T> {
}
}
if
(
start
!=
2
)
{
VLOG
(
10
)
<<
"Fill with constant = 0 in sum kernel."
;
math
::
SetConstant
<
DeviceContext
,
T
>
constant_functor
;
constant_functor
(
context
.
template
device_context
<
DeviceContext
>(),
out
,
static_cast
<
T
>
(
0
));
...
...
@@ -173,7 +178,7 @@ class SumKernel : public framework::OpKernel<T> {
for
(
size_t
i
=
start
;
i
<
in_num
;
i
++
)
{
if
(
in_vars
[
i
]
->
IsType
<
framework
::
LoDTensor
>
())
{
auto
&
in_t
=
in_vars
[
i
]
->
Get
<
framework
::
LoDTensor
>
();
if
(
in_t
.
numel
()
==
0
)
{
if
(
!
in_t
.
IsInitialized
()
||
in_t
.
numel
()
==
0
)
{
continue
;
}
auto
in
=
EigenVector
<
T
>::
Flatten
(
in_t
);
...
...
@@ -200,6 +205,7 @@ class SumKernel : public framework::OpKernel<T> {
"unsupport type: %s."
,
framework
::
ToTypeName
(
out_var
->
Type
())));
}
VLOG
(
10
)
<<
"end sum kernel"
;
}
};
}
// namespace operators
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录