Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lartpang/methodscmp
MethodsCmp: A Simple Toolkit for Counting the FLOPs/MACs, Parameters and FPS of Pytorch-based Methods
https://github.com/lartpang/methodscmp
flops flops-counter fps fps-counter macs macs-counter memory memory-counter parameter-counter parameters python pytorch
Last synced: 26 days ago
JSON representation
MethodsCmp: A Simple Toolkit for Counting the FLOPs/MACs, Parameters and FPS of Pytorch-based Methods
- Host: GitHub
- URL: https://github.com/lartpang/methodscmp
- Owner: lartpang
- Created: 2021-08-29T04:56:20.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-13T09:06:43.000Z (8 months ago)
- Last Synced: 2024-12-01T19:51:36.389Z (about 1 month ago)
- Topics: flops, flops-counter, fps, fps-counter, macs, macs-counter, memory, memory-counter, parameter-counter, parameters, python, pytorch
- Language: Python
- Homepage:
- Size: 106 KB
- Stars: 18
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# A simple toolkit for counting the FLOPs/MACs, Parameters and FPS of the model.
```shell
$ python main.py --help
usage: main.py [-h] [--method-names METHOD_NAMES [METHOD_NAMES ...]]
[--mode {ops_params,fps,gpu_mem} [{ops_params,fps,gpu_mem} ...]]A simple toolkit for counting the FLOPs/MACs, Parameters, FPS and GPU Memory of the model.
optional arguments:
-h, --help show this help message and exit
--method-names METHOD_NAMES [METHOD_NAMES ...]
The names of the methods you want to evaluate.
--mode {ops_params,fps,gpu_mem} [{ops_params,fps,gpu_mem} ...]
```**NOTE**:
* [`fvcore` cannot count the FLOPs of the built-in module nn.MultiHeadAttention of PyTorch](https://github.com/lartpang/MethodsCmp/issues/1)## Usage
```bash
pip install fvcore
```In `methods` folder, I have provided some recent methods, i.e. CoNet, DANet, HDFNet, JL-DCF, and UC-Net, as the examples.
More functional improvements and suggestions are welcome.
An example:
```shell
python main.py --method-names zoomnet ugtr c2fnet ujsc pfnet mgl_r slsr sinet
```## Change Log
* 2023-07-28:
* [New & Important] Update the library for count FLOPs/MACS from `pytorch-OpCounter` to `fvcore` which can count FLOPs/MACs of the complex module, like Transformer.
* Remove the useless `test` folder.
* [Experimental Feature] Add the new feature for counting the peak inference GPU memory of the model.
* 2022-03-03: Add more methods, add the gpu warmup process in counting FPS and update the readme.
* 2021-09-29: Refactor again.
* 2021-08-31: Refactor.
* 2021-08-29: Create a new repository and upload the code.```latex
@misc{MethodsCmp,
author = {Youwei Pang},
title = {MethodsCmp: A Simple Toolkit for Counting the FLOPs/MACs, Parameters and FPS of Pytorch-based Methods},
howpublished = {\url{https://github.com/lartpang/MethodsCmp}},
year = {2021}
}
```