8000 [Doc] Add deprecated autocast comments for doc by guangyey · Pull Request #126062 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[Doc] Add deprecated autocast comments for doc #126062

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

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
6 changes: 5 additions & 1 deletion torch/cpu/amp/autocast_mode.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from typing import Any

import torch
Expand All @@ -8,7 +9,7 @@
class autocast(torch.amp.autocast_mode.autocast):
r"""
See :class:`torch.autocast`.
``torch.cpu.amp.autocast(args...)`` is equivalent to ``torch.autocast("cpu", args...)``
``torch.cpu.amp.autocast(args...)`` is deprecated. Please use ``torch.amp.autocast("cpu", args...)`` instead.
"""

def __init__(
Expand All @@ -22,6 +23,9 @@ def __init__(
self.device = "cpu"
8000 self.fast_dtype = dtype
return
warnings.warn(
"torch.cpu.amp.autocast(args...) is deprecated. Please use torch.amp.autocast('cpu', args...) instead."
)
super().__init__(
"cpu", enabled=enabled, dtype=dtype, cache_enabled=cache_enabled
)
Expand Down
6 changes: 5 additions & 1 deletion torch/cuda/amp/autocast_mode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import collections
import functools
import warnings

import torch

Expand All @@ -17,7 +18,7 @@
class autocast(torch.amp.autocast_mode.autocast):
r"""See :class:`torch.autocast`.

``torch.cuda.amp.autocast(args...)`` is equivalent to ``torch.autocast("cuda", args...)``
``torch.cuda.amp.autocast(args...)`` is deprecated. Please use ``torch.amp.autocast("cuda", args...)`` instead.
"""

def __init__(
Expand All @@ -31,6 +32,9 @@ def __init__(
self.device = "cuda"
self.fast_dtype = dtype
return
warnings.warn(
"torch.cuda.amp.autocast(args...) is deprecated. Please use torch.amp.autocast('cpu', args...) instead."
)
super().__init__(
"cuda", enabled=enabled, dtype=dtype, cache_enabled=cache_enabled
)
Expand Down
0