Provide len() method for the minddata dataset class interface

This commit is contained in:
liu-yongqi-63 2023-02-15 11:30:49 +08:00
parent 42fa3f67af
commit cf083546aa
1 changed files with 9 additions and 0 deletions

View File

@ -1853,6 +1853,15 @@ class Dataset:
def parse(self, children=None):
raise NotImplementedError("Dataset has to implement parse method.")
def __len__(self):
"""
Get the length of dataset.
Returns:
int, the length of dataset.
"""
return self.get_dataset_size()
@staticmethod
def _update_data_shard(num_shards, shard_id):
"""