[test][easy] Add debug utils for cpu select algorithm test (#135038)
Summary: Add debug utils to debug a flaky test in fbcode ci.
Some context: https://github.com/pytorch/pytorch/pull/126545
Test Plan: ci
Differential Revision: D62005445
Pull Request resolved: https://github.com/pytorch/pytorch/pull/135038
Approved by: https://github.com/jgong5, https://github.com/XuehaiPan
diff --git a/test/inductor/test_cpu_select_algorithm.py b/test/inductor/test_cpu_select_algorithm.py
index ca1d4f1..813be61 100644
--- a/test/inductor/test_cpu_select_algorithm.py
+++ b/test/inductor/test_cpu_select_algorithm.py
@@ -1,6 +1,8 @@
# Owner(s): ["oncall: cpu inductor"]
import contextlib
import functools
+import logging
+import os
import sys
import unittest
from typing import Optional
@@ -25,6 +27,9 @@
from torch.testing._internal.common_utils import IS_MACOS, parametrize, TEST_MKL
+log = logging.getLogger(__name__)
+
+
try:
try:
from . import test_cpu_repro, test_torchinductor
@@ -264,6 +269,19 @@
def forward(self, x):
return self.epilogue(self.linear(x))
+ # TODO: debug utils, safe to remove in Oct 2024
+ if inductor_config.is_fbcode():
+ log.warning(
+ f"DEBUG: torch.backends.mkl.is_available() is {torch.backends.mkl.is_available()}, " # noqa: G004
+ f"torch.ops.mkldnn._is_mkldnn_fp16_supported() is {torch.ops.mkldnn._is_mkldnn_fp16_supported()}, "
+ f"torch.ops.mkldnn._is_mkldnn_bf16_supported() is {torch.ops.mkldnn._is_mkldnn_bf16_supported()}, "
+ f"inductor_config.freezing is {inductor_config.freezing}, "
+ f"mkldnn._is_mkldnn_acl_supported() is {torch.ops.mkldnn._is_mkldnn_acl_supported()}, "
+ f"torch._C.has_mkl is {torch._C.has_mkl}, "
+ f"PYTORCH_TEST_FBCODE is {os.getenv('PYTORCH_TEST_FBCODE')}, "
+ f"PYTORCH_TEST_REMOTE_GPU is {os.getenv('PYTORCH_TEST_REMOTE_GPU')}, "
+ )
+
counters.clear()
v = torch.randn(batch_size, in_features).to(dtype=dtype)
u = torch.randn(batch_size, out_features).to(dtype=dtype)