!3022 dataset: modify to_device paramter check and reminding msg

Merge pull request !3022 from ms_yan/para_to_device
This commit is contained in:
mindspore-ci-bot 2020-07-13 11:16:44 +08:00 committed by Gitee
commit 044b41d1cb
1 changed files with 7 additions and 3 deletions

View File

@ -975,10 +975,14 @@ class Dataset:
Raises:
TypeError: If device_type is empty.
ValueError: If device_type is not 'Ascend', 'GPU' or 'CPU'.
ValueError: If num_batch is negative or larger than int_max.
ValueError: If num_batch is not positive or larger than int_max.
ValueError: If dataset size is None or 0.
RuntimeError: If dataset is unknown.
RuntimeError: If distribution file path is given but failed to read.
"""
if self.get_dataset_size() is None or 0:
raise ValueError("dataset size is None or 0.")
if num_batch is None:
num_batch = self.get_dataset_size()
repeat_count = self.get_repeat_count()
@ -997,8 +1001,8 @@ class Dataset:
if device_type not in ('Ascend', 'GPU', 'CPU'):
raise ValueError("Only support CPU, Ascend, GPU")
if num_batch is None or num_batch == 0:
raise ValueError("num_batch is None or 0.")
if num_batch == 0:
raise ValueError("num_batch is 0.")
def get_distribution(output_dataset):
dev_id = 0