Skip to content

Commit

Permalink
engine refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Ashwin Vaidya <[email protected]>
  • Loading branch information
ashwinvaidya17 committed Jan 27, 2025
1 parent 528141d commit e47e6d9
Show file tree
Hide file tree
Showing 17 changed files with 1,290 additions and 1,195 deletions.
4 changes: 4 additions & 0 deletions src/otx/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""OTX backends."""

# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
4 changes: 4 additions & 0 deletions src/otx/backend/native/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Native backend."""

# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
8 changes: 8 additions & 0 deletions src/otx/backend/native/engine/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Native engine."""

# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

from .engine import NativeEngine

__all__ = ["NativeEngine"]
File renamed without changes.
1,206 changes: 1,206 additions & 0 deletions src/otx/backend/native/engine/engine.py

Large diffs are not rendered by default.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import yaml
from lightning import Callback

from otx.backend.native.engine.adaptive_bs import adapt_batch_size
from otx.core.config.hpo import HpoConfig
from otx.core.optimizer.callable import OptimizerCallableSupportHPO
from otx.core.schedulers import LinearWarmupSchedulerCallable, SchedulerCallableSupportHPO
from otx.core.types.device import DeviceType
from otx.core.types.task import OTXTaskType
from otx.engine.adaptive_bs import adapt_batch_size
from otx.hpo import HyperBand, run_hpo_loop
from otx.utils.device import is_xpu_available
from otx.utils.utils import (
Expand Down Expand Up @@ -85,7 +85,7 @@ def execute_hpo(
train_args=train_args,
)
if (
train_args.get("adaptive_bs", None) == "Full"
train_args.get("adaptive_bs") == "Full"
and "datamodule.train_subset.batch_size" in hpo_configurator.hpo_config["search_space"]
):
logger.info("Because adaptive_bs is set as Full, batch size is excluded from HPO.")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions src/otx/engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
# Copyright (C) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

from typing import TYPE_CHECKING

from otx.backend.native.engine import NativeEngine

from .engine import Engine

__all__ = ["Engine"]

if TYPE_CHECKING:
from otx.types import DATA, MODEL

SUPPORTED_ENGINES = [NativeEngine]


def create_engine(model: "MODEL", data: "DATA") -> Engine:
"""Create an engine."""
for engine in SUPPORTED_ENGINES:
if engine.is_supported(model, data):
return engine(model=model, data=data)
msg = f"No engine found for model {model} and data {data}"
raise ValueError(msg)
Loading

0 comments on commit e47e6d9

Please sign in to comment.