-
Notifications
You must be signed in to change notification settings - Fork 22.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BE] Make legacy type storage warning point to the caller (#113601)
`@classproperty` decorator adds another wrapper, so warning with default stacklevel (2) would always point to the wrapper implementation rather than at callee. For example, before this change following code ```python import torch print(torch.FloatStorage.dtype) ``` will produce inactionable warning: ``` /Users/nshulga/git/pytorch/pytorch/torch/_utils.py:836: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() return self.fget.__get__(instance, owner)() ``` But after the change warning turns into: ``` /Users/nshulga/test/bar.py:2: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() print(torch.FloatStorage.dtype) ``` Discovered while reading #109108 Pull Request resolved: #113601 Approved by: https://github.com/kit1980
- Loading branch information
1 parent
ffc3731
commit b3a76cc
Showing
1 changed file
with
17 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters