Closed xushilin1 closed 1 year ago
Hi @xushilin1 , the calculation of FLOPs does not include the batch size dimension. This is because users might use different batch sizes when calculating, which would make comparisons inaccurate.
Additionally, it is recommended to use the FLOP calculation tool in mmengine. The usage documentation can be accessed by clicking https://mmengine.readthedocs.io/en/latest/common_usage/model_analysis.html
Hi, Thanks for your reply! When I use the FLOP calculation tool in mmengine, I get a different FLOPs result( 3200=32x10x10 compared with 100=10x10 when using mmcv). There may be some wrong in mmcv.
from mmengine.analysis import get_model_complexity_info
model = Net()
analysis_results = get_model_complexity_info(model, (32,10))
analysis_results['flops_str']
The input should not contain the batch size dim. You can see the details at https://github.com/open-mmlab/mmengine/blob/53474ef1ba0b166508c231fa525b55b580adf20f/mmengine/analysis/print_helper.py#L730.
The correct usage is as follows:
model = Net()
analysis_results = get_model_complexity_info(model, (10,))
analysis_results['flops_str'] # '100'
Prerequisite
Environment
MMCV==2.0
Reproduces the problem - code sample
Reproduces the problem - command or script
None
Reproduces the problem - error message
GFLOPs = input_batches $\times$ input_channel $\times$ output_channels = $32\times 10\times 10$. But the result of MMCV given is just $10\times10$
Additional information
No response