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

fix verify bugs #547

Merged
merged 2 commits into from
May 13, 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
15 changes: 9 additions & 6 deletions tools/pytorch2onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@ def _prepare_input_img(img_path,
return mm_inputs


def _update_input_img(img_list, img_meta_list):
def _update_input_img(img_list, img_meta_list, update_ori_shape=False):
# update img and its meta list
N = img_list[0].size(0)
N, C, H, W = img_list[0].shape
img_meta = img_meta_list[0][0]
img_shape = img_meta['img_shape']
ori_shape = img_meta['ori_shape']
pad_shape = img_meta['pad_shape']
img_shape = (H, W, C)
if update_ori_shape:
ori_shape = img_shape
else:
ori_shape = img_meta['ori_shape']
pad_shape = img_shape
new_img_meta_list = [[{
'img_shape':
img_shape,
Expand Down Expand Up @@ -220,7 +223,7 @@ def pytorch2onnx(model,

# update img_meta
img_list, img_meta_list = _update_input_img(
img_list, img_meta_list)
img_list, img_meta_list, test_mode == 'whole')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why arg is test_mode == 'whole'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input tensor has been interpolated with scale_factor=1.5 to test dynamic shape support.
We only support dynamic shape on these whole mode models.


# check the numerical value
# get pytorch output
Expand Down