frgfm / torch-scan

Seamless analysis of your PyTorch models (RAM usage, FLOPs, MACs, receptive field, etc.)
https://frgfm.github.io/torch-scan/latest
Apache License 2.0
208 stars 22 forks source link

fix: Fixed support of modules that are used multiple times during forward #24

Closed frgfm closed 4 years ago

frgfm commented 4 years ago

This PR handles the cases where a single module is reused multiple times. The issue was that with the initial hooking mechanism, the module gets hooked N times, and upon the forward pass, it will trigger N hooks each time the module is used. This was handled by:

codecov[bot] commented 4 years ago

Codecov Report

Merging #24 into master will decrease coverage by 0.28%. The diff coverage is 82.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #24      +/-   ##
==========================================
- Coverage   89.75%   89.46%   -0.29%     
==========================================
  Files           9        9              
  Lines         527      560      +33     
==========================================
+ Hits          473      501      +28     
- Misses         54       59       +5     
Impacted Files Coverage Δ
torchscan/crawler.py 82.08% <80.55%> (+0.18%) :arrow_up:
torchscan/modules/flops.py 99.01% <100.00%> (ø)
torchscan/modules/macs.py 100.00% <100.00%> (ø)
torchscan/modules/memory.py 100.00% <100.00%> (ø)
torchscan/modules/receptive.py 100.00% <100.00%> (ø)