Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Set the strict to false in mask conflict utils. #4078

Merged
merged 1 commit into from
Aug 18, 2021
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
8 changes: 6 additions & 2 deletions nni/compression/pytorch/utils/mask_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ def fix_mask_conflict(masks, model=None, dummy_input=None, traced=None):
if traced is None:
assert model is not None and dummy_input is not None
training = model.training
model.eval()
# We need to trace the model in eval mode
traced = torch.jit.trace(model, dummy_input)
model.eval()
kw_args = {}
if torch.__version__ >= '1.6.0':
# only pytorch with version greater than 1.6.0 has the strict option
kw_args['strict'] = False
traced = torch.jit.trace(model, dummy_input, **kw_args)
model.train(training)

fix_group_mask = GroupMaskConflict(masks, model, dummy_input, traced)
Expand Down