calculate-flops.pytorch
The calflops is designed to calculate FLOPs、MACs and Parameters in all various neural networks, such as Linear、 CNN、 RNN、 GCN、Transformer(Bert、LlaMA etc Large Language Model).
MrYxJ/calculate-flops.pytorch is ranked 12,449 with 948 stars.
MrYxJ/calculate-flops.pytorch is ranked 12,449 among these 8 peers; StanfordVL/GibsonEnv is ranked 12,450.
| Name | Rank | Metrics |
|---|---|---|
| fungtion/DANN | 12,439 |
|
| CalciferZh/SMPL | 12,445 |
|
| OpenQuadruped/spot_mini_mini | 12,446 |
|
| facebookresearch/StyleNeRF | 12,447 |
|
| StanfordVL/GibsonEnv | 12,450 |
|
| stanfordnmbl/osim-rl | 12,454 |
|
| ZhendongWang6/Uformer | 12,456 |
|
| f90/Wave-U-Net | 12,457 |
|
| Parameter | Value |
|---|---|
| Language | Python |
| Category | Model Development |
| Subcategory | Interpretability |
| Stars | 948 |
| Forks | 44 |
| Contributors | 3 |
| Created date | 2023-08-20 |
| Updated date | 2026-09-22 |
| Stars in 1 day | 0 |
| Stars in 7 days | 0 |
| Rank | 12,449 |
| Previous rank | 12,374 |
| Rank change | -75 |
| 7-day stars rank | 13,428 |
| Previous 7-day stars rank | 13,439 |
| 7-day stars rank change | 11 |
| Total stars rank | 11,618 |
| Previous total stars rank | 11,598 |
| Total stars rank change | -20 |
| Country | China |
calflops: a FLOPs and Params calculate tool for neural networks Introduction This tool(calflops) is designed to compute the theoretical amount of FLOPs(floating-point operations)、MACs(multiply-add operations) and Parameters in all various neural networks, such as Linear、 CNN、 RNN、 GCN、**Transformer(Bert、LlaMA etc Large Language Model)**,even including **any custom models** via as long as based on the Pytorch implementation. Meanwhile this tool supports the printing of FLOPS, Parameter calculation value and proportion of each submodule
of the model, it is convient for users to understand the performance consumption of each part of the model. Latest news, calflops has launched a tool on Huggingface Space, which is more convenient for computing FLOPS in the model of 🤗Huggingface Platform. Welcome to use it: For LLM, this is probably the easiest tool to calculate FLOPs and it is very convenient for **huggingface** platform models. You can use by which in huggingface models to calculate model FLOPs without downloading
entire model weights locally. Notice this method requires the model to support the empty model being created for model inference in meta device. If model can't inference in meta device, you just need assign llm corresponding tokenizer to the parameter: to pass in funcional of , and it will automatically help you build the model input data whose size is input_shape. Alternatively, you also can pass in the input data of models which need multi data as input that you
have constructed. In addition, the implementation process of this package inspired by ptflops、deepspeed、hf accelerate libraries, Thanks for their great efforts, they are both very good work. Meanwhile this package also improves some aspects to calculate FLOPs based on them. How to install Install the latest version From PyPI: And you also can download latest files from How to use calflops Example CNN Model If model has only one input, you just need set the model input size by
parameter , it can automatically generate random model input to complete the calculation: If the model has multiple inputs, use the parameters or , as shown in the Transfomer Model below. Calculate Huggingface Model By Model Name(Online) No need to download the entire parameter weight of the model to the local, just by the model name can test any open source large model on the huggingface platform. You can also use this model urls of huggingface platform to calculate it FLOPs
. There are some model uses that require an application first, and you only need to pass the application in through the to calculate its FLOPs. Transformer Model (Local) Compared to the CNN Model, Transformer Model if you want to use the parameter to make calflops automatically generating the input data, you should pass its corresponding tokenizer through the parameter . If you want to use your own generated specific data to calculate FLOPs, you can use parameter or ,and parameter can
no longer be assigned to pass in this case. Here is an example that can be seen is inconvenient comparedt
How many stars and forks are recorded?
MrYxJ/calculate-flops.pytorch has 948 stars and 44 forks.
What is the repository rank?
MrYxJ/calculate-flops.pytorch is ranked 12,449.
What language and category are recorded?
MrYxJ/calculate-flops.pytorch has 948 stars, uses Python and belongs to Model Development.
Which repository is closest in rank?
MrYxJ/calculate-flops.pytorch is compared with StanfordVL/GibsonEnv, ranked 12,450 with 948 stars.