Files
pytorch/torch/_functorch/pytree_hacks.py
Xuehai Pan 67ef2683d9 [BE] wrap deprecated function/class with typing_extensions.deprecated (#127689)
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.

Resolves #126888

- #126888

This PR is split from PR #126898.

- #126898

------

Pull Request resolved: https://github.com/pytorch/pytorch/pull/127689
Approved by: https://github.com/Skylion007
2024-06-02 12:30:43 +00:00

24 lines
698 B
Python

# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import warnings
# TODO: remove this file when the migration of the pytree utility is done
from torch.utils._pytree import tree_map_, treespec_pprint
__all__ = ["tree_map_", "treespec_pprint"]
with warnings.catch_warnings():
warnings.simplefilter("always")
warnings.warn(
"`torch._functorch.pytree_hacks` is deprecated and will be removed in a future release. "
"Please `use torch.utils._pytree` instead.",
DeprecationWarning,
stacklevel=2,
)