ultralytics-thop 0.2.7__tar.gz → 0.2.8__tar.gz
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.
- {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/PKG-INFO +7 -3
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/README.md +6 -2
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/tests/test_matmul.py +1 -1
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/thop/__init__.py +1 -1
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/thop/fx_profile.py +2 -4
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/thop/vision/basic_hooks.py +1 -3
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/ultralytics_thop.egg-info/PKG-INFO +7 -3
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/LICENSE +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/pyproject.toml +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/setup.cfg +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/tests/test_conv2d.py +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/tests/test_relu.py +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/tests/test_utils.py +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/thop/profile.py +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/thop/rnn_hooks.py +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/thop/utils.py +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/thop/vision/__init__.py +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/thop/vision/calc_func.py +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/ultralytics_thop.egg-info/SOURCES.txt +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/ultralytics_thop.egg-info/dependency_links.txt +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/ultralytics_thop.egg-info/requires.txt +0 -0
 - {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/ultralytics_thop.egg-info/top_level.txt +0 -0
 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Metadata-Version: 2.1
         
     | 
| 
       2 
2 
     | 
    
         
             
            Name: ultralytics-thop
         
     | 
| 
       3 
     | 
    
         
            -
            Version: 0.2. 
     | 
| 
      
 3 
     | 
    
         
            +
            Version: 0.2.8
         
     | 
| 
       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: Glenn Jocher
         
     | 
| 
         @@ -74,7 +74,7 @@ import torch 
     | 
|
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
            model = resnet50()
         
     | 
| 
       76 
76 
     | 
    
         
             
            input = torch.randn(1, 3, 224, 224)
         
     | 
| 
       77 
     | 
    
         
            -
            macs, params = profile(model, inputs=(input, 
     | 
| 
      
 77 
     | 
    
         
            +
            macs, params = profile(model, inputs=(input,))
         
     | 
| 
       78 
78 
     | 
    
         
             
            ```
         
     | 
| 
       79 
79 
     | 
    
         | 
| 
       80 
80 
     | 
    
         
             
            ### Define Custom Rules for Third-Party Modules
         
     | 
| 
         @@ -84,16 +84,19 @@ You can define custom rules for unsupported modules: 
     | 
|
| 
       84 
84 
     | 
    
         
             
            ```python
         
     | 
| 
       85 
85 
     | 
    
         
             
            import torch.nn as nn
         
     | 
| 
       86 
86 
     | 
    
         | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
       87 
88 
     | 
    
         
             
            class YourModule(nn.Module):
         
     | 
| 
       88 
89 
     | 
    
         
             
                # your definition
         
     | 
| 
       89 
90 
     | 
    
         
             
                pass
         
     | 
| 
       90 
91 
     | 
    
         | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
       91 
93 
     | 
    
         
             
            def count_your_model(model, x, y):
         
     | 
| 
       92 
94 
     | 
    
         
             
                # your rule here
         
     | 
| 
       93 
95 
     | 
    
         
             
                pass
         
     | 
| 
       94 
96 
     | 
    
         | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
       95 
98 
     | 
    
         
             
            input = torch.randn(1, 3, 224, 224)
         
     | 
| 
       96 
     | 
    
         
            -
            macs, params = profile(model, inputs=(input, 
     | 
| 
      
 99 
     | 
    
         
            +
            macs, params = profile(model, inputs=(input,), custom_ops={YourModule: count_your_model})
         
     | 
| 
       97 
100 
     | 
    
         
             
            ```
         
     | 
| 
       98 
101 
     | 
    
         | 
| 
       99 
102 
     | 
    
         
             
            ### Improve Output Readability
         
     | 
| 
         @@ -102,6 +105,7 @@ Use `thop.clever_format` for a more readable output: 
     | 
|
| 
       102 
105 
     | 
    
         | 
| 
       103 
106 
     | 
    
         
             
            ```python
         
     | 
| 
       104 
107 
     | 
    
         
             
            from thop import clever_format
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
       105 
109 
     | 
    
         
             
            macs, params = clever_format([macs, params], "%.3f")
         
     | 
| 
       106 
110 
     | 
    
         
             
            ```
         
     | 
| 
       107 
111 
     | 
    
         | 
| 
         @@ -40,7 +40,7 @@ import torch 
     | 
|
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
            model = resnet50()
         
     | 
| 
       42 
42 
     | 
    
         
             
            input = torch.randn(1, 3, 224, 224)
         
     | 
| 
       43 
     | 
    
         
            -
            macs, params = profile(model, inputs=(input, 
     | 
| 
      
 43 
     | 
    
         
            +
            macs, params = profile(model, inputs=(input,))
         
     | 
| 
       44 
44 
     | 
    
         
             
            ```
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
            ### Define Custom Rules for Third-Party Modules
         
     | 
| 
         @@ -50,16 +50,19 @@ You can define custom rules for unsupported modules: 
     | 
|
| 
       50 
50 
     | 
    
         
             
            ```python
         
     | 
| 
       51 
51 
     | 
    
         
             
            import torch.nn as nn
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
       53 
54 
     | 
    
         
             
            class YourModule(nn.Module):
         
     | 
| 
       54 
55 
     | 
    
         
             
                # your definition
         
     | 
| 
       55 
56 
     | 
    
         
             
                pass
         
     | 
| 
       56 
57 
     | 
    
         | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
       57 
59 
     | 
    
         
             
            def count_your_model(model, x, y):
         
     | 
| 
       58 
60 
     | 
    
         
             
                # your rule here
         
     | 
| 
       59 
61 
     | 
    
         
             
                pass
         
     | 
| 
       60 
62 
     | 
    
         | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
       61 
64 
     | 
    
         
             
            input = torch.randn(1, 3, 224, 224)
         
     | 
| 
       62 
     | 
    
         
            -
            macs, params = profile(model, inputs=(input, 
     | 
| 
      
 65 
     | 
    
         
            +
            macs, params = profile(model, inputs=(input,), custom_ops={YourModule: count_your_model})
         
     | 
| 
       63 
66 
     | 
    
         
             
            ```
         
     | 
| 
       64 
67 
     | 
    
         | 
| 
       65 
68 
     | 
    
         
             
            ### Improve Output Readability
         
     | 
| 
         @@ -68,6 +71,7 @@ Use `thop.clever_format` for a more readable output: 
     | 
|
| 
       68 
71 
     | 
    
         | 
| 
       69 
72 
     | 
    
         
             
            ```python
         
     | 
| 
       70 
73 
     | 
    
         
             
            from thop import clever_format
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
       71 
75 
     | 
    
         
             
            macs, params = clever_format([macs, params], "%.3f")
         
     | 
| 
       72 
76 
     | 
    
         
             
            ```
         
     | 
| 
       73 
77 
     | 
    
         | 
| 
         @@ -15,7 +15,7 @@ class TestUtils: 
     | 
|
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
                def test_matmul_case2(self):
         
     | 
| 
       17 
17 
     | 
    
         
             
                    """Tests matrix multiplication to assert FLOPs and parameters of nn.Linear layer using random dimensions."""
         
     | 
| 
       18 
     | 
    
         
            -
                    for  
     | 
| 
      
 18 
     | 
    
         
            +
                    for _ in range(10):
         
     | 
| 
       19 
19 
     | 
    
         
             
                        n, in_c, out_c = torch.randint(1, 500, (3,)).tolist()
         
     | 
| 
       20 
20 
     | 
    
         
             
                        net = nn.Linear(in_c, out_c)
         
     | 
| 
       21 
21 
     | 
    
         
             
                        flops, params = profile(net, inputs=(torch.randn(n, in_c),))
         
     | 
| 
         @@ -148,7 +148,6 @@ def fx_profile(mod: nn.Module, input: th.Tensor, verbose=False): 
     | 
|
| 
       148 
148 
     | 
    
         
             
                    node_flops = None
         
     | 
| 
       149 
149 
     | 
    
         | 
| 
       150 
150 
     | 
    
         
             
                    input_shapes = []
         
     | 
| 
       151 
     | 
    
         
            -
                    output_shapes = []
         
     | 
| 
       152 
151 
     | 
    
         
             
                    fprint("input_shape:", end="\t")
         
     | 
| 
       153 
152 
     | 
    
         
             
                    for arg in node.args:
         
     | 
| 
       154 
153 
     | 
    
         
             
                        if str(arg) not in v_maps:
         
     | 
| 
         @@ -157,8 +156,7 @@ def fx_profile(mod: nn.Module, input: th.Tensor, verbose=False): 
     | 
|
| 
       157 
156 
     | 
    
         
             
                        input_shapes.append(v_maps[str(arg)])
         
     | 
| 
       158 
157 
     | 
    
         
             
                    fprint()
         
     | 
| 
       159 
158 
     | 
    
         
             
                    fprint(f"output_shape:\t{node.meta['tensor_meta'].shape}")
         
     | 
| 
       160 
     | 
    
         
            -
                    output_shapes 
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
      
 159 
     | 
    
         
            +
                    output_shapes = [node.meta["tensor_meta"].shape]
         
     | 
| 
       162 
160 
     | 
    
         
             
                    if node.op in ["output", "placeholder"]:
         
     | 
| 
       163 
161 
     | 
    
         
             
                        node_flops = 0
         
     | 
| 
       164 
162 
     | 
    
         
             
                    elif node.op == "call_function":
         
     | 
| 
         @@ -194,7 +192,7 @@ def fx_profile(mod: nn.Module, input: th.Tensor, verbose=False): 
     | 
|
| 
       194 
192 
     | 
    
         
             
                            print("weight_shape: None")
         
     | 
| 
       195 
193 
     | 
    
         
             
                        else:
         
     | 
| 
       196 
194 
     | 
    
         
             
                            print(type(m))
         
     | 
| 
       197 
     | 
    
         
            -
                            print(f"weight_shape: {mod.state_dict()[node.target 
     | 
| 
      
 195 
     | 
    
         
            +
                            print(f"weight_shape: {mod.state_dict()[f'{node.target}.weight'].shape}")
         
     | 
| 
       198 
196 
     | 
    
         | 
| 
       199 
197 
     | 
    
         
             
                    v_maps[str(node.name)] = node.meta["tensor_meta"].shape
         
     | 
| 
       200 
198 
     | 
    
         
             
                    if node_flops is not None:
         
     | 
| 
         @@ -10,9 +10,7 @@ multiply_adds = 1 
     | 
|
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
            def count_parameters(m, x, y):
         
     | 
| 
       12 
12 
     | 
    
         
             
                """Calculate and update the total number of parameters in a given PyTorch model."""
         
     | 
| 
       13 
     | 
    
         
            -
                total_params =  
     | 
| 
       14 
     | 
    
         
            -
                for p in m.parameters():
         
     | 
| 
       15 
     | 
    
         
            -
                    total_params += torch.DoubleTensor([p.numel()])
         
     | 
| 
      
 13 
     | 
    
         
            +
                total_params = sum(torch.DoubleTensor([p.numel()]) for p in m.parameters())
         
     | 
| 
       16 
14 
     | 
    
         
             
                m.total_params[0] = calculate_parameters(m.parameters())
         
     | 
| 
       17 
15 
     | 
    
         | 
| 
       18 
16 
     | 
    
         | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Metadata-Version: 2.1
         
     | 
| 
       2 
2 
     | 
    
         
             
            Name: ultralytics-thop
         
     | 
| 
       3 
     | 
    
         
            -
            Version: 0.2. 
     | 
| 
      
 3 
     | 
    
         
            +
            Version: 0.2.8
         
     | 
| 
       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: Glenn Jocher
         
     | 
| 
         @@ -74,7 +74,7 @@ import torch 
     | 
|
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
            model = resnet50()
         
     | 
| 
       76 
76 
     | 
    
         
             
            input = torch.randn(1, 3, 224, 224)
         
     | 
| 
       77 
     | 
    
         
            -
            macs, params = profile(model, inputs=(input, 
     | 
| 
      
 77 
     | 
    
         
            +
            macs, params = profile(model, inputs=(input,))
         
     | 
| 
       78 
78 
     | 
    
         
             
            ```
         
     | 
| 
       79 
79 
     | 
    
         | 
| 
       80 
80 
     | 
    
         
             
            ### Define Custom Rules for Third-Party Modules
         
     | 
| 
         @@ -84,16 +84,19 @@ You can define custom rules for unsupported modules: 
     | 
|
| 
       84 
84 
     | 
    
         
             
            ```python
         
     | 
| 
       85 
85 
     | 
    
         
             
            import torch.nn as nn
         
     | 
| 
       86 
86 
     | 
    
         | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
       87 
88 
     | 
    
         
             
            class YourModule(nn.Module):
         
     | 
| 
       88 
89 
     | 
    
         
             
                # your definition
         
     | 
| 
       89 
90 
     | 
    
         
             
                pass
         
     | 
| 
       90 
91 
     | 
    
         | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
       91 
93 
     | 
    
         
             
            def count_your_model(model, x, y):
         
     | 
| 
       92 
94 
     | 
    
         
             
                # your rule here
         
     | 
| 
       93 
95 
     | 
    
         
             
                pass
         
     | 
| 
       94 
96 
     | 
    
         | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
       95 
98 
     | 
    
         
             
            input = torch.randn(1, 3, 224, 224)
         
     | 
| 
       96 
     | 
    
         
            -
            macs, params = profile(model, inputs=(input, 
     | 
| 
      
 99 
     | 
    
         
            +
            macs, params = profile(model, inputs=(input,), custom_ops={YourModule: count_your_model})
         
     | 
| 
       97 
100 
     | 
    
         
             
            ```
         
     | 
| 
       98 
101 
     | 
    
         | 
| 
       99 
102 
     | 
    
         
             
            ### Improve Output Readability
         
     | 
| 
         @@ -102,6 +105,7 @@ Use `thop.clever_format` for a more readable output: 
     | 
|
| 
       102 
105 
     | 
    
         | 
| 
       103 
106 
     | 
    
         
             
            ```python
         
     | 
| 
       104 
107 
     | 
    
         
             
            from thop import clever_format
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
       105 
109 
     | 
    
         
             
            macs, params = clever_format([macs, params], "%.3f")
         
     | 
| 
       106 
110 
     | 
    
         
             
            ```
         
     | 
| 
       107 
111 
     | 
    
         | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
    
        {ultralytics_thop-0.2.7 → ultralytics_thop-0.2.8}/ultralytics_thop.egg-info/dependency_links.txt
    RENAMED
    
    | 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     |