[BE] Deprecate has_XYZ attributes (#103279)

Use [`__getattr__`](https://peps.python.org/pep-0562/) to raise warningwhen one tries to access `has_XYZ` methods and recommend appropriate `torch.backends.XYZ` methods

Make respective properties in `torch._C` private (by prefixing them with underscore), to exclude from `from torch._C import *`.

Added `warnings.simplefilter` to workaround Python-3.11 torch.compile lineinfo issue.

Fixes https://github.com/pytorch/pytorch/issues/102484

Pull Request resolved: https://github.com/pytorch/pytorch/pull/103279
Approved by: https://github.com/janeyx99, https://github.com/Skylion007
This commit is contained in:
Nikita Shulga
2023-06-10 05:17:17 +00:00
committed by PyTorch MergeBot
parent 0496d70aa0
commit 4cfa06f706
24 changed files with 74 additions and 53 deletions

View File

@ -41,7 +41,7 @@ def is_avx512_supported():
IS_AVX512_UNSUPPORTED = not is_avx512_supported()
LLGA_FUSION_GROUP = 'prim::oneDNNFusionGroup'
LLGA_NOT_ENABLED = not torch._C.has_mkldnn or IS_WINDOWS or IS_MACOS
LLGA_NOT_ENABLED = not torch.backends.mkldnn.is_available() or IS_WINDOWS or IS_MACOS
def warmup_forward(f, *args, profiling_count=3):
for i in range(profiling_count):