diff --git a/iprbench/core.py b/iprbench/core.py index df502db..5c4845c 100644 --- a/iprbench/core.py +++ b/iprbench/core.py @@ -9,15 +9,6 @@ BenchParamType = Union[int, str] BenchmarkConfig = Dict[BenchParamId, BenchParamType] -class Singleton(type): - _instances = {} - - def __call__(cls, *args, **kwargs): - if cls not in cls._instances: - cls._instances[cls] = super(type(cls), cls).__call__(*args, **kwargs) # pylint: disable=bad-super-call, no-member - return cls._instances[cls] - - class BenchParam(): '''a parameter of a benchmark diff --git a/iprbench/main.py b/iprbench/main.py index 7e43fb0..a100e01 100644 --- a/iprbench/main.py +++ b/iprbench/main.py @@ -1,6 +1,7 @@ -from .core import BenchmarkId, IBenchmark, Singleton +from .core import BenchmarkId, IBenchmark from .benchmarks.hibench import HiBench from .benchmarks.mamul1 import MaMul1 +from .util import Singleton import logging import argparse from pathlib import Path diff --git a/iprbench/util.py b/iprbench/util.py index dbe1723..00c83a7 100644 --- a/iprbench/util.py +++ b/iprbench/util.py @@ -5,6 +5,15 @@ import shutil import logging +class Singleton(type): + _instances = {} + + def __call__(cls, *args, **kwargs): + if cls not in cls._instances: + cls._instances[cls] = super(type(cls), cls).__call__(*args, **kwargs) # pylint: disable=bad-super-call, no-member + return cls._instances[cls] + + def _extract_res_dir_using_py_3_7(dir_resource_package: str, dest_path: Path): dest_path.mkdir(parents=True, exist_ok=True) dir_contents = importlib.resources.contents(dir_resource_package)