8000 Add deprecated autocast comments for doc · pytorch/pytorch@6cdfec8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6cdfec8

Browse files
committed
Add deprecated autocast comments for doc
ghstack-source-id: e746615 Pull Request resolved: #126062
1 parent afda668 commit 6cdfec8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

torch/cpu/amp/autocast_mode.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Any
2+
import warnings
23

34
import torch
45

@@ -8,7 +9,7 @@
89
class autocast(torch.amp.autocast_mode.autocast):
910
r"""
1011
See :class:`torch.autocast`.
11-
``torch.cpu.amp.autocast(args...)`` is equivalent to ``torch.autocast("cpu", args...)``
12+
``torch.cpu.amp.autocast(args...)`` is deprecated. Please use ``torch.amp.autocast("cpu", args...)`` instead.
1213
"""
1314

1415
def __init__(
@@ -22,6 +23,7 @@ def __init__(
2223
self.device = "cpu"
2324
self.fast_dtype = dtype
2425
return
26+
warnings.warn("torch.cpu.amp.autocast(args...) is deprecated. Please use torch.amp.autocast('cpu', args...) instead.")
2527
super().__init__(
2628
"cpu", enabled=enabled, dtype=dtype, cache_enabled=cache_enabled
2729
)

torch/cuda/amp/autocast_mode.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import collections
22
import functools
3+
import warnings
34

45
import torch
56

@@ -17,7 +18,7 @@
1718
class autocast(torch.amp.autocast_mode.autocast):
1819
r"""See :class:`torch.autocast`.
1920
20-
``torch.cuda.amp.autocast(args...)`` is equivalent to ``torch.autocast("cuda", args...)``
21+
``torch.cuda.amp.autocast(args...)`` is deprecated. Please use ``torch.amp.autocast("cuda", args...)`` instead.
2122
"""
2223

2324
def __init__(
@@ -31,6 +32,7 @@ def __init__(
3132
self.device = "cuda"
3233
self.fast_dtype = dtype
3334
return
35+
warnings.warn("torch.cuda.amp.autocast(args...) is deprecated. Please use torch.amp.autocast('cpu', args...) instead.")
3436
super().__init__(
3537
"cuda", enabled=enabled, dtype=dtype, cache_enabled=cache_enabled
3638
)

0 commit comments

Comments
 (0)
0