Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
359e1f23
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
359e1f23
编写于
9月 01, 2020
作者:
B
buxue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check user define bprop when there is parameter in nested network
上级
981bfbfa
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
9 addition
and
9 deletion
+9
-9
mindspore/ccsrc/pipeline/pynative/pynative_execute.cc
mindspore/ccsrc/pipeline/pynative/pynative_execute.cc
+5
-0
mindspore/ccsrc/pybind_api/ir/primitive_py.cc
mindspore/ccsrc/pybind_api/ir/primitive_py.cc
+1
-1
mindspore/ccsrc/vm/vm.cc
mindspore/ccsrc/vm/vm.cc
+1
-1
tests/ut/python/ops/test_ops.py
tests/ut/python/ops/test_ops.py
+1
-6
tests/ut/python/pynative_mode/test_user_define_bprop_check.py
...s/ut/python/pynative_mode/test_user_define_bprop_check.py
+1
-1
未找到文件。
mindspore/ccsrc/pipeline/pynative/pynative_execute.cc
浏览文件 @
359e1f23
...
...
@@ -1182,6 +1182,11 @@ void PynativeExecutor::EndGraphByOutId(const std::string &out_id, const py::obje
resource_
->
manager
()
->
AddFuncGraph
(
curr_g_
);
// custom bprop debug
if
(
py
::
hasattr
(
cell
,
parse
::
CUSTOM_BPROP_NAME
))
{
size_t
par_number
=
py
::
tuple
(
parse
::
python_adapter
::
CallPyObjMethod
(
cell
,
"get_parameters"
)).
size
();
if
(
par_number
>
0
)
{
MS_LOG
(
EXCEPTION
)
<<
"When user defines the net bprop, there are "
<<
par_number
<<
" parameters that is not supported in the net."
;
}
MS_LOG
(
DEBUG
)
<<
"Use cell custom bprop function."
;
FuncGraphPtr
bprop_graph
=
parse
::
ConvertToBpropCut
(
cell
);
if
(
bprop_graph
!=
nullptr
)
{
...
...
mindspore/ccsrc/pybind_api/ir/primitive_py.cc
浏览文件 @
359e1f23
...
...
@@ -93,7 +93,7 @@ py::tuple check_bprop_out(const py::object &grads_obj, const py::tuple &py_args)
for
(
size_t
i
=
0
;
i
<
grads
.
size
();
i
++
)
{
if
(
py
::
isinstance
<
tensor
::
Tensor
>
(
py_args
[
i
]))
{
if
(
!
py
::
isinstance
<
tensor
::
Tensor
>
(
grads
[
i
]))
{
MS_EXCEPTION
(
ValueError
)
<<
"
For user define net bprop
, the gradient of the "
<<
i
MS_EXCEPTION
(
ValueError
)
<<
"
When user defines the net bprop,
, the gradient of the "
<<
i
<<
"th arg should be Tensor, but got "
<<
py
::
cast
<
std
::
string
>
(
grads
[
i
].
attr
(
"__class__"
).
attr
(
"__name__"
))
<<
", and the value is "
<<
py
::
cast
<
py
::
str
>
(
grads
[
i
])
<<
"."
;
...
...
mindspore/ccsrc/vm/vm.cc
浏览文件 @
359e1f23
...
...
@@ -472,7 +472,7 @@ void FinalVM::InstPushPrim(const VectorRef &args) {
void
FinalVM
::
SyncData
(
const
py
::
object
&
arg
)
{
if
(
py
::
isinstance
<
py
::
tuple
>
(
arg
))
{
py
::
tuple
arg_list
=
py
::
cast
<
py
::
tuple
>
(
arg
);
auto
arg_list
=
py
::
cast
<
py
::
tuple
>
(
arg
);
for
(
size_t
i
=
0
;
i
<
arg_list
.
size
();
i
++
)
{
SyncData
(
arg_list
[
i
]);
}
...
...
tests/ut/python/ops/test_ops.py
浏览文件 @
359e1f23
...
...
@@ -2464,12 +2464,7 @@ raise_set = [
(
'StridedSlice_1'
,
{
'block'
:
(
P
.
StridedSlice
(),
{
'exception'
:
ValueError
}),
'desc_const'
:
[(
1
,
2
,
3
),
(
3
,
4
,
5
),
(
1
,
1
)],
'desc_inputs'
:
[[
4
,
5
,
6
,
7
]]}),
(
'StridedSlice_2'
,
{
'block'
:
(
P
.
StridedSlice
(),
{
'exception'
:
ValueError
}),
'desc_const'
:
[(
1
,
2
,
3
),
(
3
,
4
,
5
),
(
1
,
1
,
0
)],
'desc_inputs'
:
[[
4
,
5
,
6
,
7
]]}),
'desc_inputs'
:
[[
4
,
5
,
6
,
7
]]})
]
...
...
tests/ut/python/pynative_mode/test_user_define_bprop_check.py
浏览文件 @
359e1f23
...
...
@@ -177,7 +177,7 @@ def test_user_define_bprop_check_parameter():
grad_net
=
GradNet
(
net
)
with
pytest
.
raises
(
RuntimeError
)
as
ex
:
ret
=
grad_net
(
x
,
sens
)
assert
"
in scope Default does not support Parameter data type
."
in
str
(
ex
.
value
)
assert
"
When user defines the net bprop, there are 1 parameters that is not supported in the net
."
in
str
(
ex
.
value
)
def
test_user_define_bprop_check_number
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录