Comments (6)
Resnet flops calculated by the OpCOunter is smaller than the value in paper.
from pytorch-opcounter.
Yes, as pytorch is a dynamic graph library, it is impossible to determine skip-connection structure at nn.Module level.
One quick fix is to write a special judge for inverted residual block. I'll try to provide a more precise one via tracing computational graph.
from pytorch-opcounter.
@Lyken17 In torch1.1, a new placeholder module is provided for this kind of awkward situation.
As I can see, you should add this Module into count_hooks.py
and profile.py
, counting the extra ops for skip connection.
And update your readme for special notice is important as well that one must use the standard module provided by PyTorch for skip connection to get an accurate FLOPs.
from pytorch-opcounter.
not really. Most existing codebase still defines the identity connection in forward
. The real problem, as I mentioned before, is pytorch's define-by-run
philosophy. The only way to record all operations is to trace the DAG.
In this case, please have a look at my labmate's project zhijian-liu/onnx-profiler
from pytorch-opcounter.
What you mentioned is quite right. I didn't say it would fix this problem without changing the codes. If someone would like to call your hook based op-counter while considering skip connection, he can represent skip connection with nn.Identity
. And by adding this module to your profile
we can fix the problem.
It is kind of a patch, not a global solution.
By unify the model to onnx mode is a very interesting idea, I may look deeper into it some time.
from pytorch-opcounter.
It is kind of like a user-defined patch, so I don't think you should update your project.
from pytorch-opcounter.
Related Issues (20)
- question about the MACs of nn.BatchNorm2d
- got 0 ops for nn.MultiheadAttention HOT 7
- Count flops by a range
- thop/profile.py:12: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. `if LooseVersion(torch.__version__) < LooseVersion("1.0.0"):` HOT 2
- Does MACs and FLOPs count correctly for and INT8 quantized model? HOT 1
- Upload sdist to PyPI HOT 1
- Problem in bert HOT 1
- multiple inputs HOT 1
- Is the latest version calculate MACs or FLOPs HOT 2
- RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
- How to calculate the FLOPs of each type of layers?
- How to exclude flops of 1st input? HOT 1
- Incorrect macs without specifying batch size for conv layers
- will torch.matmul regards as zero_ops ?
- Is thop also effective for calculating Flops for spiking neural networks?
- rename calculate_conv2d_flops HOT 1
- thop calculates torch.nn module params incorrectly HOT 1
- RuntimeError: Can't add a new parameter
- count_normalization is only correct for batch_norm. wrong flops count for layernorm HOT 1
- Res add will be included when evaluate Resnet's OPs ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch-opcounter.