Skip to content

Commit

Permalink
fix: close #160
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhaoyilunnn committed Apr 18, 2024
1 parent cd904fb commit 0f69746
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions quafu/algorithms/interface_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .interface.torch import TorchTransformer

PROVIDERS = {"torch": TorchTransformer}


class InterfaceProvider:
_init = False
_providers = {}

@classmethod
def get(cls, name: str):
if name not in PROVIDERS:
if not cls._init:
from .interface.torch import TorchTransformer

cls._providers["torch"] = TorchTransformer

cls._init = True

if name not in cls._providers:
raise NotImplementedError(f"Unsupported interface: {name}")
return PROVIDERS[name]
return cls._providers[name]

0 comments on commit 0f69746

Please sign in to comment.