pytorch / vision
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
Unit Size Overall
  • There are 2,596 units with 26,526 lines of code in units (51.6% of code).
    • 14 very long units (2,181 lines of code)
    • 55 long units (3,666 lines of code)
    • 193 medium size units (5,864 lines of code)
    • 358 small units (5,203 lines of code)
    • 1,976 very small units (9,612 lines of code)
8% | 13% | 22% | 19% | 36%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cpp15% | 28% | 34% | 12% | 8%
py5% | 6% | 17% | 22% | 48%
h0% | 44% | 8% | 9% | 37%
m0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
torchvision/csrc14% | 29% | 33% | 12% | 9%
references/classification38% | 20% | 17% | 6% | 16%
ROOT80% | 0% | 12% | 0% | 7%
references/video_classification33% | 25% | 13% | 4% | 23%
references/segmentation18% | 18% | 3% | 21% | 38%
references/detection0% | 23% | 36% | 9% | 30%
references/optical_flow0% | 29% | 26% | 13% | 30%
torchvision/models0% | 2% | 19% | 27% | 50%
torchvision/prototype0% | 2% | 11% | 21% | 65%
packaging/wheel0% | 28% | 39% | 9% | 23%
torchvision/datasets0% | 2% | 14% | 28% | 54%
torchvision/transforms0% | 3% | 15% | 32% | 49%
torchvision/ops0% | 0% | 12% | 22% | 65%
torchvision/io0% | 0% | 18% | 18% | 62%
gallery0% | 0% | 34% | 25% | 40%
torchvision0% | 0% | 33% | 7% | 59%
references/similarity0% | 0% | 12% | 70% | 16%
scripts/release_notes0% | 0% | 0% | 29% | 70%
scripts0% | 0% | 0% | 0% | 100%
ios/VisionTestApp0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
293 72 0
torch::List readVideo()
in torchvision/csrc/io/video_reader/video_reader.cpp
210 18 21
at::Tensor deform_conv2d_forward_kernel()
in torchvision/csrc/ops/cpu/deform_conv2d_kernel.cpp
198 15 14
torch::Tensor decode_png()
in torchvision/csrc/io/image/cpu/decode_png.cpp
175 39 3
def main()
in references/video_classification/train.py
169 34 1
def main()
in references/classification/train.py
160 42 1
bool Decoder::init()
in torchvision/csrc/io/decoder/decoder.cpp
151 31 3
std::tuple backward_gradient_inputs()
in torchvision/csrc/ops/cpu/deform_conv2d_kernel.cpp
140 6 15
def get_args_parser()
in references/classification/train.py
120 1 1
torch::List probeVideo()
in torchvision/csrc/io/video_reader/video_reader.cpp
118 10 3
torch::Tensor decode_jpeg_cuda()
in torchvision/csrc/io/image/cuda/decode_jpeg_cuda.cpp
116 13 3
def main()
in references/classification/train_quantization.py
113 24 1
def main()
in references/segmentation/train.py
113 28 1
at::Tensor backward_gradient_parameters()
in torchvision/csrc/ops/cpu/deform_conv2d_kernel.cpp
105 5 15
def get_args_parser()
in references/classification/train_quantization.py
96 1 1
void qroi_align_forward_kernel_impl()
in torchvision/csrc/ops/quantized/cpu/qroi_align_kernel.cpp
96 11 12
def main()
in references/detection/train.py
95 26 1
void deformable_col2im_coord_kernel()
in torchvision/csrc/ops/cpu/deform_conv2d_kernel.cpp
94 9 24
void cpu_upsample_genNd_backward_aa()
in torchvision/csrc/ops/cpu/interpolate_aa_kernels.cpp
94 14 4
def get_args_parser()
in references/detection/train.py
87 1 1