mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Apply parts of pyupgrade to torch (starting with the safest changes). This PR only does two things: removes the need to inherit from object and removes unused future imports. Pull Request resolved: https://github.com/pytorch/pytorch/pull/94308 Approved by: https://github.com/ezyang, https://github.com/albanD
22 lines
667 B
Python
22 lines
667 B
Python
from torch._C import _set_backcompat_broadcast_warn
|
|
from torch._C import _get_backcompat_broadcast_warn
|
|
from torch._C import _set_backcompat_keepdim_warn
|
|
from torch._C import _get_backcompat_keepdim_warn
|
|
|
|
|
|
class Warning:
|
|
def __init__(self, setter, getter):
|
|
self.setter = setter
|
|
self.getter = getter
|
|
|
|
def set_enabled(self, value):
|
|
self.setter(value)
|
|
|
|
def get_enabled(self):
|
|
return self.getter()
|
|
|
|
enabled = property(get_enabled, set_enabled)
|
|
|
|
broadcast_warning = Warning(_set_backcompat_broadcast_warn, _get_backcompat_broadcast_warn)
|
|
keepdim_warning = Warning(_set_backcompat_keepdim_warn, _get_backcompat_keepdim_warn)
|