photosynthesis-team / piq

Measures and metrics for image2image tasks. PyTorch.
Apache License 2.0
1.32k stars 114 forks source link

FSIM Optimisation to Reduce CPU Usage #334

Closed denproc closed 1 year ago

denproc commented 1 year ago

Closes #266 Addresses the second part of #227

Proposed Changes

Outcome of the Proposed Changes

Note

Other places to consider for additional assessment of leaks

Appendix

Visual Comparison of CPU usage

htop following #266

Before

Branch: master

Screenshot 2023-02-05 at 00 42 23

After

Branch: bug/cpu_usage

Screenshot 2023-02-05 at 00 38 06

PyTorch Profiler Results. Top-8 operations.

-------------------------------------------------------  ------------  ------------  ------------  ------------  ------------  ------------  
                                                   Name    Self CPU %      Self CPU   CPU total %     CPU total  CPU time avg    # of Calls  
-------------------------------------------------------  ------------  ------------  ------------  ------------  ------------  ------------  
                                        model_inference        16.38%        8.624s       100.00%       52.639s       52.639s             1  
                                               aten::to         0.07%      37.231ms        68.84%       36.234s       1.020ms         35525  
                                         aten::_to_copy         0.14%      72.795ms        68.76%       36.197s       4.993ms          7250  
                                            aten::copy_         0.34%     177.512ms        61.16%       32.196s       2.019ms         15950  
                                  cudaStreamSynchronize        40.22%       21.173s        40.22%       21.173s       1.718ms         12325  
                                        cudaMemcpyAsync        20.68%       10.883s        20.68%       10.883s     883.015us         12325  
                                    aten::empty_strided         0.17%      88.161ms         7.78%        4.093s     564.510us          7250  
                                             cudaMalloc         7.62%        4.009s         7.62%        4.009s     129.312ms            31  
codecov[bot] commented 1 year ago

Codecov Report

Merging #334 (59fa153) into master (753030f) will increase coverage by 0.00%. The diff coverage is 96.66%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #334   +/-   ##
=======================================
  Coverage   91.96%   91.97%           
=======================================
  Files          34       34           
  Lines        2490     2493    +3     
=======================================
+ Hits         2290     2293    +3     
  Misses        200      200           
Flag Coverage Δ
unittests 91.97% <96.66%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
piq/psnr.py 80.00% <0.00%> (ø)
piq/functional/base.py 92.10% <71.42%> (ø)
piq/brisque.py 99.00% <100.00%> (ø)
piq/dss.py 100.00% <100.00%> (ø)
piq/fsim.py 100.00% <100.00%> (ø)
piq/functional/colour_conversion.py 100.00% <100.00%> (ø)
piq/functional/filters.py 100.00% <100.00%> (ø)
piq/gmsd.py 100.00% <100.00%> (ø)
piq/haarpsi.py 100.00% <100.00%> (ø)
piq/isc.py 90.90% <100.00%> (ø)
... and 7 more
sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

denproc commented 1 year ago

@snk4tr @zakajd Ready for review