Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
7ca77a90
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看板
未验证
提交
7ca77a90
编写于
3月 25, 2020
作者:
Z
Zeng Jinle
提交者:
GitHub
3月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add Tensor::IsSharedBufferWith method, test=develop (#23175)
上级
27870412
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
2 deletion
+6
-2
paddle/fluid/framework/details/share_tensor_buffer_functor.cc
...le/fluid/framework/details/share_tensor_buffer_functor.cc
+1
-1
paddle/fluid/framework/tensor.h
paddle/fluid/framework/tensor.h
+4
-0
paddle/fluid/operators/elementwise/elementwise_op_function.h
paddle/fluid/operators/elementwise/elementwise_op_function.h
+1
-1
未找到文件。
paddle/fluid/framework/details/share_tensor_buffer_functor.cc
浏览文件 @
7ca77a90
...
@@ -104,7 +104,7 @@ void ShareTensorBufferFunctor::operator()(Scope *exec_scope) {
...
@@ -104,7 +104,7 @@ void ShareTensorBufferFunctor::operator()(Scope *exec_scope) {
// If in_var is inplaced in the previous batch and we want to fetch
// If in_var is inplaced in the previous batch and we want to fetch
// in_var in the current batch, we have to reset memory of out_var
// in_var in the current batch, we have to reset memory of out_var
// to avoid wrong calculation result.
// to avoid wrong calculation result.
if
(
in_tensor
.
Holder
()
==
out_tensor
->
Holder
(
))
{
if
(
out_tensor
->
IsSharedBufferWith
(
in_tensor
))
{
VLOG
(
1
)
<<
"Clear "
<<
out_var_names_
[
i
]
VLOG
(
1
)
<<
"Clear "
<<
out_var_names_
[
i
]
<<
" because you may want to fetch an inplaced variable "
<<
" because you may want to fetch an inplaced variable "
<<
in_var_info
->
Name
()
<<
in_var_info
->
Name
()
...
...
paddle/fluid/framework/tensor.h
浏览文件 @
7ca77a90
...
@@ -160,6 +160,10 @@ class Tensor {
...
@@ -160,6 +160,10 @@ class Tensor {
offset_
=
tensor
.
offset_
;
offset_
=
tensor
.
offset_
;
}
}
bool
IsSharedBufferWith
(
const
Tensor
&
src
)
const
{
return
holder_
&&
holder_
==
src
.
Holder
();
}
const
std
::
shared_ptr
<
memory
::
Allocation
>&
Holder
()
const
{
return
holder_
;
}
const
std
::
shared_ptr
<
memory
::
Allocation
>&
Holder
()
const
{
return
holder_
;
}
size_t
offset
()
const
{
return
offset_
;
}
size_t
offset
()
const
{
return
offset_
;
}
...
...
paddle/fluid/operators/elementwise/elementwise_op_function.h
浏览文件 @
7ca77a90
...
@@ -1100,7 +1100,7 @@ void CommonElementwiseBroadcastBackward(
...
@@ -1100,7 +1100,7 @@ void CommonElementwiseBroadcastBackward(
// for inplace strategy. memset will make dx and dout clear and get wrong
// for inplace strategy. memset will make dx and dout clear and get wrong
// result.
// result.
if
(
dx
&&
d
out
.
Holder
()
==
dx
->
Holder
(
))
{
if
(
dx
&&
d
x
->
IsSharedBufferWith
(
dout
))
{
dx
->
clear
();
dx
->
clear
();
dx
->
mutable_data
<
T
>
(
x_dims
,
ctx
.
GetPlace
());
dx
->
mutable_data
<
T
>
(
x_dims
,
ctx
.
GetPlace
());
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录