Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
93cb2350
P
Paddle
项目概览
机器未来
/
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看板
未验证
提交
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 {
static_cast
<
phi
::
DenseTensor
*>
(
intermidiate_tensor_
.
impl
().
get
());
auto
&
inplace_version_counter
=
dense_tensor
->
InplaceVersionCounter
();
uint32_t
current_inplace_version
=
inplace_version_counter
.
CurrentVersion
();
uint32_t
wrapper_version_snapshot
=
inplace_version_snapshot_
;
uint32_t
tensor_version
=
inplace_version_counter
.
CurrentVersion
();
PADDLE_ENFORCE_EQ
(
current_inplace_version
,
inplace_version_snapshot_
,
tensor_version
,
wrapper_version_snapshot
,
paddle
::
platform
::
errors
::
PermissionDenied
(
"Tensor '%s' used in gradient computation has been "
"modified by an inplace operation. "
...
...
@@ -132,14 +132,14 @@ class TensorWrapper {
"Please fix your code to void calling an inplace operator "
"after using the Tensor which will used in gradient "
"computation."
,
intermidiate_tensor_
.
name
(),
current_inplace
_version
,
inplace_version_snapshot_
));
VLOG
(
6
)
<<
" The
inplace_version_snapshot_
of Tensor '"
intermidiate_tensor_
.
name
(),
tensor
_version
,
wrapper_version_snapshot
));
VLOG
(
6
)
<<
" The
wrapper_version_snapshot
of Tensor '"
<<
intermidiate_tensor_
.
name
()
<<
"' is [ "
<<
inplace_version_snapshot_
<<
" ]"
;
VLOG
(
6
)
<<
" The
current_inplace
_version of Tensor '"
<<
intermidiate_tensor_
.
name
()
<<
"' is [ "
<<
current_inplace_version
<<
" ]"
;
<<
wrapper_version_snapshot
<<
" ]"
;
VLOG
(
6
)
<<
" The
tensor
_version of Tensor '"
<<
intermidiate_tensor_
.
name
()
<<
"' is [ "
<<
tensor_version
<<
" ]"
;
}
}
...
...
python/paddle/fluid/tests/unittests/test_inplace.py
浏览文件 @
93cb2350
...
...
@@ -61,18 +61,11 @@ class TestInplace(unittest.TestCase):
var_d
=
var_b
**
2
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
(
RuntimeError
,
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
format
(
1
,
0
)):
loss
.
backward
()
with
self
.
assertRaisesRegexp
(
RuntimeError
,
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
format
(
1
,
0
)):
loss
.
backward
()
def
test_backward_error
(
self
):
with
_test_eager_guard
():
...
...
@@ -203,18 +196,11 @@ class TestDygraphInplace(unittest.TestCase):
self
.
inplace_api_processing
(
var_b
)
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
(
RuntimeError
,
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
format
(
1
,
0
)):
loss
.
backward
()
with
self
.
assertRaisesRegexp
(
RuntimeError
,
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
format
(
1
,
0
)):
loss
.
backward
()
def
test_backward_error
(
self
):
with
_test_eager_guard
():
...
...
python/paddle/fluid/tests/unittests/test_pylayer_op.py
浏览文件 @
93cb2350
...
...
@@ -487,7 +487,7 @@ class TestPyLayer(unittest.TestCase):
z
=
layer
(
data
)
with
self
.
assertRaisesRegexp
(
RuntimeError
,
"received
current_inplace_version:{} != inplace_version_snapshot_
:{}"
.
"received
tensor_version:{} != wrapper_version_snapshot
:{}"
.
format
(
1
,
0
)):
z
.
backward
()
...
...
python/paddle/fluid/tests/unittests/test_view_op_reuse_allocation.py
浏览文件 @
93cb2350
...
...
@@ -91,18 +91,11 @@ class TestDygraphViewReuseAllocation(unittest.TestCase):
view_var_b
[
0
]
=
2.
# var_b is modified inplace
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
(
RuntimeError
,
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
format
(
1
,
0
)):
loss
.
backward
()
with
self
.
assertRaisesRegexp
(
RuntimeError
,
"received tensor_version:{} != wrapper_version_snapshot:{}"
.
format
(
1
,
0
)):
loss
.
backward
()
def
test_backward_error
(
self
):
with
_test_eager_guard
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录