ultralytics-thop 2.0.16__py3-none-any.whl → 2.0.17__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- thop/__init__.py +3 -2
- thop/fx_profile.py +9 -8
- thop/profile.py +25 -2
- thop/vision/basic_hooks.py +15 -1
- {ultralytics_thop-2.0.16.dist-info → ultralytics_thop-2.0.17.dist-info}/METADATA +4 -4
- ultralytics_thop-2.0.17.dist-info/RECORD +13 -0
- ultralytics_thop-2.0.16.dist-info/RECORD +0 -13
- {ultralytics_thop-2.0.16.dist-info → ultralytics_thop-2.0.17.dist-info}/WHEEL +0 -0
- {ultralytics_thop-2.0.16.dist-info → ultralytics_thop-2.0.17.dist-info}/licenses/LICENSE +0 -0
- {ultralytics_thop-2.0.16.dist-info → ultralytics_thop-2.0.17.dist-info}/top_level.txt +0 -0
thop/__init__.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
2
2
|
|
3
|
-
__version__ = "2.0.
|
4
|
-
|
3
|
+
__version__ = "2.0.17"
|
5
4
|
|
6
5
|
import torch
|
7
6
|
|
@@ -9,3 +8,5 @@ from .profile import profile, profile_origin
|
|
9
8
|
from .utils import clever_format
|
10
9
|
|
11
10
|
default_dtype = torch.float64
|
11
|
+
|
12
|
+
__all__ = ["profile", "profile_origin", "clever_format", "default_dtype"]
|
thop/fx_profile.py
CHANGED
@@ -6,6 +6,11 @@ from distutils.version import LooseVersion
|
|
6
6
|
import torch
|
7
7
|
import torch as th
|
8
8
|
import torch.nn as nn
|
9
|
+
from torch.fx import symbolic_trace
|
10
|
+
from torch.fx.passes.shape_prop import ShapeProp
|
11
|
+
|
12
|
+
from .utils import prRed, prYellow
|
13
|
+
from .vision.calc_func import calculate_conv
|
9
14
|
|
10
15
|
if LooseVersion(torch.__version__) < LooseVersion("1.8.0"):
|
11
16
|
logging.warning(
|
@@ -40,9 +45,6 @@ def count_fn_linear(input_shapes, output_shapes, *args, **kwargs):
|
|
40
45
|
return flops
|
41
46
|
|
42
47
|
|
43
|
-
from .vision.calc_func import calculate_conv
|
44
|
-
|
45
|
-
|
46
48
|
def count_fn_conv2d(input_shapes, output_shapes, *args, **kwargs):
|
47
49
|
"""Calculates total operations (FLOPs) for a 2D conv layer based on input and output shapes using
|
48
50
|
`calculate_conv`.
|
@@ -118,11 +120,6 @@ for k in zero_ops:
|
|
118
120
|
|
119
121
|
missing_maps = {}
|
120
122
|
|
121
|
-
from torch.fx import symbolic_trace
|
122
|
-
from torch.fx.passes.shape_prop import ShapeProp
|
123
|
-
|
124
|
-
from .utils import prRed, prYellow
|
125
|
-
|
126
123
|
|
127
124
|
def null_print(*args, **kwargs):
|
128
125
|
"""A no-op print function that takes any arguments without performing any actions."""
|
@@ -211,11 +208,15 @@ def fx_profile(mod: nn.Module, input: th.Tensor, verbose=False):
|
|
211
208
|
if __name__ == "__main__":
|
212
209
|
|
213
210
|
class MyOP(nn.Module):
|
211
|
+
"""Custom operator that performs a simple forward pass dividing input by 1."""
|
212
|
+
|
214
213
|
def forward(self, input):
|
215
214
|
"""Performs forward pass on given input data."""
|
216
215
|
return input / 1
|
217
216
|
|
218
217
|
class MyModule(torch.nn.Module):
|
218
|
+
"""Neural network module with two linear layers and a custom MyOP operator."""
|
219
|
+
|
219
220
|
def __init__(self):
|
220
221
|
"""Initializes MyModule with two linear layers and a custom MyOP operator."""
|
221
222
|
super().__init__()
|
thop/profile.py
CHANGED
@@ -1,7 +1,30 @@
|
|
1
1
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
2
2
|
|
3
|
-
from thop.rnn_hooks import
|
4
|
-
|
3
|
+
from thop.rnn_hooks import (
|
4
|
+
count_gru,
|
5
|
+
count_gru_cell,
|
6
|
+
count_lstm,
|
7
|
+
count_lstm_cell,
|
8
|
+
count_rnn,
|
9
|
+
count_rnn_cell,
|
10
|
+
torch,
|
11
|
+
)
|
12
|
+
from thop.vision.basic_hooks import (
|
13
|
+
count_adap_avgpool,
|
14
|
+
count_avgpool,
|
15
|
+
count_convNd,
|
16
|
+
count_convtNd,
|
17
|
+
count_linear,
|
18
|
+
count_normalization,
|
19
|
+
count_parameters,
|
20
|
+
count_prelu,
|
21
|
+
count_relu,
|
22
|
+
count_softmax,
|
23
|
+
count_upsample,
|
24
|
+
logging,
|
25
|
+
nn,
|
26
|
+
zero_ops,
|
27
|
+
)
|
5
28
|
|
6
29
|
from .utils import prRed
|
7
30
|
|
thop/vision/basic_hooks.py
CHANGED
@@ -2,10 +2,24 @@
|
|
2
2
|
|
3
3
|
import logging
|
4
4
|
|
5
|
+
import torch
|
5
6
|
import torch.nn as nn
|
6
7
|
from torch.nn.modules.conv import _ConvNd
|
7
8
|
|
8
|
-
from .calc_func import
|
9
|
+
from thop.vision.calc_func import (
|
10
|
+
calculate_adaptive_avg,
|
11
|
+
calculate_avgpool,
|
12
|
+
calculate_conv,
|
13
|
+
calculate_conv2d_flops,
|
14
|
+
calculate_linear,
|
15
|
+
calculate_norm,
|
16
|
+
calculate_parameters,
|
17
|
+
calculate_relu,
|
18
|
+
calculate_relu_flops,
|
19
|
+
calculate_softmax,
|
20
|
+
calculate_upsample,
|
21
|
+
calculate_zero_ops,
|
22
|
+
)
|
9
23
|
|
10
24
|
multiply_adds = 1
|
11
25
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ultralytics-thop
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.17
|
4
4
|
Summary: Ultralytics THOP package for fast computation of PyTorch model FLOPs and parameters.
|
5
5
|
Author-email: Ligeng Zhu <ligeng.zhu+github@gmail.com>
|
6
6
|
Maintainer-email: Ultralytics <hello@ultralytics.com>
|
@@ -56,7 +56,7 @@ THOP offers an intuitive API designed to profile PyTorch models by calculating t
|
|
56
56
|
|
57
57
|
Get started with THOP quickly by installing it via pip:
|
58
58
|
|
59
|
-
[](https://pypi.org/project/ultralytics-thop/) [](https://
|
59
|
+
[](https://pypi.org/project/ultralytics-thop/) [](https://clickpy.clickhouse.com/dashboard/ultralytics-thop) [](https://pypi.org/project/ultralytics-thop/)
|
60
60
|
|
61
61
|
```bash
|
62
62
|
pip install ultralytics-thop
|
@@ -74,7 +74,7 @@ This ensures you have the most recent version, incorporating the latest improvem
|
|
74
74
|
|
75
75
|
### Basic Usage
|
76
76
|
|
77
|
-
Profiling a standard PyTorch model like [ResNet50](https://pytorch.org/vision/main/models/generated/torchvision.models.resnet50.html) is straightforward. Import the necessary libraries, load your model and a sample input tensor, then use the `profile` function:
|
77
|
+
Profiling a standard PyTorch model like [ResNet50](https://docs.pytorch.org/vision/main/models/generated/torchvision.models.resnet50.html) is straightforward. Import the necessary libraries, load your model and a sample input tensor, then use the `profile` function:
|
78
78
|
|
79
79
|
```python
|
80
80
|
import torch
|
@@ -230,7 +230,7 @@ The table below showcases the parameters and MACs for several popular [computer
|
|
230
230
|
|
231
231
|
## 🙌 Contribute
|
232
232
|
|
233
|
-
We actively welcome and encourage community contributions to make THOP even better! Whether it's adding support for new [PyTorch layers](https://pytorch.org/docs/stable/nn.html), improving existing calculations, enhancing documentation, or fixing bugs, your input is valuable. Please see our [Contributing Guide](https://docs.ultralytics.com/help/contributing/) for detailed instructions on how to participate. Together, we can ensure THOP remains a state-of-the-art tool for the [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) community. Don't hesitate to share your feedback and suggestions!
|
233
|
+
We actively welcome and encourage community contributions to make THOP even better! Whether it's adding support for new [PyTorch layers](https://docs.pytorch.org/docs/stable/nn.html), improving existing calculations, enhancing documentation, or fixing bugs, your input is valuable. Please see our [Contributing Guide](https://docs.ultralytics.com/help/contributing/) for detailed instructions on how to participate. Together, we can ensure THOP remains a state-of-the-art tool for the [machine learning](https://www.ultralytics.com/glossary/machine-learning-ml) community. Don't hesitate to share your feedback and suggestions!
|
234
234
|
|
235
235
|
## 📜 License
|
236
236
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
thop/__init__.py,sha256=jUflh8SMGvE0AqZliYPEX-DJ0ynmVJVMIHKB9IU6BlQ,293
|
2
|
+
thop/fx_profile.py,sha256=mdomj44BIc85XyDabnYRjlJI_p3BxAMls0P8GVS2WYU,8404
|
3
|
+
thop/profile.py,sha256=c5aH5zfL5e68OJtNL3OO45nkH51PygrE325wMQ4H2pE,8357
|
4
|
+
thop/rnn_hooks.py,sha256=JKZ2eSCvIKvhvCDqM4oWPZjmBkdyJ4R2Q7XSn63lsX0,6503
|
5
|
+
thop/utils.py,sha256=IwFJQ1v-SLyhm-313Li535R6fhtomkm8Fem1Kfe6G_U,1484
|
6
|
+
thop/vision/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
|
7
|
+
thop/vision/basic_hooks.py,sha256=tvr8P4tRJpP9Qyk-tnuXnBPGaMGBj6qlDpGI-uJh5mE,5466
|
8
|
+
thop/vision/calc_func.py,sha256=2-LcoFg8ODy8EMb-xEsgLVPigLTki3dXnAg58dxVq80,4530
|
9
|
+
ultralytics_thop-2.0.17.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
10
|
+
ultralytics_thop-2.0.17.dist-info/METADATA,sha256=vHUOSsXrncSfOCM2J7dQLcayh-fHVDwZZVV40meK7yE,14942
|
11
|
+
ultralytics_thop-2.0.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
12
|
+
ultralytics_thop-2.0.17.dist-info/top_level.txt,sha256=HQ7D0gSvDJ31CNR-f0EuXNVve05RYBmwyIkHQKiEhU8,5
|
13
|
+
ultralytics_thop-2.0.17.dist-info/RECORD,,
|
@@ -1,13 +0,0 @@
|
|
1
|
-
thop/__init__.py,sha256=uIP-Z82T22WjV4ZABASgzJpdE7KrxsGHmoAMbe9Dv1Y,219
|
2
|
-
thop/fx_profile.py,sha256=ACI2RLyDYBLB7Cru9y2IAx_YCFX_uhYEArDR0np_tFc,8231
|
3
|
-
thop/profile.py,sha256=CsS9mFIW3VWUA15pHQbGDZX-N624u10LZs5FtJOW_Fg,7983
|
4
|
-
thop/rnn_hooks.py,sha256=JKZ2eSCvIKvhvCDqM4oWPZjmBkdyJ4R2Q7XSn63lsX0,6503
|
5
|
-
thop/utils.py,sha256=IwFJQ1v-SLyhm-313Li535R6fhtomkm8Fem1Kfe6G_U,1484
|
6
|
-
thop/vision/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
|
7
|
-
thop/vision/basic_hooks.py,sha256=jrq6HQtyMjO0PouGxiUZEehMVTozlUvslqMyOdoBcnQ,5156
|
8
|
-
thop/vision/calc_func.py,sha256=2-LcoFg8ODy8EMb-xEsgLVPigLTki3dXnAg58dxVq80,4530
|
9
|
-
ultralytics_thop-2.0.16.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
10
|
-
ultralytics_thop-2.0.16.dist-info/METADATA,sha256=EWJhKFCiDgN0tuXepxy0mF9Z_bxbzOYGYzddFWxqK_k,14922
|
11
|
-
ultralytics_thop-2.0.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
12
|
-
ultralytics_thop-2.0.16.dist-info/top_level.txt,sha256=HQ7D0gSvDJ31CNR-f0EuXNVve05RYBmwyIkHQKiEhU8,5
|
13
|
-
ultralytics_thop-2.0.16.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|