Skip to content

Commit

Permalink
Nano : add length check in trace (#4972)
Browse files Browse the repository at this point in the history
* add length check

* fix style

* fix

* modify as reviews

* fix style
  • Loading branch information
rnwang04 authored Jul 1, 2022
1 parent 3cdce80 commit 94329df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def forward_step(self, *inputs):
'''
This function run through the onnxruntime forwarding step
'''
invalidInputError(len(self._forward_args) >= len(inputs), "The length of inputs is "
"inconsistent with the length of ONNX Runtime session's inputs, "
"there may be some redundant inputs.")
inputs = dict(zip(self._forward_args, inputs))
ort_outs = self.ortsess.run(None, inputs)
return ort_outs
Expand Down
2 changes: 1 addition & 1 deletion python/nano/src/bigdl/nano/pytorch/trainer/Trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def quantize(model, # remove the type requirement for type checking
elif accelerator == 'openvino':
model_type = type(model).__name__
if not model_type == 'PytorchOpenVINOModel':
if not input_sample:
if input_sample is None:
# input_sample can be a dataloader
input_sample = calib_dataloader
model = Trainer.trace(model,
Expand Down

0 comments on commit 94329df

Please sign in to comment.