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] Make the parameters of get_model_complexity_info() friendly #1056

Merged
merged 2 commits into from
Apr 10, 2023

Conversation

sjiang95
Copy link
Contributor

@sjiang95 sjiang95 commented Apr 8, 2023

Motivation

Optimize the flexibility of function get_model_complexity_info(). #1055

Modification

  1. Set default value of input_shape to None.
  2. assert does not allow both input_shape and inputs are None.
  3. If both input_shape and inputs are provided, print a warning.

BC-breaking (Optional)

It the downstream repo calls the function get_model_complexity_info() like this line (It seems that the downstream repos have to call this function like the linked line.), not change has to be performed on the existing repos to fit this modification.

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.

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

CLAassistant commented Apr 8, 2023

CLA assistant check
All committers have signed the CLA.

@sjiang95 sjiang95 changed the title print_helper: optimize inputs of get_model_complexity_info() [Enhance] print_helper: optimize inputs of get_model_complexity_info() Apr 8, 2023
Comment on lines 700 to 706
assert (input_shape is not None) or (
inputs
is not None), '"input_shape" and "inputs" cannot both be "None".'
if (input_shape is not None) and (inputs is not None):
warnings.warn('Both "input_shape" and "inputs" are provided.\
"inputs" will be used.')

Copy link
Member

Choose a reason for hiding this comment

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

Directly throwing errors are OK when they are both set.

When "input_shape" and "inputs" are both `None` or both set,
throw ValueError.

Signed-off-by: Shengjiang QUAN <qsj287068067@126.com>
@sjiang95 sjiang95 requested a review from zhouzaida April 10, 2023 09:27
@zhouzaida zhouzaida changed the title [Enhance] print_helper: optimize inputs of get_model_complexity_info() [Enhance] Make the parameters of get_model_complexity_info() friendly Apr 10, 2023
@zhouzaida zhouzaida merged commit f76218a into open-mmlab:main Apr 10, 2023
@sjiang95 sjiang95 deleted the flops branch April 10, 2023 13:33
xiexinch added a commit to open-mmlab/mmsegmentation that referenced this pull request Jan 31, 2024
## Motivation

`inputs` and `input_shape` can't be both set to mmengine api
`get_model_complexity_info`

open-mmlab/mmengine#1056


## Modification

Set `input_shape` to None.
Chrps pushed a commit to Chrps/mmsegmentation that referenced this pull request Apr 8, 2024
## Motivation

`inputs` and `input_shape` can't be both set to mmengine api
`get_model_complexity_info`

open-mmlab/mmengine#1056


## Modification

Set `input_shape` to None.
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.

None yet

3 participants