Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
c6d8a4dc
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看板
提交
c6d8a4dc
编写于
5月 26, 2020
作者:
S
seatea
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix pylint warning.
上级
831ceba6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
24 addition
and
26 deletion
+24
-26
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_abnormal.py
...python_input/gtest_input/pipeline/parse/parse_abnormal.py
+1
-1
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_compile.py
.../python_input/gtest_input/pipeline/parse/parse_compile.py
+1
-3
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_primitive.py
...ython_input/gtest_input/pipeline/parse/parse_primitive.py
+9
-7
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_integrate.py
...thon_input/gtest_input/pipeline/parse/parser_integrate.py
+9
-10
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_test.py
...pp/python_input/gtest_input/pipeline/parse/parser_test.py
+4
-5
未找到文件。
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_abnormal.py
浏览文件 @
c6d8a4dc
...
...
@@ -32,7 +32,7 @@ def rec2():
return
rec1
()
def
test_keep_roots_recursion
(
x
,
y
):
def
test_keep_roots_recursion
():
return
rec1
()
+
nonrec
()
...
...
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_compile.py
浏览文件 @
c6d8a4dc
...
...
@@ -48,8 +48,6 @@ loss = nn.MSELoss()
def
test_build
():
input_data
=
Tensor
(
np
.
random
.
randint
(
0
,
255
,
[
1
,
3
,
224
,
224
]))
input_label
=
Tensor
(
np
.
random
.
randint
(
0
,
10
,
[
1
,
10
]))
net
=
Net
()
opt
=
Momentum
(
net
.
get_parameters
(),
learning_rate
=
0.1
,
momentum
=
0.9
)
model
=
Model
(
net
,
loss_fn
=
loss
,
optimizer
=
opt
,
metrics
=
None
)
Model
(
net
,
loss_fn
=
loss
,
optimizer
=
opt
,
metrics
=
None
)
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_primitive.py
浏览文件 @
c6d8a4dc
...
...
@@ -35,16 +35,18 @@ log.setLevel(level=logging.ERROR)
relu_test
=
Primitive
(
'relu_test'
)
def
test_ops_f1
(
x
,
y
):
foo
=
relu_test
(
x
)
return
foo
def
test_ops_f1
(
x
):
test
=
relu_test
(
x
)
return
test
# use method2: create instance outside function use an operator with parameters
class
Conv_test
(
Primitive
):
@
prim_attr_register
def
__init__
(
self
,
stride
=
0
,
pad
=
1
):
print
(
'in conv_test init'
,
self
.
stride
)
self
.
stride
=
stride
self
.
pad
=
pad
print
(
'in conv_test init'
,
self
.
stride
,
self
.
pad
)
def
__call__
(
self
,
x
=
0
,
y
=
1
,
z
=
2
):
pass
...
...
@@ -65,7 +67,7 @@ class ResNet(nn.Cell):
self
.
weight
=
Parameter
(
tensor
,
name
=
"weight"
)
self
.
conv
=
Conv_test
(
3
,
5
)
def
construct
(
self
,
x
,
y
,
train
=
"train"
):
def
construct
(
self
,
x
,
y
):
return
x
+
y
*
self
.
weight
+
self
.
conv
(
x
)
def
get_params
(
self
):
...
...
@@ -78,7 +80,7 @@ class SimpleNet(nn.Cell):
self
.
weight
=
Parameter
(
tensor
,
name
=
"weight"
)
self
.
network
=
network
def
construct
(
self
,
x
,
y
,
train
=
"train"
):
def
construct
(
self
,
x
,
y
):
return
self
.
network
(
x
)
+
self
.
weight
*
y
def
get_params
(
self
):
...
...
@@ -106,7 +108,7 @@ class SimpleNet_1(nn.Cell):
super
(
SimpleNet_1
,
self
).
__init__
()
self
.
conv
=
Conv_test
(
2
,
3
)
def
construct
(
self
,
x
,
y
,
train
=
"train"
):
def
construct
(
self
,
x
,
y
):
return
self
.
conv
(
x
,
y
)
def
get_params
(
self
):
...
...
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_integrate.py
浏览文件 @
c6d8a4dc
...
...
@@ -15,9 +15,8 @@
"""
file: parser_integrate.py
"""
import
mindspore._c_expression
as
me
import
numpy
as
np
import
mindspore._c_expression
as
me
import
mindspore.nn
as
nn
from
mindspore.common
import
dtype
from
mindspore.common.api
import
ms_function
,
_executor
...
...
@@ -110,9 +109,9 @@ def test_tensor_add():
Y
.
set_dtype
(
dtype
.
float32
)
X
=
me
.
tensor
(
np
.
ones
([
2
,
3
]))
Y
=
me
.
tensor
(
np
.
ones
([
2
,
3
]))
sum
=
add
(
X
,
Y
)
tensor_add
=
add
(
X
,
Y
)
print
(
"test tensor add"
)
return
sum
return
tensor_add
def
loss_func
(
x
,
y
):
...
...
@@ -129,7 +128,7 @@ def test_resetnet50_build():
X
.
set_dtype
(
dtype
.
float32
)
Y
.
set_dtype
(
dtype
.
float32
)
network
=
resnet50
()
model
=
Model
(
network
=
network
,
loss_fn
=
loss_func
,
optimizer
=
optimizer
)
Model
(
network
=
network
,
loss_fn
=
loss_func
,
optimizer
=
optimizer
)
class
Net
(
nn
.
Cell
):
...
...
@@ -146,20 +145,20 @@ class TestNet(nn.Cell):
super
(
TestNet
,
self
).
__init__
()
self
.
param
=
Parameter
(
Tensor
([
1
,
3
,
16
,
50
]),
"param"
)
def
construct
(
self
,
input
):
self
.
param
=
self
.
param
+
input
def
construct
(
self
,
input
s
):
self
.
param
=
self
.
param
+
input
s
return
self
.
param
def
test_compile_conv2d
():
net
=
Net
()
input
=
Tensor
(
np
.
ones
([
1
,
3
,
16
,
50
]).
astype
(
np
.
float32
))
_executor
.
compile
(
net
,
input
)
input
s
=
Tensor
(
np
.
ones
([
1
,
3
,
16
,
50
]).
astype
(
np
.
float32
))
_executor
.
compile
(
net
,
input
s
)
def
test_none
(
x
,
y
):
def
func
(
x
,
y
):
if
y
==
None
:
if
y
is
None
:
return
x
return
x
+
y
...
...
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_test.py
浏览文件 @
c6d8a4dc
...
...
@@ -176,20 +176,19 @@ def test_funcdef(x, y):
def
mymax
(
a
,
b
):
if
a
>
b
:
return
a
else
:
return
b
return
b
t
=
mymax
(
x
,
y
)
return
t
def
test_tuple_fn
(
x
,
y
):
def
test_tuple_fn
(
y
):
l
=
(
1
,
2
,
3
,
5
,
7
)
l
=
l
+
l
[
y
]
return
l
def
test_list_fn
(
x
,
y
):
def
test_list_fn
(
y
):
l
=
[
1
,
2
,
3
,
5
,
7
]
l
=
l
+
l
[
y
]
return
l
...
...
@@ -265,7 +264,7 @@ def test_simple_closure(a, b):
return
f
()
*
g
()
def
test_assign_tuple
(
x
,
y
):
def
test_assign_tuple
():
a
=
1
b
=
2
t
=
a
,
b
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录