-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Convert classes used for Detection to nn.Modules #4389
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
Conversation
e424fd7 to
beab59f
Compare
beab59f to
91284af
Compare
|
|
||
|
|
||
| class BoxCoder(object): | ||
| class BoxCoder(nn.Module): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class with its encode/decode methods does not play nice with the nn.Module's forward() approach. Not sure if we should convert it but it will allow us to drop its declarations to __annotations__
| def forward(self, match_quality_matrix): | ||
| return self._forward_impl(match_quality_matrix) | ||
|
|
||
| def _forward_impl(self, match_quality_matrix): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workaround for overwriting the forward on inheriting classes. We do the same on quantization.
|
I'm going to close this PR until it's clearer to us whether we should convert Classes to Modules OR if there will be native support of Objects in JIT. |
|
I had a chat with Vasilis about this, and indeed the first thing to evaluate is if custom classes will be supported in the lite interpreter or not. One of the reasons for that is that converting all custom classes to |
I'm converting some of the existing classes used to do computations for Detection models to nn.Modules. It's unclear why they were structured like this, could be because they were ported from DETR in the past (perhaps @fmassa can provide more info).
This PR was originally done to investigate #4386 (comment). Though it does not resolves it (might be partial solution), this conversion enables us to drop the
__annotation__declarations.I also tried to convert the
LevelMapperbut it's modification is not straightforward as it modifies arguments post compilation and creates JIT issues. Worth checking this on a separate PR.