[BE] wrap deprecated function/class with typing_extensions.deprecated (#126898)

Use `typing_extensions.deprecated` for deprecation annotation if possible. Otherwise, add `category=FutureWarning` to `warnings.warn("message")` if the category is missing.

Note that only warnings that their messages contain `[Dd]eprecat(ed|ion)` are updated in this PR.

UPDATE: Use `FutureWarning` instead of `DeprecationWarning`.

Resolves #126888

- #126888

Pull Request resolved: https://github.com/pytorch/pytorch/pull/126898
Approved by: https://github.com/albanD
This commit is contained in:
Xuehai Pan
2024-05-29 12:09:24 +00:00
committed by PyTorch MergeBot
parent 699db7988d
commit 749a132fb0
117 changed files with 700 additions and 478 deletions

View File

@ -359,9 +359,12 @@ def to_sparse_semi_structured(
[-4370, -4370, -4370, ..., -4370, -4370, -4370]], device='cuda:0', dtype=torch.int16))
"""
if transposed:
raise DeprecationWarning(
"Setting transpose from to_sparse_semi_structured is deprecated and will be removed in a future release."
"SparseSemiStructuredTensor only support contiguous input tensors. "
warnings.warn(
"Setting transpose from `to_sparse_semi_structured` is deprecated "
"and will be removed in a future release. "
"`SparseSemiStructuredTensor` only support contiguous input tensors.",
FutureWarning,
stacklevel=2,
)
# set from _FORCE_CUTLASS flag