pytorch / xla
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,676 units with 24,089 lines of code in units (67.0% of code).
    • 3 very long units (649 lines of code)
    • 16 long units (953 lines of code)
    • 191 medium size units (5,491 lines of code)
    • 476 small units (6,865 lines of code)
    • 1,990 very small units (10,131 lines of code)
2% | 3% | 22% | 28% | 42%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cpp3% | 4% | 21% | 29% | 41%
py0% | 1% | 30% | 27% | 41%
h0% | 0% | 11% | 3% | 85%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
torch_xla/csrc3% | 4% | 20% | 28% | 42%
torch_xla/distributed0% | 3% | 45% | 25% | 25%
torch_xla/core0% | 0% | 23% | 23% | 53%
scripts0% | 0% | 27% | 30% | 41%
torch_xla/debug0% | 0% | 30% | 35% | 34%
torch_xla/amp0% | 0% | 69% | 15% | 14%
torch_xla/utils0% | 0% | 9% | 29% | 61%
contrib/scripts0% | 0% | 61% | 15% | 23%
torch_xla0% | 0% | 30% | 11% | 58%
ROOT0% | 0% | 16% | 58% | 25%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
void InitXlaModuleBindings()
in torch_xla/csrc/init_python_bindings.cpp
430 8 1
NmsResult BuildNms()
in torch_xla/csrc/nms_op.cpp
118 2 5
std::vector OpByOpExecutor::BuildOps()
in torch_xla/csrc/op_by_op_executor.cpp
101 12 3
xla::XlaOp ComputeMaxPoolIndices()
in torch_xla/csrc/pooling.cpp
78 2 5
void TensorToBufferSType()
in torch_xla/csrc/tensor_util.cpp
68 16 5
NodePtr ARange()
in torch_xla/csrc/ops/ops.cpp
68 16 4
void BuildProfilerSubmodule()
in torch_xla/csrc/init_python_bindings.cpp
64 4 1
xla::XlaOp XlaDenseScatter()
in torch_xla/csrc/xla_lower_util.cpp
62 11 5
py::object RecordReadExample()
in torch_xla/csrc/init_python_bindings.cpp
61 10 1
61 11 2
XlaOpVector Scalar::Lower()
in torch_xla/csrc/ops/scalar.cpp
60 17 1
std::string DebugUtil::GetTensorsGraphInfo()
in torch_xla/csrc/debug_util.cpp
58 13 3
void PopulateTensorBuffer()
in torch_xla/csrc/tensor_util.cpp
56 13 5
ir::Value ApplyUpdate()
in torch_xla/csrc/view.cpp
56 11 2
54 4 4
xla::XlaOp RngUniform()
in torch_xla/csrc/random.cpp
52 11 4
52 5 3
def run()
in torch_xla/distributed/xla_dist.py
52 11 2
xla::XlaOp CreateIndexUpdate()
in torch_xla/csrc/xla_lower_util.cpp
51 7 5
xla::XlaOp RngNormal()
in torch_xla/csrc/random.cpp
50 7 4