[autoparallel] refactored the autoparallel module for organization (#1706)

* [autoparallel] refactored the autoparallel module for organization

* polish code
This commit is contained in:
Frank Lee
2022-10-14 13:27:00 +08:00
committed by GitHub
parent 91cd34e6e0
commit 6c331a5a09
57 changed files with 408 additions and 799 deletions

View File

@@ -0,0 +1,25 @@
class Registry:
# TODO: refactor the registry classes used in colossalai.registry, colossalai.fx and here
def __init__(self, name):
self.name = name
self.store = {}
def register(self, source):
def wrapper(func):
self.store[source] = func
return func
return wrapper
def get(self, source):
assert source in self.store, f'{source} not found in the {self.name} registry'
target = self.store[source]
return target
def has(self, source):
return source in self.store
operator_registry = Registry('operator')