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

[Enhance] Complement type hint of get_model_complexity_info() #1064

Merged
merged 2 commits into from
Apr 10, 2023

Conversation

sjiang95
Copy link
Contributor

@sjiang95 sjiang95 commented Apr 10, 2023

The type of inputs should be one of torch.Tensor, tuple[torch.Tensor, ...] and None.

Motivation

The type hint of arg inputs in get_model_complexity_info() should match class FlopAnalyzer

inputs: Union[Tensor, Tuple[Tensor, ...]],

and class ActivationAnalyzer,
inputs: Union[Tensor, Tuple[Tensor, ...]],

since the argument inputs is finally fed into these two classes.

Otherwise, a user may be confused about what if a custom model requires more than one tensors as inputs.

Modification

Change current type hint of inputs in get_model_complexity_info() from

Optional[torch.Tensor]

to

Union[torch.Tensor, Tuple[torch.Tensor, ...], None]

BC-breaking (Optional)

Not applicable.

Use cases (Optional)

Not applicable.

Checklist

  • Pre-commit or other linting tools are used to fix the potential lint issues.
  • The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
  • The documentation has been modified accordingly, like docstring or example tutorials.

@zhouzaida
Copy link
Collaborator

Hi @sjiang95 , thanks for your contribution. Please resolve the conflicting files and fix the lint.

@sjiang95 sjiang95 force-pushed the inputstypehint branch 2 times, most recently from 0814d18 to bc8e5ba Compare April 10, 2023 11:14
The type of `inputs` should be one of `torch.Tensor`,
`tuple[torch.Tensor, ...]` and `None`.

Signed-off-by: Shengjiang QUAN <qsj287068067@126.com>
@sjiang95
Copy link
Contributor Author

Hi @zhouzaida, thanks for your quick response.
It is ready to be reviewed now.

@zhouzaida
Copy link
Collaborator

Hi @zhouzaida, thanks for your quick response. It is ready to be reviewed now.

Hi @sjiang95, hanks for your contribution. I have approved and it can be merged after passing the CI.

@zhouzaida zhouzaida merged commit 5da24ed into open-mmlab:main Apr 10, 2023
@sjiang95 sjiang95 deleted the inputstypehint branch April 10, 2023 13:35
Copy link

codecov bot commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@f76218a). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1064   +/-   ##
=======================================
  Coverage        ?   76.41%           
=======================================
  Files           ?      139           
  Lines           ?    11203           
  Branches        ?     2253           
=======================================
  Hits            ?     8561           
  Misses          ?     2280           
  Partials        ?      362           
Flag Coverage Δ
unittests 76.41% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants