Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
4670b58c
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看板
提交
4670b58c
编写于
7月 10, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
7月 10, 2020
浏览文件
操作
浏览文件
下载
差异文件
!2908 dataset: avoid same column name and add para check for to_device
Merge pull request !2908 from ms_yan/column_empty
上级
9b4ec82f
83bc1fb3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
4 deletion
+27
-4
mindspore/dataset/core/validator_helpers.py
mindspore/dataset/core/validator_helpers.py
+3
-1
mindspore/dataset/engine/datasets.py
mindspore/dataset/engine/datasets.py
+4
-2
mindspore/dataset/engine/validators.py
mindspore/dataset/engine/validators.py
+20
-1
未找到文件。
mindspore/dataset/core/validator_helpers.py
浏览文件 @
4670b58c
...
...
@@ -95,7 +95,7 @@ def check_uint32(value, arg_name=""):
def
check_pos_int32
(
value
,
arg_name
=
""
):
type_check
(
value
,
(
int
,),
arg_name
)
check_value
(
value
,
[
POS_INT_MIN
,
INT32_MAX
])
check_value
(
value
,
[
POS_INT_MIN
,
INT32_MAX
]
,
arg_name
)
def
check_uint64
(
value
,
arg_name
=
""
):
...
...
@@ -143,6 +143,8 @@ def check_columns(columns, name):
col_names
=
[
"{0}[{1}]"
.
format
(
name
,
i
)
for
i
in
range
(
len
(
columns
))]
type_check_list
(
columns
,
(
str
,),
col_names
)
if
len
(
set
(
columns
))
!=
len
(
columns
):
raise
ValueError
(
"Every column name should not be same with others in column_names."
)
def
parse_user_args
(
method
,
*
args
,
**
kwargs
):
...
...
mindspore/dataset/engine/datasets.py
浏览文件 @
4670b58c
...
...
@@ -44,7 +44,7 @@ from .validators import check_batch, check_shuffle, check_map, check_filter, che
check_take
,
check_project
,
check_imagefolderdatasetv2
,
check_mnist_cifar_dataset
,
check_manifestdataset
,
\
check_tfrecorddataset
,
check_vocdataset
,
check_cocodataset
,
check_celebadataset
,
check_minddataset
,
\
check_generatordataset
,
check_sync_wait
,
check_zip_dataset
,
check_add_column
,
check_textfiledataset
,
check_concat
,
\
check_split
,
check_bucket_batch_by_length
,
check_cluedataset
check_split
,
check_bucket_batch_by_length
,
check_cluedataset
,
check_positive_int32
from
..core.datatypes
import
mstype_to_detype
,
mstypelist_to_detypelist
try
:
...
...
@@ -939,6 +939,7 @@ class Dataset:
raise
TypeError
(
"apply_func must return a dataset."
)
return
dataset
@
check_positive_int32
def
device_que
(
self
,
prefetch_size
=
None
):
"""
Return a transferredDataset that transfer data through device.
...
...
@@ -956,6 +957,7 @@ class Dataset:
"""
return
self
.
to_device
()
@
check_positive_int32
def
to_device
(
self
,
num_batch
=
None
):
"""
Transfer data through CPU, GPU or Ascend devices.
...
...
@@ -973,7 +975,7 @@ class Dataset:
Raises:
TypeError: If device_type is empty.
ValueError: If device_type is not 'Ascend', 'GPU' or 'CPU'.
ValueError: If num_batch is
None or 0
or larger than int_max.
ValueError: If num_batch is
negative
or larger than int_max.
RuntimeError: If dataset is unknown.
RuntimeError: If distribution file path is given but failed to read.
"""
...
...
mindspore/dataset/engine/validators.py
浏览文件 @
4670b58c
...
...
@@ -25,7 +25,7 @@ from mindspore._c_expression import typing
from
..core.validator_helpers
import
parse_user_args
,
type_check
,
type_check_list
,
check_value
,
\
INT32_MAX
,
check_valid_detype
,
check_dir
,
check_file
,
check_sampler_shuffle_shard_options
,
\
validate_dataset_param_value
,
check_padding_options
,
check_gnn_list_or_ndarray
,
check_num_parallel_workers
,
\
check_columns
,
check_positive
check_columns
,
check_positive
,
check_pos_int32
from
.
import
datasets
from
.
import
samplers
...
...
@@ -593,6 +593,25 @@ def check_take(method):
return
new_method
def
check_positive_int32
(
method
):
"""check whether the input argument is positive and int, only works for functions with one input."""
@
wraps
(
method
)
def
new_method
(
self
,
*
args
,
**
kwargs
):
[
count
],
param_dict
=
parse_user_args
(
method
,
*
args
,
**
kwargs
)
para_name
=
None
for
key
in
list
(
param_dict
.
keys
()):
if
key
not
in
[
'self'
,
'cls'
]:
para_name
=
key
# Need to get default value of param
if
count
is
not
None
:
check_pos_int32
(
count
,
para_name
)
return
method
(
self
,
*
args
,
**
kwargs
)
return
new_method
def
check_zip
(
method
):
"""check the input arguments of zip."""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录