Skip to content

Commit

Permalink
Fixed trace issue when input is dictionary (#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
maktukmak authored Jun 14, 2023
1 parent 74a859c commit 6a3c643
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions neural_compressor/adaptor/torch_utils/smooth_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,9 @@ def __init__(self):
def trace(self, model, dummy_input):
traced_model = None
optimize_numerics = False
if isinstance(dummy_input, dict):
if isinstance(dummy_input, dict) or isinstance(dummy_input, UserDict):
try:
traced_model = torch.jit.trace(model, dummy_input["input_ids"], strict=False)
traced_model = torch.jit.trace(model, example_kwarg_inputs=dict(dummy_input), strict=False)
traced_model = torch.jit.freeze(traced_model.eval(), optimize_numerics=optimize_numerics)
except:
pass
Expand Down

0 comments on commit 6a3c643

Please sign in to comment.