Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate some methods for NNCF 2.6 release #2083

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions nncf/torch/nncf_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,26 +967,6 @@ def nncf(self) -> NNCFNetworkInterface:
# self._nncf is being set in the creation function defined in the NNCFNetworkMeta metaclass
return self._nncf

def __getattr__(self, key):
"""
Only defined for purposes of deprecation warnings. This method should be removed after v2.5.0.
"""
try:
return super().__getattr__(key)
except AttributeError as e:
if hasattr(self._nncf, key):
warning_deprecated(
"Old style of accessing NNCF-specific attributes and methods on NNCFNetwork "
"objects is deprecated. "
"Access the NNCF-specific attrs through the NNCFInterface, which is "
"set up as an `nncf` attribute on the compressed model object.\n"
"For instance, instead of `compressed_model.get_graph()` "
"you should now write `compressed_model.nncf.get_graph()`.\n"
"The old style will be removed after NNCF v2.5.0"
)
return getattr(self._nncf, key)
raise e

def __setattr__(self, key, value):
# If setting `forward`, set it on the original model.
if key == "forward":
Expand All @@ -1004,16 +984,6 @@ def __setattr__(self, key, value):
)
super().__setattr__(key, value)

def get_nncf_wrapped_model(self) -> "NNCFNetwork":
warning_deprecated(
"Calls to NNCFNetwork.get_nncf_wrapped_model() are deprecated and will be removed "
"in NNCF v2.6.0.\n"
"Starting from NNCF v2.5.0, the compressed model object already inherits the original "
"class of the uncompressed model and the forward signature, so the call to "
".get_nncf_wrapped_model() may be simply omitted."
)
return self


class NNCFSkippingIter:
"""
Expand Down
7 changes: 0 additions & 7 deletions tests/torch/test_nncf_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,13 +584,6 @@ def test_works_when_wrapped_with_dataparallel(simple_net):
dp_model(torch.zeros([10, *simple_net.INPUT_SIZE[1:]], device="cuda"))


def test_warns_on_old_style_calls(simple_net):
with pytest.warns(NNCFDeprecationWarning):
simple_net.get_graph()
with pytest.warns(NNCFDeprecationWarning):
simple_net.get_nncf_wrapped_model()


def test_class_has_same_name_and_module_as_original(simple_net):
assert simple_net.__class__.__name__ == SimplestModel.__name__
assert simple_net.__class__.__module__ == SimplestModel.__module__
Expand Down