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

Improve ONNX tracing support for Faster-RCNN #2060

Closed
wants to merge 20 commits into from
Closed

Improve ONNX tracing support for Faster-RCNN #2060

wants to merge 20 commits into from

Conversation

crisp-snakey
Copy link
Contributor

Small fixes to better preserve the origin of shape information during ONNX export. This resolves an issue where an ONNX export would generate fixed sized tensors for tensors that are actually of a dynamic shape.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 22, 2020
@ppwwyyxx
Copy link
Contributor

ppwwyyxx commented Oct 1, 2020

Could you add a unittest that would have failed before? Otherwise it's not clear to me what this PR is trying to fix.

@crisp-snakey
Copy link
Contributor Author

So, I've been trying to add a unittest that shows the problem (at least for the ROIPooler). It requires an extra dependency (onnxruntime) which seems to be broken on MacOS. The pipeline fails during an import inside of onnxruntime (it for some reason can't import a function to retrieve the available backends).

.github/workflows/workflow.yml Outdated Show resolved Hide resolved
detectron2/modeling/poolers.py Outdated Show resolved Hide resolved
.github/workflows/workflow.yml Outdated Show resolved Hide resolved
detectron2/modeling/poolers.py Outdated Show resolved Hide resolved
detectron2/modeling/roi_heads/fast_rcnn.py Show resolved Hide resolved
tests/modeling/test_roi_pooler.py Outdated Show resolved Hide resolved
(pred_ctr_y + 0.5 * pred_h).unsqueeze(dim=-1), # y2
],
dim=-1,
).flatten(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

fyi, I'm only waiting to first get the fix pytorch/pytorch#45828 into pytorch so we don't have to do this hack

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ppwwyyxx has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

facebook-github-bot pushed a commit that referenced this pull request Oct 23, 2020
Summary:
Small fixes to better preserve the origin of shape information during ONNX export. This resolves an issue where an ONNX export would generate fixed sized tensors for tensors that are actually of a dynamic shape.

Pull Request resolved: #2060

Reviewed By: theschnitz

Differential Revision: D24156111

Pulled By: ppwwyyxx

fbshipit-source-id: 34776d4b18be6915b9deea6bd2cbb7680ffc6488
@ppwwyyxx
Copy link
Contributor

FYI we also hide the changes to len() under a patch function. In general we avoid hacks on modeling code if the same effect can be achieved by more hacks outside the modeling code.

@crisp-snakey crisp-snakey deleted the improve-onnx-tracing branch December 30, 2020 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants