pytorch / nestedtensor
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 436 units with 6,062 lines of code in units (58.8% of code).
    • 4 very long units (471 lines of code)
    • 19 long units (1,225 lines of code)
    • 54 medium size units (1,698 lines of code)
    • 83 small units (1,295 lines of code)
    • 276 very small units (1,373 lines of code)
7% | 20% | 28% | 21% | 22%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cpp14% | 30% | 27% | 17% | 9%
py0% | 11% | 23% | 27% | 37%
h0% | 0% | 36% | 22% | 40%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
nestedtensor/csrc13% | 24% | 30% | 18% | 13%
nestedtensor/csrc/cuda0% | 94% | 0% | 0% | 5%
nestedtensor/csrc/utils0% | 16% | 19% | 33% | 31%
nestedtensor/nn0% | 100% | 0% | 0% | 0%
nestedtensor/nested0% | 11% | 17% | 27% | 44%
ROOT0% | 70% | 0% | 0% | 29%
benchmarks0% | 0% | 29% | 31% | 38%
nestedtensor/csrc/storage0% | 0% | 46% | 16% | 37%
nestedtensor/csrc/scripts0% | 0% | 44% | 42% | 13%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
void add_functions()
in nestedtensor/csrc/python_functions.cpp
145 16 1
Tensor NestedTensor_batch_norm()
in nestedtensor/csrc/autograd_functions.cpp
121 21 9
Tensor NestedTensor_add_Tensor()
in nestedtensor/csrc/BinaryOps.cpp
103 25 3
bool _verify_variables()
in nestedtensor/csrc/creation.cpp
102 25 7
Tensor NestedTensor_conv2d()
in nestedtensor/csrc/conv2d.cpp
88 24 7
Tensor NestedTensor_cudnn_convolution_relu()
in nestedtensor/csrc/conv2d.cpp
88 24 7
Tensor to_padded_tensor()
in nestedtensor/csrc/masking.cpp
79 12 2
void register_python_nested_node()
in nestedtensor/csrc/utils/python_nested_node.cpp
71 12 1
def multi_head_attention_forward()
in nestedtensor/nn/mha.py
69 6 23
c10::optional nt_from_tensor_mask()
in nestedtensor/csrc/masking.cpp
67 24 3
Tensor NestedTensor_sub_Tensor()
in nestedtensor/csrc/BinaryOps.cpp
64 15 3
at::Tensor interpolate()
in nestedtensor/csrc/python_functions.cpp
64 14 5
at::Tensor bt_min_mha()
in nestedtensor/csrc/cuda/mha.cpp
64 1 12
def _nn_functional_embedding_bag()
in nestedtensor/nested/nested.py
64 19 11
Tensor NestedTensor_var_dim()
in nestedtensor/csrc/ReduceOps.cpp
63 9 4
Tensor NestedTensor_mul_Tensor()
in nestedtensor/csrc/BinaryOps.cpp
59 15 2
std::tuple to_tensor_mask()
in nestedtensor/csrc/masking.cpp
59 12 2
Tensor from_padded_tensor()
in nestedtensor/csrc/masking.cpp
58 7 2
57 14 0
Tensor NestedTensor_slice()
in nestedtensor/csrc/nested_tensor_impl.cpp
57 13 5