Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
caaaf2f0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
caaaf2f0
编写于
4月 19, 2022
作者:
Z
Zhanlue Yang
提交者:
GitHub
4月 19, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed performance issue regarding BackwardRun using add_final_state_dygraph (#41912)
上级
5c91010d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
12 addition
and
8 deletion
+12
-8
paddle/fluid/eager/auto_code_generator/final_state_generator/eager_gen.py
...er/auto_code_generator/final_state_generator/eager_gen.py
+0
-3
paddle/fluid/eager/backward.cc
paddle/fluid/eager/backward.cc
+2
-1
paddle/fluid/eager/grad_tensor_holder.cc
paddle/fluid/eager/grad_tensor_holder.cc
+8
-3
paddle/fluid/eager/grad_tensor_holder.h
paddle/fluid/eager/grad_tensor_holder.h
+2
-1
未找到文件。
paddle/fluid/eager/auto_code_generator/final_state_generator/eager_gen.py
浏览文件 @
caaaf2f0
...
@@ -1471,9 +1471,6 @@ class DygraphNodeGenerator(DygraphFunctionGeneratorBase):
...
@@ -1471,9 +1471,6 @@ class DygraphNodeGenerator(DygraphFunctionGeneratorBase):
grad_node_name
=
GetGradNodeName
(
forward_api_name
)
grad_node_name
=
GetGradNodeName
(
forward_api_name
)
if
len
(
grad_node_creation_str
)
==
0
:
grad_node_creation_str
=
f
"if(create_graph) VLOG(3) <<
\"
Higher order grad node for
{
grad_node_name
}
has not been implemented yet.
\"
;"
self
.
node_definition_str
=
GRAD_FUNCTION_TEMPLATE
.
format
(
self
.
node_definition_str
=
GRAD_FUNCTION_TEMPLATE
.
format
(
grad_node_name
,
fill_zero_str
,
get_grad_in_args_str
,
grad_node_name
,
grad_node_name
,
fill_zero_str
,
get_grad_in_args_str
,
grad_node_name
,
grad_function_call_str
,
get_outputs_str
,
inputs_autograd_meta_str
,
grad_function_call_str
,
get_outputs_str
,
inputs_autograd_meta_str
,
...
...
paddle/fluid/eager/backward.cc
浏览文件 @
caaaf2f0
...
@@ -766,7 +766,8 @@ std::vector<paddle::experimental::Tensor> RunBackward(
...
@@ -766,7 +766,8 @@ std::vector<paddle::experimental::Tensor> RunBackward(
<<
", rank: "
<<
edge_rank
.
second
;
<<
", rank: "
<<
edge_rank
.
second
;
node_input_buffers_dict
[
next_node
]
->
add
(
node_input_buffers_dict
[
next_node
]
->
add
(
edge_rank
.
first
,
edge_rank
.
second
,
grad_output_tensor
);
edge_rank
.
first
,
edge_rank
.
second
,
grad_output_tensor
,
create_graph
);
// Update queue
// Update queue
node_in_degree_map
[
next_node
]
--
;
node_in_degree_map
[
next_node
]
--
;
...
...
paddle/fluid/eager/grad_tensor_holder.cc
浏览文件 @
caaaf2f0
...
@@ -72,7 +72,8 @@ void GradTensorHolder::CopyValueFromTensor(
...
@@ -72,7 +72,8 @@ void GradTensorHolder::CopyValueFromTensor(
}
}
void
GradTensorHolder
::
add
(
size_t
slot_id
,
size_t
rank
,
void
GradTensorHolder
::
add
(
size_t
slot_id
,
size_t
rank
,
const
paddle
::
experimental
::
Tensor
&
t
)
{
const
paddle
::
experimental
::
Tensor
&
t
,
bool
create_graph
)
{
// TODO(jiabin): We need to deal with empty input_buffer with slot size not
// TODO(jiabin): We need to deal with empty input_buffer with slot size not
// empty;
// empty;
PADDLE_ENFORCE
(
slot_id
<
buffer_
.
size
(),
PADDLE_ENFORCE
(
slot_id
<
buffer_
.
size
(),
...
@@ -113,8 +114,12 @@ void GradTensorHolder::add(size_t slot_id, size_t rank,
...
@@ -113,8 +114,12 @@ void GradTensorHolder::add(size_t slot_id, size_t rank,
if
(
t
.
is_dense_tensor
())
{
if
(
t
.
is_dense_tensor
())
{
if
(
buffer_tensor
.
is_dense_tensor
())
{
if
(
buffer_tensor
.
is_dense_tensor
())
{
buffer_tensor
=
add_final_state_dygraph_function
(
t
,
buffer_tensor
);
if
(
create_graph
)
{
buffer_tensor
=
add_final_state_dygraph_function
(
t
,
buffer_tensor
);
}
else
{
paddle
::
imperative
::
TensorAdd
<
paddle
::
experimental
::
Tensor
>
(
t
,
&
buffer_tensor
);
}
}
else
{
}
else
{
// TODO(jiabin): Support Other TensorBase later
// TODO(jiabin): Support Other TensorBase later
// TODO(zhanlve): Replace SelectedRowsAddTensor with
// TODO(zhanlve): Replace SelectedRowsAddTensor with
...
...
paddle/fluid/eager/grad_tensor_holder.h
浏览文件 @
caaaf2f0
...
@@ -45,7 +45,8 @@ class GradTensorHolder {
...
@@ -45,7 +45,8 @@ class GradTensorHolder {
GradTensorHolder
&
operator
=
(
const
GradTensorHolder
&
other
)
=
default
;
GradTensorHolder
&
operator
=
(
const
GradTensorHolder
&
other
)
=
default
;
// Create new tensor and copy tensor->impl
// Create new tensor and copy tensor->impl
void
add
(
size_t
slot_id
,
size_t
rank
,
const
paddle
::
experimental
::
Tensor
&
t
);
void
add
(
size_t
slot_id
,
size_t
rank
,
const
paddle
::
experimental
::
Tensor
&
t
,
bool
create_graph
=
false
);
void
CopyValueFromTensor
(
size_t
slot_id
,
size_t
rank
,
void
CopyValueFromTensor
(
size_t
slot_id
,
size_t
rank
,
const
paddle
::
experimental
::
Tensor
&
t
,
const
paddle
::
experimental
::
Tensor
&
t
,
bool
fill_one
=
false
);
bool
fill_one
=
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录