-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reroute profiler to profilers (#12308)
Co-authored-by: Carlos Mocholí <[email protected]> Co-authored-by: Akihiro Nitta <[email protected]>
- Loading branch information
1 parent
64d3ddf
commit 7090ba9
Showing
20 changed files
with
324 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright The PyTorch Lightning team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# 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.base import AbstractProfiler, BaseProfiler | ||
from pytorch_lightning.profilers.advanced import AdvancedProfiler | ||
from pytorch_lightning.profilers.base import 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", | ||
"BaseProfiler", | ||
"Profiler", | ||
"AdvancedProfiler", | ||
"PassThroughProfiler", | ||
"PyTorchProfiler", | ||
"SimpleProfiler", | ||
"XLAProfiler", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright The PyTorch Lightning team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# 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.profilers.advanced import AdvancedProfiler as NewAdvancedProfiler | ||
from pytorch_lightning.utilities import rank_zero_deprecation | ||
|
||
|
||
class AdvancedProfiler(NewAdvancedProfiler): | ||
def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def] | ||
rank_zero_deprecation( | ||
"`pytorch_lightning.profiler.AdvancedProfiler` is deprecated in v1.7 and will be removed in v1.9." | ||
" Use the equivalent `pytorch_lightning.profilers.AdvancedProfiler` class instead." | ||
) | ||
super().__init__(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Copyright The PyTorch Lightning team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# 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. | ||
"""Profiler to check if there are any bottlenecks in your code.""" | ||
from abc import ABC, abstractmethod | ||
from typing import Any | ||
|
||
from pytorch_lightning.profilers.base import PassThroughProfiler as NewPassThroughProfiler | ||
from pytorch_lightning.profilers.profiler import Profiler | ||
from pytorch_lightning.utilities.rank_zero import rank_zero_deprecation | ||
|
||
|
||
class AbstractProfiler(ABC): | ||
"""Specification of a profiler. | ||
See deprecation warning below | ||
.. deprecated:: v1.6 | ||
`AbstractProfiler` was deprecated in v1.6 and will be removed in v1.8. | ||
Please use `Profiler` instead. | ||
""" | ||
|
||
@abstractmethod | ||
def start(self, action_name: str) -> None: | ||
"""Defines how to start recording an action.""" | ||
|
||
@abstractmethod | ||
def stop(self, action_name: str) -> None: | ||
"""Defines how to record the duration once an action is complete.""" | ||
|
||
@abstractmethod | ||
def summary(self) -> str: | ||
"""Create profiler summary in text format.""" | ||
|
||
@abstractmethod | ||
def setup(self, **kwargs: Any) -> None: | ||
"""Execute arbitrary pre-profiling set-up steps as defined by subclass.""" | ||
|
||
@abstractmethod | ||
def teardown(self, **kwargs: Any) -> None: | ||
"""Execute arbitrary post-profiling tear-down steps as defined by subclass.""" | ||
|
||
|
||
class BaseProfiler(Profiler): | ||
""" | ||
.. deprecated:: v1.6 | ||
`BaseProfiler` was deprecated in v1.6 and will be removed in v1.8. | ||
Please use `Profiler` instead. | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): # type: ignore[no-untyped-def] | ||
rank_zero_deprecation( | ||
"`BaseProfiler` was deprecated in v1.6 and will be removed in v1.8. Please use `Profiler` instead." | ||
) | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class PassThroughProfiler(NewPassThroughProfiler): | ||
def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def] | ||
rank_zero_deprecation( | ||
"`pytorch_lightning.profiler.PassThroughProfiler` is deprecated in v1.7 and will be removed in v1.9." | ||
" Use the equivalent `pytorch_lightning.profilers.PassThroughProfiler` class instead." | ||
) | ||
super().__init__(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright The PyTorch Lightning team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# 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.profilers.profiler import Profiler as NewProfiler | ||
from pytorch_lightning.utilities import rank_zero_deprecation | ||
|
||
|
||
class Profiler(NewProfiler): | ||
""" | ||
.. deprecated:: v1.6 | ||
`pytorch_lightning.profiler.Profiler` is deprecated in v1.7 and will be removed in v1.9. | ||
Use the equivalent `pytorch_lightning.profilers.Profiler` class instead. | ||
""" | ||
|
||
def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def] | ||
rank_zero_deprecation( | ||
"`pytorch_lightning.profiler.Profiler` is deprecated in v1.7 and will be removed in v1.9." | ||
" Use the equivalent `pytorch_lightning.profilers.Profiler` class instead." | ||
) | ||
super().__init__(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright The PyTorch Lightning team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# 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.profilers.pytorch import PyTorchProfiler as NewPyTorchProfiler | ||
from pytorch_lightning.profilers.pytorch import RegisterRecordFunction as NewRegisterRecordFuncion | ||
from pytorch_lightning.profilers.pytorch import ScheduleWrapper as NewScheduleWrapper | ||
from pytorch_lightning.utilities import rank_zero_deprecation | ||
|
||
|
||
class RegisterRecordFunction(NewRegisterRecordFuncion): | ||
def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def] | ||
rank_zero_deprecation( | ||
"`pytorch_lightning.profiler.pytorch.RegisterRecordFunction` is deprecated in v1.7 and will be removed in" | ||
" in v1.9. Use the equivalent `pytorch_lightning.profilers.pytorch.RegisterRecordFunction` class instead." | ||
) | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class ScheduleWrapper(NewScheduleWrapper): | ||
def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def] | ||
rank_zero_deprecation( | ||
"`pytorch_lightning.profiler.pytorch.ScheduleWrapper` is deprecated in v1.7 and will be removed in v1.9." | ||
" Use the equivalent `pytorch_lightning.profilers.pytorch.ScheduleWrapper` class instead." | ||
) | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class PyTorchProfiler(NewPyTorchProfiler): | ||
def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def] | ||
rank_zero_deprecation( | ||
"`pytorch_lightning.profiler.PyTorchProfiler` is deprecated in v1.7 and will be removed in v1.9." | ||
" Use the equivalent `pytorch_lightning.profilers.PyTorchProfiler` class instead." | ||
) | ||
super().__init__(*args, **kwargs) |
Oops, something went wrong.