tensorflow / mesh
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 1,032 units with 16,737 lines of code in units (87.5% of code).
    • 23 very long units (3,664 lines of code)
    • 41 long units (2,777 lines of code)
    • 176 medium size units (5,383 lines of code)
    • 154 small units (2,324 lines of code)
    • 638 very small units (2,589 lines of code)
21% | 16% | 32% | 13% | 15%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py21% | 16% | 32% | 13% | 15%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
mesh_tensorflow/transformer24% | 20% | 34% | 10% | 10%
mesh_tensorflow/bert42% | 12% | 20% | 13% | 10%
mesh_tensorflow/experimental22% | 24% | 26% | 16% | 9%
mesh_tensorflow5% | 8% | 37% | 20% | 28%
mesh_tensorflow/auto_mtf0% | 19% | 23% | 19% | 36%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def tpu_estimator_model_fn()
in mesh_tensorflow/transformer/utils.py
431 80 26
def beam_search()
in mesh_tensorflow/beam_search.py
214 19 12
def transformer_moe_layer_v1()
in mesh_tensorflow/transformer/heterogeneous_moe.py
204 31 12
def run()
in mesh_tensorflow/transformer/utils.py
202 32 21
def transformer_moe_layer_v1()
in mesh_tensorflow/transformer/moe.py
187 27 11
def unet_with_spatial_partition()
in mesh_tensorflow/experimental/unet.py
185 18 5
def model_fn_builder()
in mesh_tensorflow/bert/run_pretraining.py
169 10 5
def eval_model()
in mesh_tensorflow/transformer/utils.py
150 38 13
def main()
in mesh_tensorflow/bert/run_classifier.py
150 31 1
def write_predictions()
in mesh_tensorflow/bert/run_squad.py
147 34 9
def model_fn_builder()
in mesh_tensorflow/bert/run_classifier.py
143 14 7
def synthetic_attention()
in mesh_tensorflow/transformer/attention.py
142 20 15
def sample_autoregressive()
in mesh_tensorflow/transformer/transformer.py
136 18 6
def _top_2_gating()
in mesh_tensorflow/transformer/moe.py
136 28 11
def model_fn_builder()
in mesh_tensorflow/bert/run_squad.py
136 13 6
def convert_examples_to_features()
in mesh_tensorflow/bert/run_squad.py
134 41 7
def main()
in mesh_tensorflow/bert/run_squad.py
123 12 1
def get_dataset_creator()
in mesh_tensorflow/experimental/unet.py
120 17 1
def _ntlb_gating()
in mesh_tensorflow/transformer/moe.py
119 17 11
def _top_n_gating()
in mesh_tensorflow/transformer/moe.py
113 35 11