Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
fbdba6e4
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看板
提交
fbdba6e4
编写于
5月 22, 2020
作者:
J
jinyaohui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean pylint
上级
d9c74e0a
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
63 addition
and
42 deletion
+63
-42
tests/mindspore_test_framework/apps/test_reid_gradient_compare_with_pytorch.py
...framework/apps/test_reid_gradient_compare_with_pytorch.py
+0
-1
tests/st/ops/cpu/test_slice_grad_op.py
tests/st/ops/cpu/test_slice_grad_op.py
+8
-7
tests/st/ops/cpu/test_slice_op.py
tests/st/ops/cpu/test_slice_op.py
+6
-5
tests/st/ops/custom_ops_tbe/test_add3.py
tests/st/ops/custom_ops_tbe/test_add3.py
+8
-5
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_primitive.py
...ython_input/gtest_input/pipeline/parse/parse_primitive.py
+1
-3
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_test.py
...pp/python_input/gtest_input/pipeline/parse/parser_test.py
+2
-0
tests/ut/python/dataset/test_batch.py
tests/ut/python/dataset/test_batch.py
+1
-0
tests/ut/python/dataset/test_center_crop.py
tests/ut/python/dataset/test_center_crop.py
+1
-0
tests/ut/python/dataset/test_filterop.py
tests/ut/python/dataset/test_filterop.py
+1
-1
tests/ut/python/dataset/test_normalizeOp.py
tests/ut/python/dataset/test_normalizeOp.py
+1
-0
tests/ut/python/dataset/test_opt.py
tests/ut/python/dataset/test_opt.py
+3
-3
tests/ut/python/dataset/test_pad.py
tests/ut/python/dataset/test_pad.py
+1
-0
tests/ut/python/dataset/test_random_color_adjust.py
tests/ut/python/dataset/test_random_color_adjust.py
+1
-0
tests/ut/python/dataset/test_take.py
tests/ut/python/dataset/test_take.py
+0
-1
tests/ut/python/dataset/test_tensor_string.py
tests/ut/python/dataset/test_tensor_string.py
+1
-0
tests/ut/python/dtype/test_dictionary.py
tests/ut/python/dtype/test_dictionary.py
+5
-2
tests/ut/python/mindrecord/test_mnist_to_mr.py
tests/ut/python/mindrecord/test_mnist_to_mr.py
+5
-4
tests/ut/python/nn/test_parameter.py
tests/ut/python/nn/test_parameter.py
+1
-0
tests/ut/python/ops/test_control_ops.py
tests/ut/python/ops/test_control_ops.py
+3
-2
tests/ut/python/parallel/parallel_end_to_end/dropout/_test_dropout_parallel_4p.py
.../parallel_end_to_end/dropout/_test_dropout_parallel_4p.py
+1
-0
tests/ut/python/parallel/test_train_and_eval.py
tests/ut/python/parallel/test_train_and_eval.py
+8
-7
tests/ut/python/parameter_feature/test_parameter.py
tests/ut/python/parameter_feature/test_parameter.py
+2
-0
tests/ut/python/pipeline/parse/test_cont_break.py
tests/ut/python/pipeline/parse/test_cont_break.py
+2
-1
tests/vm_impl/math_ops_vm_impl.py
tests/vm_impl/math_ops_vm_impl.py
+1
-0
未找到文件。
tests/mindspore_test_framework/apps/test_reid_gradient_compare_with_pytorch.py
浏览文件 @
fbdba6e4
...
@@ -21,7 +21,6 @@ from mindspore import context
...
@@ -21,7 +21,6 @@ from mindspore import context
from
mindspore.ops
import
operations
as
P
from
mindspore.ops
import
operations
as
P
from
..mindspore_test
import
mindspore_test
from
..mindspore_test
import
mindspore_test
from
..pipeline.gradient.compare_gradient
import
pipeline_for_compare_inputs_grad_with_npy_for_case_by_case_config
from
..pipeline.gradient.compare_gradient
import
pipeline_for_compare_inputs_grad_with_npy_for_case_by_case_config
from
...vm_impl
import
*
verification_set
=
[
verification_set
=
[
(
'MatMul'
,
{
(
'MatMul'
,
{
...
...
tests/st/ops/cpu/test_slice_grad_op.py
浏览文件 @
fbdba6e4
...
@@ -13,15 +13,15 @@
...
@@ -13,15 +13,15 @@
# limitations under the License.
# limitations under the License.
# ============================================================================
# ============================================================================
import
pytest
from
mindspore
import
Tensor
from
mindspore.ops
import
operations
as
P
from
mindspore.ops.operations
import
_grad_ops
as
G
import
mindspore.nn
as
nn
from
mindspore.common.api
import
ms_function
import
numpy
as
np
import
numpy
as
np
import
pytest
import
mindspore.context
as
context
import
mindspore.context
as
context
import
mindspore.nn
as
nn
from
mindspore
import
Tensor
from
mindspore.common
import
dtype
as
mstype
from
mindspore.common
import
dtype
as
mstype
from
mindspore.common.api
import
ms_function
from
mindspore.ops.operations
import
_grad_ops
as
G
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
'CPU'
)
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
'CPU'
)
...
@@ -54,5 +54,6 @@ def test_slice():
...
@@ -54,5 +54,6 @@ def test_slice():
print
(
"output:
\n
"
,
output
)
print
(
"output:
\n
"
,
output
)
assert
(
output
.
asnumpy
()
==
expect
).
all
()
assert
(
output
.
asnumpy
()
==
expect
).
all
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_slice
()
test_slice
()
tests/st/ops/cpu/test_slice_op.py
浏览文件 @
fbdba6e4
...
@@ -13,13 +13,14 @@
...
@@ -13,13 +13,14 @@
# limitations under the License.
# limitations under the License.
# ============================================================================
# ============================================================================
import
pytest
from
mindspore
import
Tensor
from
mindspore.ops
import
operations
as
P
import
mindspore.nn
as
nn
import
numpy
as
np
import
numpy
as
np
import
pytest
import
mindspore.context
as
context
import
mindspore.context
as
context
import
mindspore.nn
as
nn
from
mindspore
import
Tensor
from
mindspore.common
import
dtype
as
mstype
from
mindspore.common
import
dtype
as
mstype
from
mindspore.ops
import
operations
as
P
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
'CPU'
)
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
'CPU'
)
...
@@ -45,6 +46,6 @@ def test_slice():
...
@@ -45,6 +46,6 @@ def test_slice():
print
(
"output:
\n
"
,
output
)
print
(
"output:
\n
"
,
output
)
assert
(
output
.
asnumpy
()
==
expect
).
all
()
assert
(
output
.
asnumpy
()
==
expect
).
all
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_slice
()
test_slice
()
tests/st/ops/custom_ops_tbe/test_add3.py
浏览文件 @
fbdba6e4
...
@@ -12,15 +12,17 @@
...
@@ -12,15 +12,17 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
# ============================================================================
# ============================================================================
import
pytest
import
numpy
as
np
import
numpy
as
np
import
mindspore.nn
as
nn
import
pytest
from
cus_add3
import
CusAdd3
import
mindspore.context
as
context
import
mindspore.context
as
context
import
mindspore.nn
as
nn
from
mindspore
import
Tensor
from
mindspore
import
Tensor
from
mindspore.ops
import
composite
as
C
from
cus_add3
import
CusAdd3
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"Ascend"
)
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"Ascend"
)
class
Net
(
nn
.
Cell
):
class
Net
(
nn
.
Cell
):
"""Net definition"""
"""Net definition"""
...
@@ -31,6 +33,7 @@ class Net(nn.Cell):
...
@@ -31,6 +33,7 @@ class Net(nn.Cell):
def
construct
(
self
,
input1
,
input2
):
def
construct
(
self
,
input1
,
input2
):
return
self
.
add3
(
input1
,
input2
)
return
self
.
add3
(
input1
,
input2
)
@
pytest
.
mark
.
level0
@
pytest
.
mark
.
level0
@
pytest
.
mark
.
platform_x86_ascend_training
@
pytest
.
mark
.
platform_x86_ascend_training
@
pytest
.
mark
.
platform_arm_ascend_training
@
pytest
.
mark
.
platform_arm_ascend_training
...
@@ -41,4 +44,4 @@ def test_net():
...
@@ -41,4 +44,4 @@ def test_net():
add3_net
=
Net
()
add3_net
=
Net
()
output
=
add3_net
(
Tensor
(
input1
),
Tensor
(
input2
))
output
=
add3_net
(
Tensor
(
input1
),
Tensor
(
input2
))
expect
=
np
.
array
([
3.0
,
7.0
,
13.0
]).
astype
(
np
.
float32
)
expect
=
np
.
array
([
3.0
,
7.0
,
13.0
]).
astype
(
np
.
float32
)
assert
(
output
.
asnumpy
()
==
expect
).
all
()
assert
(
output
.
asnumpy
()
==
expect
).
all
()
\ No newline at end of file
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_primitive.py
浏览文件 @
fbdba6e4
...
@@ -19,16 +19,14 @@
...
@@ -19,16 +19,14 @@
@Desc : parser class method function.
@Desc : parser class method function.
"""
"""
import
logging
import
logging
import
numpy
as
np
import
numpy
as
np
import
sys
from
collections
import
*
import
mindspore.nn
as
nn
import
mindspore.nn
as
nn
from
mindspore.common.parameter
import
Parameter
from
mindspore.common.parameter
import
Parameter
from
mindspore.common.tensor
import
Tensor
from
mindspore.common.tensor
import
Tensor
from
mindspore.ops
import
Primitive
,
prim_attr_register
from
mindspore.ops
import
Primitive
,
prim_attr_register
from
mindspore.ops
import
functional
as
F
from
mindspore.ops
import
functional
as
F
from
mindspore.train.model
import
Model
log
=
logging
.
getLogger
(
"test"
)
log
=
logging
.
getLogger
(
"test"
)
log
.
setLevel
(
level
=
logging
.
ERROR
)
log
.
setLevel
(
level
=
logging
.
ERROR
)
...
...
tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_test.py
浏览文件 @
fbdba6e4
...
@@ -201,6 +201,7 @@ def get_resolve_fn(x, y):
...
@@ -201,6 +201,7 @@ def get_resolve_fn(x, y):
# Test:no return function
# Test:no return function
# pylint: disable=pointless-statement
def
get_no_return_fn
(
x
,
y
):
def
get_no_return_fn
(
x
,
y
):
x
+
y
x
+
y
...
@@ -339,6 +340,7 @@ def func_call(x, y, *var, a=0, b=1, **kwargs):
...
@@ -339,6 +340,7 @@ def func_call(x, y, *var, a=0, b=1, **kwargs):
return
x
+
y
+
var
[
0
]
+
a
+
b
+
kwargs
[
"z"
]
return
x
+
y
+
var
[
0
]
+
a
+
b
+
kwargs
[
"z"
]
# pylint: disable=repeated-keyword
def
test_call_variable
():
def
test_call_variable
():
t
=
(
1
,
2
,
3
)
t
=
(
1
,
2
,
3
)
d
=
{
"z"
:
10
,
"e"
:
11
}
d
=
{
"z"
:
10
,
"e"
:
11
}
...
...
tests/ut/python/dataset/test_batch.py
浏览文件 @
fbdba6e4
...
@@ -434,6 +434,7 @@ def test_batch_exception_11():
...
@@ -434,6 +434,7 @@ def test_batch_exception_11():
assert
"drop_remainder"
in
str
(
e
)
assert
"drop_remainder"
in
str
(
e
)
# pylint: disable=redundant-keyword-arg
def
test_batch_exception_12
():
def
test_batch_exception_12
():
"""
"""
Test batch exception: wrong input order, drop_remainder wrongly used as batch_size
Test batch exception: wrong input order, drop_remainder wrongly used as batch_size
...
...
tests/ut/python/dataset/test_center_crop.py
浏览文件 @
fbdba6e4
...
@@ -106,6 +106,7 @@ def test_center_crop_comp(height=375, width=375, plot=False):
...
@@ -106,6 +106,7 @@ def test_center_crop_comp(height=375, width=375, plot=False):
visualize
(
image
,
image_cropped
)
visualize
(
image
,
image_cropped
)
# pylint: disable=unnecessary-lambda
def
test_crop_grayscale
(
height
=
375
,
width
=
375
):
def
test_crop_grayscale
(
height
=
375
,
width
=
375
):
"""
"""
Test that centercrop works with pad and grayscale images
Test that centercrop works with pad and grayscale images
...
...
tests/ut/python/dataset/test_filterop.py
浏览文件 @
fbdba6e4
...
@@ -19,7 +19,6 @@ import mindspore.common.dtype as mstype
...
@@ -19,7 +19,6 @@ import mindspore.common.dtype as mstype
import
mindspore.dataset
as
ds
import
mindspore.dataset
as
ds
import
mindspore.dataset.transforms.c_transforms
as
C
import
mindspore.dataset.transforms.c_transforms
as
C
import
mindspore.dataset.transforms.vision.c_transforms
as
cde
import
mindspore.dataset.transforms.vision.c_transforms
as
cde
from
mindspore
import
log
as
logger
DATA_DIR
=
[
"../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"
]
DATA_DIR
=
[
"../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"
]
SCHEMA_DIR
=
"../data/dataset/test_tf_file_3_images/datasetSchema.json"
SCHEMA_DIR
=
"../data/dataset/test_tf_file_3_images/datasetSchema.json"
...
@@ -255,6 +254,7 @@ def filter_func_map(col1, col2):
...
@@ -255,6 +254,7 @@ def filter_func_map(col1, col2):
return
False
return
False
# pylint: disable=simplifiable-if-statement
def
filter_func_map_part
(
col1
):
def
filter_func_map_part
(
col1
):
if
col1
<
3
:
if
col1
<
3
:
return
True
return
True
...
...
tests/ut/python/dataset/test_normalizeOp.py
浏览文件 @
fbdba6e4
...
@@ -36,6 +36,7 @@ def normalize_np(image):
...
@@ -36,6 +36,7 @@ def normalize_np(image):
return
image
return
image
# pylint: disable=inconsistent-return-statements
def
get_normalized
(
image_id
):
def
get_normalized
(
image_id
):
"""
"""
Reads the image using DE ops and then normalizes using Numpy
Reads the image using DE ops and then normalizes using Numpy
...
...
tests/ut/python/dataset/test_opt.py
浏览文件 @
fbdba6e4
...
@@ -13,10 +13,10 @@
...
@@ -13,10 +13,10 @@
# limitations under the License.
# limitations under the License.
# ==============================================================================
# ==============================================================================
import
numpy
as
np
import
numpy
as
np
import
pytest
import
mindspore.dataset
as
ds
import
mindspore.dataset
as
ds
# Generate 1d int numpy array from 0 - 63
# Generate 1d int numpy array from 0 - 63
def
generator_1d
():
def
generator_1d
():
for
i
in
range
(
64
):
for
i
in
range
(
64
):
...
@@ -33,7 +33,7 @@ def test_case_0():
...
@@ -33,7 +33,7 @@ def test_case_0():
data1
=
data1
.
shuffle
(
2
)
data1
=
data1
.
shuffle
(
2
)
data1
=
data1
.
map
([
"data"
],
operations
=
(
lambda
x
:
x
))
data1
=
data1
.
map
([
"data"
],
operations
=
(
lambda
x
:
x
))
data1
=
data1
.
batch
(
2
)
data1
=
data1
.
batch
(
2
)
...
@@ -43,4 +43,4 @@ def test_case_0():
...
@@ -43,4 +43,4 @@ def test_case_0():
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_case_0
()
test_case_0
()
\ No newline at end of file
tests/ut/python/dataset/test_pad.py
浏览文件 @
fbdba6e4
...
@@ -70,6 +70,7 @@ def test_pad_op():
...
@@ -70,6 +70,7 @@ def test_pad_op():
assert
mse
<
0.01
assert
mse
<
0.01
# pylint: disable=unnecessary-lambda
def
test_pad_grayscale
():
def
test_pad_grayscale
():
"""
"""
Tests that the pad works for grayscale images
Tests that the pad works for grayscale images
...
...
tests/ut/python/dataset/test_random_color_adjust.py
浏览文件 @
fbdba6e4
...
@@ -253,6 +253,7 @@ def test_random_color_adjust_op_hue(plot=False):
...
@@ -253,6 +253,7 @@ def test_random_color_adjust_op_hue(plot=False):
visualize
(
c_image
,
mse
,
py_image
)
visualize
(
c_image
,
mse
,
py_image
)
# pylint: disable=unnecessary-lambda
def
test_random_color_adjust_grayscale
():
def
test_random_color_adjust_grayscale
():
"""
"""
Tests that the random color adjust works for grayscale images
Tests that the random color adjust works for grayscale images
...
...
tests/ut/python/dataset/test_take.py
浏览文件 @
fbdba6e4
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
import
numpy
as
np
import
numpy
as
np
import
mindspore.dataset
as
ds
import
mindspore.dataset
as
ds
import
mindspore.dataset.transforms.vision.c_transforms
as
vision
from
mindspore
import
log
as
logger
from
mindspore
import
log
as
logger
...
...
tests/ut/python/dataset/test_tensor_string.py
浏览文件 @
fbdba6e4
...
@@ -19,6 +19,7 @@ import pytest
...
@@ -19,6 +19,7 @@ import pytest
import
mindspore.dataset
as
ds
import
mindspore.dataset
as
ds
# pylint: disable=comparison-with-itself
def
test_basic
():
def
test_basic
():
x
=
np
.
array
([[
"ab"
,
"cde"
,
"121"
],
[
"x"
,
"km"
,
"789"
]],
dtype
=
'S'
)
x
=
np
.
array
([[
"ab"
,
"cde"
,
"121"
],
[
"x"
,
"km"
,
"789"
]],
dtype
=
'S'
)
# x = np.array(["ab", "cde"], dtype='S')
# x = np.array(["ab", "cde"], dtype='S')
...
...
tests/ut/python/dtype/test_dictionary.py
浏览文件 @
fbdba6e4
...
@@ -137,16 +137,19 @@ def test_dict_set_or_get_item_3():
...
@@ -137,16 +137,19 @@ def test_dict_set_or_get_item_3():
net
=
DictNet
()
net
=
DictNet
()
assert
net
()
==
Tensor
(
np
.
ones
([
4
,
2
,
3
],
np
.
float32
))
assert
net
()
==
Tensor
(
np
.
ones
([
4
,
2
,
3
],
np
.
float32
))
def
test_dict_set_item
():
def
test_dict_set_item
():
class
DictSetNet
(
Cell
):
class
DictSetNet
(
Cell
):
def
__init__
(
self
):
def
__init__
(
self
):
super
(
DictSetNet
,
self
).
__init__
()
super
(
DictSetNet
,
self
).
__init__
()
self
.
attrs
=
(
"abc"
,
"edf"
,
"ghi"
,
"jkl"
)
self
.
attrs
=
(
"abc"
,
"edf"
,
"ghi"
,
"jkl"
)
def
construct
(
self
,
x
):
def
construct
(
self
,
x
):
my_dict
=
{
"def"
:
x
,
"abc"
:
x
,
"edf"
:
x
,
"ghi"
:
x
,
"jkl"
:
x
}
my_dict
=
{
"def"
:
x
,
"abc"
:
x
,
"edf"
:
x
,
"ghi"
:
x
,
"jkl"
:
x
}
for
i
in
range
(
len
(
self
.
attrs
)):
for
i
in
range
(
len
(
self
.
attrs
)):
my_dict
[
self
.
attrs
[
i
]]
=
x
-
i
my_dict
[
self
.
attrs
[
i
]]
=
x
-
i
return
my_dict
[
"jkl"
],
my_dict
[
"edf"
]
return
my_dict
[
"jkl"
],
my_dict
[
"edf"
]
x
=
Tensor
(
np
.
ones
([
2
,
2
,
3
],
np
.
float32
))
x
=
Tensor
(
np
.
ones
([
2
,
2
,
3
],
np
.
float32
))
net
=
DictSetNet
()
net
=
DictSetNet
()
out
=
net
(
x
)
out
=
net
(
x
)
\ No newline at end of file
tests/ut/python/mindrecord/test_mnist_to_mr.py
浏览文件 @
fbdba6e4
...
@@ -12,12 +12,13 @@
...
@@ -12,12 +12,13 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
"""test mnist to mindrecord tool"""
"""test mnist to mindrecord tool"""
import
cv2
import
gzip
import
gzip
import
pytest
import
numpy
as
np
import
os
import
os
import
cv2
import
numpy
as
np
import
pytest
from
mindspore
import
log
as
logger
from
mindspore
import
log
as
logger
from
mindspore.mindrecord
import
FileReader
from
mindspore.mindrecord
import
FileReader
from
mindspore.mindrecord
import
MnistToMR
from
mindspore.mindrecord
import
MnistToMR
...
@@ -144,10 +145,10 @@ def test_mnist_to_mindrecord_compare_data(fixture_file):
...
@@ -144,10 +145,10 @@ def test_mnist_to_mindrecord_compare_data(fixture_file):
assert
np
.
array
(
x
[
'label'
])
==
label
assert
np
.
array
(
x
[
'label'
])
==
label
reader
.
close
()
reader
.
close
()
def
test_mnist_to_mindrecord_multi_partition
(
fixture_file
):
def
test_mnist_to_mindrecord_multi_partition
(
fixture_file
):
"""test transform mnist dataset to multiple mindrecord files."""
"""test transform mnist dataset to multiple mindrecord files."""
mnist_transformer
=
MnistToMR
(
MNIST_DIR
,
FILE_NAME
,
PARTITION_NUM
)
mnist_transformer
=
MnistToMR
(
MNIST_DIR
,
FILE_NAME
,
PARTITION_NUM
)
mnist_transformer
.
transform
()
mnist_transformer
.
transform
()
read
(
"mnist_train.mindrecord0"
,
"mnist_test.mindrecord0"
)
read
(
"mnist_train.mindrecord0"
,
"mnist_test.mindrecord0"
)
tests/ut/python/nn/test_parameter.py
浏览文件 @
fbdba6e4
# Copyright 2020 Huawei Technologies Co., Ltd
# Copyright 2020 Huawei Technologies Co., Ltd
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
tests/ut/python/ops/test_control_ops.py
浏览文件 @
fbdba6e4
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
# limitations under the License.
# limitations under the License.
# ============================================================================
# ============================================================================
""" test control ops """
""" test control ops """
import
pytest
import
numpy
as
np
import
numpy
as
np
import
pytest
import
mindspore
as
ms
import
mindspore
as
ms
from
mindspore
import
Tensor
from
mindspore
import
Tensor
...
@@ -436,10 +436,11 @@ def test_index_to_switch_layer():
...
@@ -436,10 +436,11 @@ def test_index_to_switch_layer():
Tensor
(
np
.
full
([
128
,
96
],
0.6
,
dtype
=
np
.
float32
)))
Tensor
(
np
.
full
([
128
,
96
],
0.6
,
dtype
=
np
.
float32
)))
C
.
grad_all
(
net
)(
index
,
Tensor
(
np
.
full
([
128
,
96
],
0.6
,
dtype
=
np
.
float32
)))
C
.
grad_all
(
net
)(
index
,
Tensor
(
np
.
full
([
128
,
96
],
0.6
,
dtype
=
np
.
float32
)))
def
test_control_depend_check
():
def
test_control_depend_check
():
with
pytest
.
raises
(
TypeError
)
as
e
:
with
pytest
.
raises
(
TypeError
)
as
e
:
depend
=
P
.
ControlDepend
(
0.0
)
depend
=
P
.
ControlDepend
(
0.0
)
with
pytest
.
raises
(
ValueError
)
as
e
:
with
pytest
.
raises
(
ValueError
)
as
e
:
depend
=
P
.
ControlDepend
(
2
)
depend
=
P
.
ControlDepend
(
2
)
with
pytest
.
raises
(
TypeError
)
as
e
:
with
pytest
.
raises
(
TypeError
)
as
e
:
depend
=
P
.
ControlDepend
((
2
,))
depend
=
P
.
ControlDepend
((
2
,))
\ No newline at end of file
tests/ut/python/parallel/parallel_end_to_end/dropout/_test_dropout_parallel_4p.py
浏览文件 @
fbdba6e4
...
@@ -50,6 +50,7 @@ class Net(Cell):
...
@@ -50,6 +50,7 @@ class Net(Cell):
return
x
return
x
# pylint: disable=comparison-with-itself
class
DropoutFactory
:
class
DropoutFactory
:
def
__init__
(
self
,
input_shape
,
keep_prob
,
seed0
,
seed1
,
strategy0
=
None
):
def
__init__
(
self
,
input_shape
,
keep_prob
,
seed0
,
seed1
,
strategy0
=
None
):
size
=
1
size
=
1
...
...
tests/ut/python/parallel/test_train_and_eval.py
浏览文件 @
fbdba6e4
...
@@ -13,11 +13,12 @@
...
@@ -13,11 +13,12 @@
# limitations under the License.
# limitations under the License.
# ============================================================================
# ============================================================================
import
numpy
as
np
import
numpy
as
np
import
mindspore
as
ms
import
mindspore
as
ms
from
mindspore
import
context
,
Tensor
,
Parameter
from
mindspore
import
context
,
Tensor
,
Parameter
from
mindspore.nn
import
Cell
,
TrainOneStepCell
,
Momentum
from
mindspore.ops
import
operations
as
P
from
mindspore.common.api
import
_executor
from
mindspore.common.api
import
_executor
from
mindspore.nn
import
Cell
from
mindspore.ops
import
operations
as
P
class
Net
(
Cell
):
class
Net
(
Cell
):
...
@@ -42,7 +43,7 @@ class EvalNet(Cell):
...
@@ -42,7 +43,7 @@ class EvalNet(Cell):
def
construct
(
self
,
x
,
b
):
def
construct
(
self
,
x
,
b
):
out
=
self
.
network
(
x
,
b
)
out
=
self
.
network
(
x
,
b
)
out
=
self
.
relu
(
out
)
out
=
self
.
relu
(
out
)
return
out
return
out
_x
=
Tensor
(
np
.
ones
([
8
,
8
]),
dtype
=
ms
.
float32
)
_x
=
Tensor
(
np
.
ones
([
8
,
8
]),
dtype
=
ms
.
float32
)
...
@@ -54,15 +55,15 @@ def test_train_and_eval():
...
@@ -54,15 +55,15 @@ def test_train_and_eval():
context
.
set_context
(
save_graphs
=
True
,
mode
=
0
)
context
.
set_context
(
save_graphs
=
True
,
mode
=
0
)
context
.
set_auto_parallel_context
(
parallel_mode
=
"semi_auto_parallel"
,
device_num
=
16
)
context
.
set_auto_parallel_context
(
parallel_mode
=
"semi_auto_parallel"
,
device_num
=
16
)
strategy1
=
((
4
,
4
),
(
4
,
4
))
strategy1
=
((
4
,
4
),
(
4
,
4
))
strategy2
=
((
4
,
4
),
)
strategy2
=
((
4
,
4
),)
net
=
Net
(
_w1
,
strategy1
,
strategy2
)
net
=
Net
(
_w1
,
strategy1
,
strategy2
)
eval_net
=
EvalNet
(
net
,
strategy2
=
strategy2
)
eval_net
=
EvalNet
(
net
,
strategy2
=
strategy2
)
net
.
set_train
()
net
.
set_train
()
net
.
set_auto_parallel
()
net
.
set_auto_parallel
()
_executor
.
compile
(
net
,
_x
,
_b
,
phase
=
'train'
,
auto_parallel_mode
=
True
)
_executor
.
compile
(
net
,
_x
,
_b
,
phase
=
'train'
,
auto_parallel_mode
=
True
)
eval_net
.
set_train
(
mode
=
False
)
eval_net
.
set_train
(
mode
=
False
)
eval_net
.
set_auto_parallel
()
eval_net
.
set_auto_parallel
()
_executor
.
compile
(
eval_net
,
_x
,
_b
,
phase
=
'eval'
,
auto_parallel_mode
=
True
)
_executor
.
compile
(
eval_net
,
_x
,
_b
,
phase
=
'eval'
,
auto_parallel_mode
=
True
)
context
.
reset_auto_parallel_context
()
context
.
reset_auto_parallel_context
()
\ No newline at end of file
tests/ut/python/parameter_feature/test_parameter.py
浏览文件 @
fbdba6e4
...
@@ -50,6 +50,7 @@ def test_parser_three_default_mixed_args_subnet():
...
@@ -50,6 +50,7 @@ def test_parser_three_default_mixed_args_subnet():
assert
net
(
tensor1
,
tensor2
)
==
tensor1
assert
net
(
tensor1
,
tensor2
)
==
tensor1
# pylint: disable=keyword-arg-before-vararg
def
test_net_vararg_kwonlyarg_kwarg
():
def
test_net_vararg_kwonlyarg_kwarg
():
class
FirstNet
(
Cell
):
class
FirstNet
(
Cell
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -76,6 +77,7 @@ def test_net_vararg_kwonlyarg_kwarg():
...
@@ -76,6 +77,7 @@ def test_net_vararg_kwonlyarg_kwarg():
net
()
net
()
# pylint: disable=keyword-arg-before-vararg
def
test_net_vararg_normal_input
():
def
test_net_vararg_normal_input
():
class
FirstNet
(
Cell
):
class
FirstNet
(
Cell
):
def
__init__
(
self
):
def
__init__
(
self
):
...
...
tests/ut/python/pipeline/parse/test_cont_break.py
浏览文件 @
fbdba6e4
...
@@ -34,6 +34,7 @@ def run_test(netclass, count):
...
@@ -34,6 +34,7 @@ def run_test(netclass, count):
# np.testing.assert_array_almost_equal(output_np, output_ms.asnumpy(), decimal=3)
# np.testing.assert_array_almost_equal(output_np, output_ms.asnumpy(), decimal=3)
# pylint: disable=unnecessary-pass
class
for_loop_with_break
(
Cell
):
class
for_loop_with_break
(
Cell
):
def
__init__
(
self
):
def
__init__
(
self
):
super
().
__init__
()
super
().
__init__
()
...
@@ -70,7 +71,7 @@ class for_loop_with_continue(Cell):
...
@@ -70,7 +71,7 @@ class for_loop_with_continue(Cell):
def
test_for_loop_with_continue
():
def
test_for_loop_with_continue
():
run_test
(
for_loop_with_continue
,
10
)
run_test
(
for_loop_with_continue
,
10
)
# pylint: disable=unnecessary-pass
class
for_loop_with_cont_break
(
Cell
):
class
for_loop_with_cont_break
(
Cell
):
def
__init__
(
self
):
def
__init__
(
self
):
super
().
__init__
()
super
().
__init__
()
...
...
tests/vm_impl/math_ops_vm_impl.py
浏览文件 @
fbdba6e4
...
@@ -38,6 +38,7 @@ def vm_impl_tensor_add(self):
...
@@ -38,6 +38,7 @@ def vm_impl_tensor_add(self):
return
vm_impl
return
vm_impl
# pylint: disable=used-before-assignment
@
vm_impl_getters
.
register
(
P
.
LogicalNot
)
@
vm_impl_getters
.
register
(
P
.
LogicalNot
)
def
vm_impl_logical_not
(
self
):
def
vm_impl_logical_not
(
self
):
x
=
x
.
asnumpy
()
x
=
x
.
asnumpy
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录