pytorch / functorch
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 605 units with 6,887 lines of code in units (56.3% of code).
    • 2 very long units (251 lines of code)
    • 14 long units (1,021 lines of code)
    • 61 medium size units (1,887 lines of code)
    • 129 small units (1,794 lines of code)
    • 399 very small units (1,934 lines of code)
3% | 14% | 27% | 26% | 28%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py8% | 7% | 28% | 21% | 34%
cpp0% | 20% | 26% | 30% | 23%
h0% | 19% | 36% | 16% | 27%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
functorch/_src6% | 6% | 30% | 22% | 32%
benchmarks37% | 0% | 0% | 19% | 43%
functorch/csrc0% | 20% | 26% | 29% | 23%
op_analysis0% | 64% | 0% | 11% | 24%
benchmarks/transformer_fusion_patterns0% | 0% | 73% | 8% | 18%
ROOT0% | 0% | 72% | 0% | 27%
codegen0% | 0% | 13% | 34% | 51%
functorch0% | 0% | 44% | 23% | 31%
notebooks/_src0% | 0% | 0% | 40% | 60%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def minimizer()
in functorch/_src/fx_minifier.py
129 31 3
def main()
in benchmarks/operator_authoring.py
122 6 0
void batchedTensorForLoopFallback()
in functorch/csrc/BatchedFallback.cpp
100 16 2
std::tuple batch_norm_backward_plumbing()
in functorch/csrc/BatchRulesNorm.cpp
86 11 10
void boxed_reduction_batch_rule()
in functorch/csrc/BatchRulesReduceOps.cpp
84 26 2
def gen_data()
in op_analysis/gen_data.py
82 27 2
void batchedTensorInplaceForLoopFallback()
in functorch/csrc/BatchedFallback.cpp
78 11 2
std::tuple native_layer_norm_backward_plumbing()
in functorch/csrc/BatchRulesNorm.cpp
78 11 8
void dynamicLayerBackFallback()
in functorch/csrc/DynamicLayer.cpp
74 16 2
std::tuple native_group_norm_backward_plumbing()
in functorch/csrc/BatchRulesNorm.cpp
73 7 10
std::tuple nll_loss_forward_decomposition()
in functorch/csrc/BatchRulesLoss.cpp
66 18 5
def partition_with_recompute_fwd_in_bwd()
in functorch/_src/aot_autograd.py
63 15 2
def compute_code()
in functorch/_src/operator_authoring.py
62 19 1
void call()
in functorch/csrc/PointwiseOperatorCompileCache.cpp
60 11 1
std::tuple convolution_backward_plumbing()
in functorch/csrc/BatchRulesConvolution.cpp
59 10 11
inline void boxed_all_tensors_have_optional_bdim()
in functorch/csrc/BatchRulesHelper.h
56 10 2
def tensorexpr_compile()
in functorch/_src/compilers.py
50 18 2
def profile_cuda_kernels()
in benchmarks/transformer_fusion_patterns/benchmark_helper.py
47 6 3
Tensor binary_cross_entropy_backward_plumbing()
in functorch/csrc/BatchRulesLoss.cpp
43 8 5
void boxed_tensor_inputs_batch_rule()
in functorch/csrc/BatchRulesHelper.h
43 8 2