1# Copyright 2020 Huawei Technologies Co., Ltd 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================ 15'''Remove after MindData merge to MindSpore ''' 16import numpy as np 17 18from mindspore import Tensor 19 20 21class MindData: 22 """ Stub for MindData """ 23 24 def __init__(self, size=1, batch_size=None, repeat_count=1, 25 np_types=None, output_shapes=None, input_indexs=()): 26 self._size = size 27 self._batch_size = batch_size 28 self._repeat_count = repeat_count 29 self._np_types = np_types 30 self._output_shapes = output_shapes 31 self._input_indexs = input_indexs 32 self._iter_num = 0 33 34 def get_dataset_size(self): 35 return self._size 36 37 def get_repeat_count(self): 38 return self._repeat_count 39 40 def get_batch_size(self): 41 return self._batch_size 42 43 def output_types(self): 44 return self._np_types 45 46 def output_shapes(self): 47 return self._output_shapes 48 49 @property 50 def input_indexs(self): 51 return self._input_indexs 52 53 def device_que(self, send_epoch_end=True, create_data_info_queue=False): 54 self.queue_name = '6ba41974-209e-11ea-88b0-a24efeb2c736' 55 self.send_epoch_end = send_epoch_end 56 return self 57 58 def create_tuple_iterator(self, num_epochs=-1, do_copy=True): 59 return self.__iter__() 60 61 def send(self, num_epochs=-1): 62 pass 63 64 def stop_send(self): 65 pass 66 67 def release(self): 68 pass 69 70 def continue_send(self): 71 pass 72 73 def get_data_info(self): 74 pass 75 76 def dynamic_min_max_shapes(self): 77 pass 78 79 def __len__(self): 80 return self._size 81 82 def __iter__(self): 83 return self 84 85 def __next__(self): 86 if self._size < self._iter_num: 87 raise StopIteration 88 self._iter_num += 1 89 next_value = [] 90 for shape, typ in zip(self._output_shapes, self._np_types): 91 next_value.append(Tensor(np.ndarray(shape, typ))) 92 93 return tuple(next_value) 94 95 def next(self): 96 return self.__next__() 97 98 def reset(self): 99 self._iter_num = 0 100