Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engine Refactor part 1 #4187

Open
wants to merge 3 commits into
base: feature/v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 OTXEngine

__all__ = ["OTXEngine"]
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
if TYPE_CHECKING:
from lightning import LightningModule, Trainer

from otx.engine.engine import Engine
from otx.backend.native.engine import OTXEngine

logger = logging.getLogger(__name__)


def adapt_batch_size(
engine: Engine,
engine: OTXEngine,
not_increase: bool = True,
callbacks: list[Callback] | Callback | None = None,
**train_args,
Expand Down Expand Up @@ -94,7 +94,7 @@ def _adjust_train_args(train_args: dict[str, Any]) -> dict[str, Any]:
return train_args


def _train_model(bs: int, engine: Engine, callbacks: list[Callback] | Callback | None = None, **train_args) -> None:
def _train_model(bs: int, engine: OTXEngine, callbacks: list[Callback] | Callback | None = None, **train_args) -> None:
if bs <= 0:
msg = f"Batch size should be greater than 0, but {bs} is given."
raise ValueError(msg)
Expand Down Expand Up @@ -167,7 +167,7 @@ def _scale_batch_reset_params(trainer: Trainer, steps_per_trial: int) -> None:
trainer.limit_val_batches = steps_per_trial


def _apply_new_batch_size(engine: Engine, new_batch_size: int) -> None:
def _apply_new_batch_size(engine: OTXEngine, new_batch_size: int) -> None:
origin_bs = engine.datamodule.train_subset.batch_size
if new_batch_size == origin_bs:
return
Expand Down
Loading
Loading