Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
93cb2350
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看板
未验证
提交
93cb2350
编写于
4月 01, 2022
作者:
P
pangyoki
提交者:
GitHub
4月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unify inplace_version checking log in new and old dygraph framework (#41209)
* change inplace_version checking log * fix
上级
c86e3a11
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
26 addition
and
47 deletion
+26
-47
paddle/fluid/eager/tensor_wrapper.h
paddle/fluid/eager/tensor_wrapper.h
+10
-10
python/paddle/fluid/tests/unittests/test_inplace.py
python/paddle/fluid/tests/unittests/test_inplace.py
+10
-24
python/paddle/fluid/tests/unittests/test_pylayer_op.py
python/paddle/fluid/tests/unittests/test_pylayer_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_view_op_reuse_allocation.py
...le/fluid/tests/unittests/test_view_op_reuse_allocation.py
+5
-12
未找到文件。
paddle/fluid/eager/tensor_wrapper.h
浏览文件 @
93cb2350
...
@@ -121,10 +121,10 @@ class TensorWrapper {
...
@@ -121,10 +121,10 @@ class TensorWrapper {
static_cast
<
phi
::
DenseTensor
*>
(
intermidiate_tensor_
.
impl
().
get
());
static_cast
<
phi
::
DenseTensor
*>
(
intermidiate_tensor_
.
impl
().
get
());
auto
&
inplace_version_counter
=
dense_tensor
->
InplaceVersionCounter
();
auto
&
inplace_version_counter
=
dense_tensor
->
InplaceVersionCounter
();
uint32_t
current_inplace_version
=
uint32_t
wrapper_version_snapshot
=
inplace_version_snapshot_
;
inplace_version_counter
.
CurrentVersion
();
uint32_t
tensor_version
=
inplace_version_counter
.
CurrentVersion
();
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
current_inplace_version
,
inplace_version_snapshot_
,
tensor_version
,
wrapper_version_snapshot
,
paddle
::
platform
::
errors
::
PermissionDenied
(
paddle
::
platform
::
errors
::
PermissionDenied
(
"Tensor '%s' used in gradient computation has been "
"Tensor '%s' used in gradient computation has been "
"modified by an inplace operation. "
"modified by an inplace operation. "
...
@@ -132,14 +132,14 @@ class TensorWrapper {
...
@@ -132,14 +132,14 @@ class TensorWrapper {
"Please fix your code to void calling an inplace operator "
"Please fix your code to void calling an inplace operator "
"after using the Tensor which will used in gradient "
"after using the Tensor which will used in gradient "
"computation."
,
"computation."
,
intermidiate_tensor_
.
name
(),
current_inplace
_version
,
intermidiate_tensor_
.
name
(),
tensor
_version
,
inplace_version_snapshot_
));
wrapper_version_snapshot
));
VLOG
(
6
)
<<
" The
inplace_version_snapshot_
of Tensor '"
VLOG
(
6
)
<<
" The
wrapper_version_snapshot
of Tensor '"
<<
intermidiate_tensor_
.
name
()
<<
"' is [ "
<<
intermidiate_tensor_
.
name
()
<<
"' is [ "
<<
inplace_version_snapshot_
<<
" ]"
;
<<
wrapper_version_snapshot
<<
" ]"
;
VLOG
(
6
)
<<
" The
current_inplace
_version of Tensor '"
VLOG
(
6
)
<<
" The
tensor
_version of Tensor '"
<<
intermidiate_tensor_
.
name
()
<<
"' is [ "
<<
intermidiate_tensor_
.
name
()
<<
"' is [ "
<<
tensor_version
<<
current_inplace_version
<<
" ]"
;
<<
" ]"
;
}
}
}
}
...
...
python/paddle/fluid/tests/unittests/test_inplace.py
浏览文件 @
93cb2350
...
@@ -61,13 +61,6 @@ class TestInplace(unittest.TestCase):
...
@@ -61,13 +61,6 @@ class TestInplace(unittest.TestCase):
var_d
=
var_b
**
2
var_d
=
var_b
**
2
loss
=
paddle
.
nn
.
functional
.
relu
(
var_c
+
var_d
)
loss
=
paddle
.
nn
.
functional
.
relu
(
var_c
+
var_d
)
if
in_dygraph_mode
():
with
self
.
assertRaisesRegexp
(
RuntimeError
,
"received current_inplace_version:{} != inplace_version_snapshot_:{}"
.
format
(
1
,
0
)):
loss
.
backward
()
else
:
with
self
.
assertRaisesRegexp
(
with
self
.
assertRaisesRegexp
(
RuntimeError
,
RuntimeError
,
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
...
@@ -203,13 +196,6 @@ class TestDygraphInplace(unittest.TestCase):
...
@@ -203,13 +196,6 @@ class TestDygraphInplace(unittest.TestCase):
self
.
inplace_api_processing
(
var_b
)
self
.
inplace_api_processing
(
var_b
)
loss
=
paddle
.
nn
.
functional
.
relu
(
var_c
)
loss
=
paddle
.
nn
.
functional
.
relu
(
var_c
)
if
in_dygraph_mode
():
with
self
.
assertRaisesRegexp
(
RuntimeError
,
"received current_inplace_version:{} != inplace_version_snapshot_:{}"
.
format
(
1
,
0
)):
loss
.
backward
()
else
:
with
self
.
assertRaisesRegexp
(
with
self
.
assertRaisesRegexp
(
RuntimeError
,
RuntimeError
,
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
...
...
python/paddle/fluid/tests/unittests/test_pylayer_op.py
浏览文件 @
93cb2350
...
@@ -487,7 +487,7 @@ class TestPyLayer(unittest.TestCase):
...
@@ -487,7 +487,7 @@ class TestPyLayer(unittest.TestCase):
z
=
layer
(
data
)
z
=
layer
(
data
)
with
self
.
assertRaisesRegexp
(
with
self
.
assertRaisesRegexp
(
RuntimeError
,
RuntimeError
,
"received
current_inplace_version:{} != inplace_version_snapshot_
:{}"
.
"received
tensor_version:{} != wrapper_version_snapshot
:{}"
.
format
(
1
,
0
)):
format
(
1
,
0
)):
z
.
backward
()
z
.
backward
()
...
...
python/paddle/fluid/tests/unittests/test_view_op_reuse_allocation.py
浏览文件 @
93cb2350
...
@@ -91,13 +91,6 @@ class TestDygraphViewReuseAllocation(unittest.TestCase):
...
@@ -91,13 +91,6 @@ class TestDygraphViewReuseAllocation(unittest.TestCase):
view_var_b
[
0
]
=
2.
# var_b is modified inplace
view_var_b
[
0
]
=
2.
# var_b is modified inplace
loss
=
paddle
.
nn
.
functional
.
relu
(
var_c
)
loss
=
paddle
.
nn
.
functional
.
relu
(
var_c
)
if
in_dygraph_mode
():
with
self
.
assertRaisesRegexp
(
RuntimeError
,
"received current_inplace_version:{} != inplace_version_snapshot_:{}"
.
format
(
1
,
0
)):
loss
.
backward
()
else
:
with
self
.
assertRaisesRegexp
(
with
self
.
assertRaisesRegexp
(
RuntimeError
,
RuntimeError
,
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录