Skip to content

Commit

Permalink
Refactor code for speed and clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed Jun 20, 2024
1 parent 9517cac commit af86310
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<br>
<img src="https://raw.githubusercontent.com/ultralytics/assets/main/logo/Ultralytics_Logotype_Original.svg" width="320">
<a href="https://ultralytics.com" target="_blank"><img src="https://raw.githubusercontent.com/ultralytics/assets/main/logo/Ultralytics_Logotype_Original.svg" width="320" alt="Ultralytics logo"></a>

# 🚀 THOP: PyTorch-OpCounter

Expand Down Expand Up @@ -154,7 +154,7 @@ For bugs or feature requests, please open an issue on [GitHub Issues](https://gi
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
<a href="https://www.tiktok.com/@ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-tiktok.png" width="3%" alt="Ultralytics TikTok"></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
<a href="https://www.instagram.com/ultralytics/"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-instagram.png" width="3%" alt="Ultralytics Instagram"></a>
<a href="https://ultralytics.com/bilibili"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-bilibili.png" width="3%" alt="Ultralytics Instagram"></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
<a href="https://ultralytics.com/discord"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="3%" alt="Ultralytics Discord"></a>
</div>
3 changes: 1 addition & 2 deletions benchmark/evaluate_famous_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import torch
from torchvision import models

from thop.profile import profile
from torchvision import models

model_names = sorted(
name
Expand Down
1 change: 0 additions & 1 deletion benchmark/evaluate_rnn_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import torch
import torch.nn as nn

from thop.profile import profile

input_size = 160
Expand Down
1 change: 0 additions & 1 deletion tests/test_conv2d.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import torch
import torch.nn as nn

from thop import profile


Expand Down
1 change: 0 additions & 1 deletion tests/test_matmul.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import torch
import torch.nn as nn

from thop import profile


Expand Down
1 change: 0 additions & 1 deletion tests/test_relu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import torch
import torch.nn as nn

from thop import profile


Expand Down
2 changes: 1 addition & 1 deletion thop/vision/basic_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def zero_ops(m, x, y):
def count_convNd(m: _ConvNd, x, y: torch.Tensor):
"""Calculate and add the number of convolutional operations (FLOPs) to the model's total operations count."""
x = x[0]

m.total_ops += calculate_conv2d_flops(
input_size=list(x.shape),
output_size=list(y.shape),
Expand Down

0 comments on commit af86310

Please sign in to comment.