From f6aae27671033c1285ca9280e4e9385f48084b29 Mon Sep 17 00:00:00 2001 From: awaelchli Date: Wed, 22 Jun 2022 16:36:31 +0200 Subject: [PATCH] Reroute profiler to profilers (#12308) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Carlos MocholĂ­ Co-authored-by: Akihiro Nitta --- examples/pl_basics/profiler_example.py | 2 +- .../{profiler => profilers}/__init__.py | 12 ++++++------ .../{profiler => profilers}/advanced.py | 2 +- .../{profiler => profilers}/base.py | 2 +- .../{profiler => profilers}/profiler.py | 0 .../{profiler => profilers}/pytorch.py | 2 +- .../{profiler => profilers}/simple.py | 2 +- src/pytorch_lightning/{profiler => profilers}/xla.py | 2 +- src/pytorch_lightning/trainer/trainer.py | 2 +- tests/tests_pytorch/core/test_datamodules.py | 2 +- .../tests_pytorch/deprecated_api/test_remove_1-8.py | 2 +- .../{profiler => profilers}/__init__.py | 0 .../{profiler => profilers}/test_profiler.py | 4 ++-- .../{profiler => profilers}/test_xla_profiler.py | 2 +- tests/tests_pytorch/run_standalone_tests.sh | 4 ++-- tests/tests_pytorch/utilities/test_cli.py | 2 +- tests/tests_pytorch/utilities/test_fetching.py | 2 +- 17 files changed, 22 insertions(+), 22 deletions(-) rename src/pytorch_lightning/{profiler => profilers}/__init__.py (65%) rename src/pytorch_lightning/{profiler => profilers}/advanced.py (98%) rename src/pytorch_lightning/{profiler => profilers}/base.py (97%) rename src/pytorch_lightning/{profiler => profilers}/profiler.py (100%) rename src/pytorch_lightning/{profiler => profilers}/pytorch.py (99%) rename src/pytorch_lightning/{profiler => profilers}/simple.py (99%) rename src/pytorch_lightning/{profiler => profilers}/xla.py (98%) rename tests/tests_pytorch/{profiler => profilers}/__init__.py (100%) rename tests/tests_pytorch/{profiler => profilers}/test_profiler.py (99%) rename tests/tests_pytorch/{profiler => profilers}/test_xla_profiler.py (97%) diff --git a/examples/pl_basics/profiler_example.py b/examples/pl_basics/profiler_example.py index 89074548683c2..050740e3ce314 100644 --- a/examples/pl_basics/profiler_example.py +++ b/examples/pl_basics/profiler_example.py @@ -31,7 +31,7 @@ import torchvision.transforms as T from pytorch_lightning import cli_lightning_logo, LightningDataModule, LightningModule -from pytorch_lightning.profiler.pytorch import PyTorchProfiler +from pytorch_lightning.profilers.pytorch import PyTorchProfiler from pytorch_lightning.utilities.cli import LightningCLI DEFAULT_CMD_LINE = ( diff --git a/src/pytorch_lightning/profiler/__init__.py b/src/pytorch_lightning/profilers/__init__.py similarity index 65% rename from src/pytorch_lightning/profiler/__init__.py rename to src/pytorch_lightning/profilers/__init__.py index 60a1fa7ed869e..dad105135fa01 100644 --- a/src/pytorch_lightning/profiler/__init__.py +++ b/src/pytorch_lightning/profilers/__init__.py @@ -11,12 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from pytorch_lightning.profiler.advanced import AdvancedProfiler -from pytorch_lightning.profiler.base import AbstractProfiler, BaseProfiler, PassThroughProfiler -from pytorch_lightning.profiler.profiler import Profiler -from pytorch_lightning.profiler.pytorch import PyTorchProfiler -from pytorch_lightning.profiler.simple import SimpleProfiler -from pytorch_lightning.profiler.xla import XLAProfiler +from pytorch_lightning.profilers.advanced import AdvancedProfiler +from pytorch_lightning.profilers.base import AbstractProfiler, BaseProfiler, PassThroughProfiler +from pytorch_lightning.profilers.profiler import Profiler +from pytorch_lightning.profilers.pytorch import PyTorchProfiler +from pytorch_lightning.profilers.simple import SimpleProfiler +from pytorch_lightning.profilers.xla import XLAProfiler __all__ = [ "AbstractProfiler", diff --git a/src/pytorch_lightning/profiler/advanced.py b/src/pytorch_lightning/profilers/advanced.py similarity index 98% rename from src/pytorch_lightning/profiler/advanced.py rename to src/pytorch_lightning/profilers/advanced.py index a776f50764589..214d67e52eb4c 100644 --- a/src/pytorch_lightning/profiler/advanced.py +++ b/src/pytorch_lightning/profilers/advanced.py @@ -19,7 +19,7 @@ from pathlib import Path from typing import Dict, Optional, Union -from pytorch_lightning.profiler.profiler import Profiler +from pytorch_lightning.profilers.profiler import Profiler log = logging.getLogger(__name__) diff --git a/src/pytorch_lightning/profiler/base.py b/src/pytorch_lightning/profilers/base.py similarity index 97% rename from src/pytorch_lightning/profiler/base.py rename to src/pytorch_lightning/profilers/base.py index b4eae688ebf80..b91f628013a33 100644 --- a/src/pytorch_lightning/profiler/base.py +++ b/src/pytorch_lightning/profilers/base.py @@ -15,7 +15,7 @@ from abc import ABC, abstractmethod from typing import Any -from pytorch_lightning.profiler.profiler import Profiler +from pytorch_lightning.profilers.profiler import Profiler from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation diff --git a/src/pytorch_lightning/profiler/profiler.py b/src/pytorch_lightning/profilers/profiler.py similarity index 100% rename from src/pytorch_lightning/profiler/profiler.py rename to src/pytorch_lightning/profilers/profiler.py diff --git a/src/pytorch_lightning/profiler/pytorch.py b/src/pytorch_lightning/profilers/pytorch.py similarity index 99% rename from src/pytorch_lightning/profiler/pytorch.py rename to src/pytorch_lightning/profilers/pytorch.py index 062031bafa2a6..c9340444a06eb 100644 --- a/src/pytorch_lightning/profiler/pytorch.py +++ b/src/pytorch_lightning/profilers/pytorch.py @@ -23,7 +23,7 @@ from torch import nn, Tensor from torch.autograd.profiler import record_function -from pytorch_lightning.profiler.profiler import Profiler +from pytorch_lightning.profilers.profiler import Profiler from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.imports import _KINETO_AVAILABLE from pytorch_lightning.utilities.rank_zero import rank_zero_warn diff --git a/src/pytorch_lightning/profiler/simple.py b/src/pytorch_lightning/profilers/simple.py similarity index 99% rename from src/pytorch_lightning/profiler/simple.py rename to src/pytorch_lightning/profilers/simple.py index f49dc8dc97d0c..20d76f9b2d378 100644 --- a/src/pytorch_lightning/profiler/simple.py +++ b/src/pytorch_lightning/profilers/simple.py @@ -21,7 +21,7 @@ import numpy as np -from pytorch_lightning.profiler.profiler import Profiler +from pytorch_lightning.profilers.profiler import Profiler log = logging.getLogger(__name__) diff --git a/src/pytorch_lightning/profiler/xla.py b/src/pytorch_lightning/profilers/xla.py similarity index 98% rename from src/pytorch_lightning/profiler/xla.py rename to src/pytorch_lightning/profilers/xla.py index 010b083ff1b95..0f86d63b546eb 100644 --- a/src/pytorch_lightning/profiler/xla.py +++ b/src/pytorch_lightning/profilers/xla.py @@ -14,7 +14,7 @@ import logging from typing import Dict -from pytorch_lightning.profiler.profiler import Profiler +from pytorch_lightning.profilers.profiler import Profiler from pytorch_lightning.utilities import _TPU_AVAILABLE from pytorch_lightning.utilities.exceptions import MisconfigurationException diff --git a/src/pytorch_lightning/trainer/trainer.py b/src/pytorch_lightning/trainer/trainer.py index 85de7acbe352a..f64afddca79fa 100644 --- a/src/pytorch_lightning/trainer/trainer.py +++ b/src/pytorch_lightning/trainer/trainer.py @@ -55,7 +55,7 @@ PrecisionPlugin, ) from pytorch_lightning.plugins.environments.slurm_environment import SLURMEnvironment -from pytorch_lightning.profiler import ( +from pytorch_lightning.profilers import ( AdvancedProfiler, PassThroughProfiler, Profiler, diff --git a/tests/tests_pytorch/core/test_datamodules.py b/tests/tests_pytorch/core/test_datamodules.py index 2c6625ac0772d..bfcb49a306d88 100644 --- a/tests/tests_pytorch/core/test_datamodules.py +++ b/tests/tests_pytorch/core/test_datamodules.py @@ -24,7 +24,7 @@ from pytorch_lightning import LightningDataModule, Trainer from pytorch_lightning.callbacks import ModelCheckpoint from pytorch_lightning.demos.boring_classes import BoringDataModule, BoringModel -from pytorch_lightning.profiler.simple import SimpleProfiler +from pytorch_lightning.profilers.simple import SimpleProfiler from pytorch_lightning.trainer.states import TrainerFn from pytorch_lightning.utilities import _OMEGACONF_AVAILABLE, AttributeDict from pytorch_lightning.utilities.exceptions import MisconfigurationException diff --git a/tests/tests_pytorch/deprecated_api/test_remove_1-8.py b/tests/tests_pytorch/deprecated_api/test_remove_1-8.py index 54292a7d32013..685eaf1e0d5ca 100644 --- a/tests/tests_pytorch/deprecated_api/test_remove_1-8.py +++ b/tests/tests_pytorch/deprecated_api/test_remove_1-8.py @@ -40,7 +40,7 @@ from pytorch_lightning.plugins.training_type.single_device import SingleDevicePlugin from pytorch_lightning.plugins.training_type.single_tpu import SingleTPUPlugin from pytorch_lightning.plugins.training_type.tpu_spawn import TPUSpawnPlugin -from pytorch_lightning.profiler import AbstractProfiler, AdvancedProfiler, BaseProfiler, Profiler, SimpleProfiler +from pytorch_lightning.profilers import AbstractProfiler, AdvancedProfiler, BaseProfiler, Profiler, SimpleProfiler from pytorch_lightning.strategies import ParallelStrategy from pytorch_lightning.trainer.configuration_validator import _check_datamodule_checkpoint_hooks from pytorch_lightning.trainer.states import RunningStage diff --git a/tests/tests_pytorch/profiler/__init__.py b/tests/tests_pytorch/profilers/__init__.py similarity index 100% rename from tests/tests_pytorch/profiler/__init__.py rename to tests/tests_pytorch/profilers/__init__.py diff --git a/tests/tests_pytorch/profiler/test_profiler.py b/tests/tests_pytorch/profilers/test_profiler.py similarity index 99% rename from tests/tests_pytorch/profiler/test_profiler.py rename to tests/tests_pytorch/profilers/test_profiler.py index a74c2cde222a6..127d373f3e574 100644 --- a/tests/tests_pytorch/profiler/test_profiler.py +++ b/tests/tests_pytorch/profilers/test_profiler.py @@ -26,8 +26,8 @@ from pytorch_lightning.callbacks import EarlyStopping, StochasticWeightAveraging from pytorch_lightning.demos.boring_classes import BoringModel, ManualOptimBoringModel from pytorch_lightning.loggers import CSVLogger, TensorBoardLogger -from pytorch_lightning.profiler import AdvancedProfiler, PassThroughProfiler, PyTorchProfiler, SimpleProfiler -from pytorch_lightning.profiler.pytorch import RegisterRecordFunction, warning_cache +from pytorch_lightning.profilers import AdvancedProfiler, PassThroughProfiler, PyTorchProfiler, SimpleProfiler +from pytorch_lightning.profilers.pytorch import RegisterRecordFunction, warning_cache from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.imports import _KINETO_AVAILABLE from tests_pytorch.helpers.runif import RunIf diff --git a/tests/tests_pytorch/profiler/test_xla_profiler.py b/tests/tests_pytorch/profilers/test_xla_profiler.py similarity index 97% rename from tests/tests_pytorch/profiler/test_xla_profiler.py rename to tests/tests_pytorch/profilers/test_xla_profiler.py index c28b829535b4c..7f5b0ecdd7740 100644 --- a/tests/tests_pytorch/profiler/test_xla_profiler.py +++ b/tests/tests_pytorch/profilers/test_xla_profiler.py @@ -18,7 +18,7 @@ from pytorch_lightning import Trainer from pytorch_lightning.demos.boring_classes import BoringModel -from pytorch_lightning.profiler import XLAProfiler +from pytorch_lightning.profilers import XLAProfiler from pytorch_lightning.utilities import _TPU_AVAILABLE from tests_pytorch.helpers.runif import RunIf diff --git a/tests/tests_pytorch/run_standalone_tests.sh b/tests/tests_pytorch/run_standalone_tests.sh index 3dd80324539ce..713b7ab08d5fa 100644 --- a/tests/tests_pytorch/run_standalone_tests.sh +++ b/tests/tests_pytorch/run_standalone_tests.sh @@ -38,7 +38,7 @@ parametrizations=${parametrizations//"tests/tests_pytorch/"/} parametrizations_arr=($parametrizations) # tests to skip - space separated -blocklist='profiler/test_profiler.py::test_pytorch_profiler_nested_emit_nvtx utilities/test_warnings.py' +blocklist='profilers/test_profiler.py::test_pytorch_profiler_nested_emit_nvtx utilities/test_warnings.py' report='' for i in "${!parametrizations_arr[@]}"; do @@ -58,7 +58,7 @@ for i in "${!parametrizations_arr[@]}"; do done if nvcc --version; then - nvprof --profile-from-start off -o trace_name.prof -- python ${defaults} profiler/test_profiler.py::test_pytorch_profiler_nested_emit_nvtx + nvprof --profile-from-start off -o trace_name.prof -- python ${defaults} profilers/test_profiler.py::test_pytorch_profiler_nested_emit_nvtx fi # needs to run outside of `pytest` diff --git a/tests/tests_pytorch/utilities/test_cli.py b/tests/tests_pytorch/utilities/test_cli.py index f499acf41e6d0..1920344a7d5cc 100644 --- a/tests/tests_pytorch/utilities/test_cli.py +++ b/tests/tests_pytorch/utilities/test_cli.py @@ -36,7 +36,7 @@ from pytorch_lightning.demos.boring_classes import BoringDataModule, BoringModel from pytorch_lightning.loggers import _COMET_AVAILABLE, _NEPTUNE_AVAILABLE, _WANDB_AVAILABLE, TensorBoardLogger from pytorch_lightning.plugins.environments import SLURMEnvironment -from pytorch_lightning.profiler import PyTorchProfiler +from pytorch_lightning.profilers import PyTorchProfiler from pytorch_lightning.strategies import DDPStrategy from pytorch_lightning.trainer.states import TrainerFn from pytorch_lightning.utilities import _TPU_AVAILABLE diff --git a/tests/tests_pytorch/utilities/test_fetching.py b/tests/tests_pytorch/utilities/test_fetching.py index a362521bc9c52..50c9b85970bf0 100644 --- a/tests/tests_pytorch/utilities/test_fetching.py +++ b/tests/tests_pytorch/utilities/test_fetching.py @@ -22,7 +22,7 @@ from pytorch_lightning import Callback, LightningDataModule, Trainer from pytorch_lightning.demos.boring_classes import BoringModel, RandomDataset -from pytorch_lightning.profiler import SimpleProfiler +from pytorch_lightning.profilers import SimpleProfiler from pytorch_lightning.trainer.supporters import CombinedLoader from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.fetching import DataFetcher, DataLoaderIterDataFetcher, InterBatchParallelDataFetcher