From ad8304e396fddb59b6d30eac80ef8cc12fbeb7ca Mon Sep 17 00:00:00 2001 From: Ilyas Moutawwakil <57442720+IlyasMoutawwakil@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:22:32 +0200 Subject: [PATCH] Code Style (#254) --- optimum_benchmark/__init__.py | 2 +- optimum_benchmark/backends/__init__.py | 2 +- optimum_benchmark/backends/ipex/backend.py | 4 ---- optimum_benchmark/backends/ipex/config.py | 6 +++--- optimum_benchmark/backends/ipex/utils.py | 1 - optimum_benchmark/cli.py | 2 +- optimum_benchmark/import_utils.py | 3 +++ setup.py | 2 +- 8 files changed, 10 insertions(+), 12 deletions(-) diff --git a/optimum_benchmark/__init__.py b/optimum_benchmark/__init__.py index 264e8e38..313fb22a 100644 --- a/optimum_benchmark/__init__.py +++ b/optimum_benchmark/__init__.py @@ -1,7 +1,7 @@ from .backends import ( BackendConfig, - IPEXConfig, INCConfig, + IPEXConfig, LlamaCppConfig, LLMSwarmConfig, ORTConfig, diff --git a/optimum_benchmark/backends/__init__.py b/optimum_benchmark/backends/__init__.py index 8ee6e155..ec146f0b 100644 --- a/optimum_benchmark/backends/__init__.py +++ b/optimum_benchmark/backends/__init__.py @@ -1,7 +1,7 @@ from .config import BackendConfig +from .ipex.config import IPEXConfig from .llama_cpp.config import LlamaCppConfig from .llm_swarm.config import LLMSwarmConfig -from .ipex.config import IPEXConfig from .neural_compressor.config import INCConfig from .onnxruntime.config import ORTConfig from .openvino.config import OVConfig diff --git a/optimum_benchmark/backends/ipex/backend.py b/optimum_benchmark/backends/ipex/backend.py index 9bb8c065..8939fdb0 100644 --- a/optimum_benchmark/backends/ipex/backend.py +++ b/optimum_benchmark/backends/ipex/backend.py @@ -1,4 +1,3 @@ -import inspect from collections import OrderedDict from tempfile import TemporaryDirectory from typing import Any, Dict @@ -6,9 +5,7 @@ import torch from hydra.utils import get_class -from ...generators.dataset_generator import DatasetGenerator from ...import_utils import is_accelerate_available, is_torch_distributed_available -from ...task_utils import TEXT_GENERATION_TASKS from ..base import Backend from ..transformers_utils import fast_weights_init from .config import IPEXConfig @@ -33,7 +30,6 @@ def __init__(self, config: IPEXConfig) -> None: else: raise NotImplementedError(f"IPEXBackend does not support task {self.config.task}") - def load(self) -> None: self.logger.info("\t+ Creating backend temporary directory") self.tmpdir = TemporaryDirectory() diff --git a/optimum_benchmark/backends/ipex/config.py b/optimum_benchmark/backends/ipex/config.py index 3beffe87..5ee4aad1 100644 --- a/optimum_benchmark/backends/ipex/config.py +++ b/optimum_benchmark/backends/ipex/config.py @@ -1,11 +1,12 @@ -from dataclasses import dataclass, field -from typing import Any, Dict, Optional +from dataclasses import dataclass +from typing import Optional from ...import_utils import ipex_version from ..config import BackendConfig TORCH_DTYPES = ["bfloat16", "float16", "float32", "auto"] + @dataclass class IPEXConfig(BackendConfig): name: str = "ipex" @@ -34,4 +35,3 @@ def __post_init__(self): if self.torch_dtype is not None and self.torch_dtype not in TORCH_DTYPES: raise ValueError(f"`torch_dtype` must be one of {TORCH_DTYPES}. Got {self.torch_dtype} instead.") - diff --git a/optimum_benchmark/backends/ipex/utils.py b/optimum_benchmark/backends/ipex/utils.py index 4f98834c..76d53864 100644 --- a/optimum_benchmark/backends/ipex/utils.py +++ b/optimum_benchmark/backends/ipex/utils.py @@ -7,4 +7,3 @@ "image-classification": "optimum.intel.IPEXModelForImageClassification", "audio-classification": "optimum.intel.IPEXModelForAudioClassification", } - diff --git a/optimum_benchmark/cli.py b/optimum_benchmark/cli.py index 769340d2..29abc074 100644 --- a/optimum_benchmark/cli.py +++ b/optimum_benchmark/cli.py @@ -10,10 +10,10 @@ Benchmark, BenchmarkConfig, EnergyStarConfig, - IPEXConfig, INCConfig, InferenceConfig, InlineConfig, + IPEXConfig, LlamaCppConfig, LLMSwarmConfig, ORTConfig, diff --git a/optimum_benchmark/import_utils.py b/optimum_benchmark/import_utils.py index cde0ceb1..9100ed04 100644 --- a/optimum_benchmark/import_utils.py +++ b/optimum_benchmark/import_utils.py @@ -158,14 +158,17 @@ def onnxruntime_version(): except importlib.metadata.PackageNotFoundError: return None + def openvino_version(): if _openvino_available: return importlib.metadata.version("openvino") + def ipex_version(): if _ipex_available: return importlib.metadata.version("intel_extension_for_pytorch") + def neural_compressor_version(): if _neural_compressor_available: return importlib.metadata.version("neural_compressor") diff --git a/setup.py b/setup.py index b85ae9a6..5e401c21 100644 --- a/setup.py +++ b/setup.py @@ -69,7 +69,7 @@ "quality": ["ruff"], "testing": ["pytest", "hydra-joblib-launcher"], # optimum backends - "ipex":[f"optimum[ipex]>={MIN_OPTIMUM_VERSION}"], + "ipex": [f"optimum[ipex]>={MIN_OPTIMUM_VERSION}"], "openvino": [f"optimum[openvino,nncf]>={MIN_OPTIMUM_VERSION}"], "onnxruntime": [f"optimum[onnxruntime]>={MIN_OPTIMUM_VERSION}"], "onnxruntime-gpu": [f"optimum[onnxruntime-gpu]>={MIN_OPTIMUM_VERSION}"],