mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-04-28 11:45:23 +00:00
* [misc] update pre-commit * [misc] run pre-commit * [misc] remove useless configuration files * [misc] ignore cuda for clang-format
25 lines
478 B
Python
25 lines
478 B
Python
from abc import ABC, abstractmethod
|
|
|
|
|
|
class DummyDataGenerator(ABC):
|
|
def __init__(self, length=10):
|
|
self.length = length
|
|
|
|
@abstractmethod
|
|
def generate(self):
|
|
pass
|
|
|
|
def __iter__(self):
|
|
self.step = 0
|
|
return self
|
|
|
|
def __next__(self):
|
|
if self.step < self.length:
|
|
self.step += 1
|
|
return self.generate()
|
|
else:
|
|
raise StopIteration
|
|
|
|
def __len__(self):
|
|
return self.length
|