Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
c05203ef
M
mindspore
项目概览
正统之独孤求败
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c05203ef
编写于
5月 16, 2020
作者:
J
jiangjinsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add validate for geswitch and merge
上级
a3110549
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
2 deletion
+16
-2
mindspore/ops/operations/control_ops.py
mindspore/ops/operations/control_ops.py
+14
-0
mindspore/ops/operations/nn_ops.py
mindspore/ops/operations/nn_ops.py
+1
-1
tests/ut/python/ops/test_control_ops.py
tests/ut/python/ops/test_control_ops.py
+1
-1
未找到文件。
mindspore/ops/operations/control_ops.py
浏览文件 @
c05203ef
...
@@ -128,6 +128,7 @@ class GeSwitch(PrimitiveWithInfer):
...
@@ -128,6 +128,7 @@ class GeSwitch(PrimitiveWithInfer):
return
(
data
,
data
)
return
(
data
,
data
)
def
infer_dtype
(
self
,
data_type
,
pred_type
):
def
infer_dtype
(
self
,
data_type
,
pred_type
):
validator
.
check_subclass
(
"data"
,
data_type
,
(
mstype
.
tensor
,)
+
mstype
.
number_type
,
self
.
name
)
validator
.
check_tensor_type_same
({
"pred"
:
pred_type
},
[
mstype
.
bool_
],
self
.
name
)
validator
.
check_tensor_type_same
({
"pred"
:
pred_type
},
[
mstype
.
bool_
],
self
.
name
)
return
(
data_type
,
data_type
)
return
(
data_type
,
data_type
)
...
@@ -153,7 +154,20 @@ class Merge(PrimitiveWithInfer):
...
@@ -153,7 +154,20 @@ class Merge(PrimitiveWithInfer):
raise
NotImplementedError
raise
NotImplementedError
def
infer_shape
(
self
,
inputs
):
def
infer_shape
(
self
,
inputs
):
validator
.
check_integer
(
'inputs len'
,
len
(
inputs
),
0
,
Rel
.
GT
,
self
.
name
)
input_0
=
inputs
[
0
]
for
i
in
range
(
1
,
len
(
inputs
)):
if
inputs
[
i
]
!=
input_0
:
raise
ValueError
(
f
"For
\'
{
self
.
name
}
\'
, the shape of
{
i
}
th input should be same as "
f
"first input
{
input_0
}
, but got
{
inputs
[
i
]
}
."
)
return
(
inputs
[
0
],
[
1
])
return
(
inputs
[
0
],
[
1
])
def
infer_dtype
(
self
,
inputs
):
def
infer_dtype
(
self
,
inputs
):
args
=
{}
for
i
,
item
in
enumerate
(
inputs
):
args
[
'inputs[%d]'
%
i
]
=
item
validator
.
check_tensor_type_same
(
args
,
(
mstype
.
bool_
,)
+
mstype
.
number_type
,
self
.
name
)
return
(
inputs
[
0
],
mstype
.
int32
)
return
(
inputs
[
0
],
mstype
.
int32
)
mindspore/ops/operations/nn_ops.py
浏览文件 @
c05203ef
...
@@ -2084,7 +2084,7 @@ class GetNext(PrimitiveWithInfer):
...
@@ -2084,7 +2084,7 @@ class GetNext(PrimitiveWithInfer):
Note:
Note:
GetNext op needs to be associated with network and also depends on the init_dataset interface,
GetNext op needs to be associated with network and also depends on the init_dataset interface,
it can't be used directly as a single op.
it can't be used directly as a single op.
For details, please refer to `nn.
cell_wrapper.
DataWrapper` source code.
For details, please refer to `nn.DataWrapper` source code.
Args:
Args:
types (list[:class:`mindspore.dtype`]): The type of the outputs.
types (list[:class:`mindspore.dtype`]): The type of the outputs.
...
...
tests/ut/python/ops/test_control_ops.py
浏览文件 @
c05203ef
...
@@ -33,7 +33,7 @@ def cond_data_test(x_init, y_init):
...
@@ -33,7 +33,7 @@ def cond_data_test(x_init, y_init):
super
(
Net
,
self
).
__init__
()
super
(
Net
,
self
).
__init__
()
self
.
square
=
P
.
Square
()
self
.
square
=
P
.
Square
()
self
.
add
=
P
.
TensorAdd
()
self
.
add
=
P
.
TensorAdd
()
self
.
value
=
Tensor
(
np
.
full
((
1
),
3
,
dtype
=
np
.
float32
)
)
self
.
value
=
Tensor
(
3
,
dtype
=
ms
.
float32
)
self
.
switch
=
P
.
GeSwitch
()
self
.
switch
=
P
.
GeSwitch
()
self
.
merge
=
P
.
Merge
()
self
.
merge
=
P
.
Merge
()
self
.
less
=
P
.
Less
()
self
.
less
=
P
.
Less
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录