8000 [BE] Stop using deprecated APIs in mkldnn_pattern_matcher (#143156) · pytorch/pytorch@c37185c · GitHub
[go: up one dir, main page]

Skip to content

Commit c37185c

Browse files
malfetpytorchmergebot
authored andcommitted
[BE] Stop using deprecated APIs in mkldnn_pattern_matcher (#143156)
This should fix ``` /var/lib/jenkins/workspace/test/inductor/test_mkldnn_pattern_matcher.py:157: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead. ``` Pull Request resolved: #143156 Approved by: https://github.com/kit1980
1 parent 075905b commit c37185c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/inductor/test_mkldnn_pattern_matcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def cal_conv_generated_kernel_number(mod, input, dtype, dim=4):
104104
if dtype == torch.float32:
105105
maybe_autocast = contextlib.nullcontext()
106106
else:
107-
maybe_autocast = torch.cpu.amp.autocast(dtype=dtype)
107+
maybe_autocast = torch.amp.autocast("cpu", dtype=dtype)
108108
with torch.no_grad(), maybe_autocast:
109109
output = mod(input)
110110
input_kernel, output_kernel = 0, 0
@@ -156,13 +156,13 @@ def _test_common(
156156
check_autocast == torch.bfloat16
157157
and torch.ops.mkldnn._is_mkldnn_bf16_supported()
158158
):
159-
maybe_autocast = torch.cpu.amp.autocast(dtype=torch.bfloat16)
159+
maybe_autocast = torch.amp.autocast("cpu", dtype=torch.bfloat16)
160160
atol, rtol = 1e-2, 1e-2
161161
elif (
162162
check_autocast == torch.float16
163163
and torch.ops.mkldnn._is_mkldnn_fp16_supported()
164164
):
165-
maybe_autocast = torch.cpu.amp.autocast(dtype=torch.float16)
165+
maybe_autocast = torch.amp.autocast("cpu", dtype=torch.float16)
166166
atol, rtol = 1e-2, 1e-2
167167
else:
168168
assert check_autocast == torch.float32

0 commit comments

Comments
 (0)
0