mirror of https://github.com/hpcaitech/ColossalAI
22 lines
410 B
Python
22 lines
410 B
Python
from abc import ABC, abstractmethod
|
|
from typing import Callable
|
|
|
|
|
|
class BaseExtension(ABC):
|
|
@abstractmethod
|
|
def requires_build(self) -> bool:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def build(self) -> None:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def load(self) -> Callable:
|
|
pass
|
|
|
|
def fetch(self) -> Callable:
|
|
if self.requires_build:
|
|
self.build()
|
|
return self.load()
|