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

Add cleanup_torchscript_cache to test_quantize_conformance.py #2171

Merged
Merged
Changes from all 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
13 changes: 13 additions & 0 deletions tests/post_training/pipelines/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,19 @@ def run(self) -> None:
self.save_quantized_model()
self.get_num_fq()
self.validate()
self.cleanup_torchscript_cache()

@staticmethod
def cleanup_torchscript_cache():
"""
Helper for removing cached model representation.

After run torch.jit.trace in convert_model, PyTorch does not clear the trace cache automatically.
"""
# pylint: disable=protected-access
torch._C._jit_clear_class_registry()
torch.jit._recursive.concrete_type_store = torch.jit._recursive.ConcreteTypeStore()
torch.jit._state._clear_class_state()

def get_run_info(self) -> RunInfo:
return self.run_info