!19179 dataset: judge return value first to present more clear error msg

Merge pull request !19179 from ms_yan/error_log
This commit is contained in:
i-robot 2021-07-01 07:51:09 +00:00 committed by Gitee
commit 8679413627
1 changed files with 3 additions and 0 deletions

View File

@ -74,6 +74,9 @@ class _SharedQueue(multiprocessing.queues.Queue):
name_list = [] name_list = []
count = 0 count = 0
start_bytes = 0 start_bytes = 0
if not isinstance(data, tuple) and not isinstance(data, np.ndarray):
raise TypeError("return value of user defined python function in GeneratorDataset or"
" map should be numpy array or tuple of numpy array.")
for r in data: for r in data:
if (isinstance(r, np.ndarray) and r.size > self.min_shared_mem if (isinstance(r, np.ndarray) and r.size > self.min_shared_mem
and start_bytes + r.nbytes < self.seg_size): and start_bytes + r.nbytes < self.seg_size):