apple / coremltools
Conditional Complexity

The distribution of complexity of units (measured with McCabe index).

Intro
  • Conditional complexity (also called cyclomatic complexity) is a term used to measure the complexity of software. The term refers to the number of possible paths through a program function. A higher value ofter means higher maintenance and testing costs (infosecinstitute.com).
  • Conditional complexity is calculated by counting all conditions in the program that can affect the execution path (e.g. if statement, loops, switches, and/or operators, try and catch blocks...).
  • Conditional complexity is measured at the unit level (methods, functions...).
  • Units are classified in four categories based on the measured McCabe index: 1-5 (simple units), 6-10 (medium complex units), 11-25 (complex units), 26+ (very complex units).
Learn more...
Conditional Complexity Overall
  • There are 3,342 units with 43,361 lines of code in units (59.7% of code).
    • 6 very complex units (1,413 lines of code)
    • 45 complex units (4,326 lines of code)
    • 240 medium complex units (10,638 lines of code)
    • 405 simple units (9,950 lines of code)
    • 2,646 very simple units (17,034 lines of code)
3% | 9% | 24% | 22% | 39%
Legend:
51+
26-50
11-25
6-10
1-5
Alternative Visuals
Conditional Complexity per Extension
51+
26-50
11-25
6-10
1-5
cpp10% | 11% | 26% | 20% | 32%
py1% | 9% | 24% | 23% | 41%
hpp0% | 0% | 20% | 27% | 52%
mm0% | 0% | 0% | 50% | 49%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
mlmodel/src9% | 11% | 26% | 21% | 31%
coremltools/converters1% | 9% | 25% | 23% | 39%
coremltools/models0% | 12% | 14% | 21% | 52%
modelpackage/src0% | 0% | 15% | 0% | 84%
coremlpython0% | 0% | 0% | 50% | 49%
mlmodel/tools0% | 0% | 0% | 0% | 100%
milstoragepython0% | 0% | 0% | 0% | 100%
coremltools/_deps0% | 0% | 0% | 0% | 100%
scripts0% | 0% | 0% | 0% | 100%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
Result NeuralNetworkSpecValidator::validateLayer()
in mlmodel/src/Validation/NeuralNetwork/NeuralNetworkValidator.cpp
299 160 1
Result validateFeatureDescription()
in mlmodel/src/Validation/InterfaceValidators.cpp
271 86 3
Result validate()
in mlmodel/src/Validation/NonMaximumSuppressionValidator.cpp
250 78 1
def functionalize_loops()
in coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/functionalize_loops.py
243 72 3
Result validateNeuralNetworkTopLevel()
in mlmodel/src/Validation/NeuralNetwork/NeuralNetworkValidator.cpp
165 63 4
def load()
in coremltools/converters/mil/backend/mil/load.py
185 56 4
def _check_fp16_weight_param_exists()
in coremltools/models/neural_network/builder.py
71 50 2
def _try_to_transform()
in coremltools/converters/mil/mil/passes/gelu_tanh_approximation_fusion.py
88 45 2
def _quantize_nn_spec()
in coremltools/models/neural_network/quantization_utils.py
345 45 4
def extract_subgraph()
in coremltools/converters/mil/frontend/tensorflow/tfssa.py
99 44 4
57 44 1
def _pattern_match_and_rewrite()
in coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/fuse_dilation_conv.py
93 43 2
def StridedSlice()
in coremltools/converters/mil/frontend/tensorflow/ops.py
127 42 2
def _try_match_and_transform_pattern_4()
in coremltools/converters/mil/mil/passes/layernorm_instancenorm_pattern_fusion.py
108 42 2
void NeuralNetworkShaper::ProcessLayer()
in mlmodel/src/Validation/NeuralNetwork/NeuralNetworkShapes.cpp
127 42 1
def _try_to_transform()
in coremltools/converters/mil/mil/passes/conv_scale_fusion.py
81 41 3
bool CoreML::hasWeightOfType()
in mlmodel/src/Utils.cpp
59 40 2
def remove_redundant_transposes()
in coremltools/converters/mil/backend/nn/passes/mlmodel_passes.py
117 39 1
Result NeuralNetworkSpecValidator::validateConvolutionLayer()
in mlmodel/src/Validation/NeuralNetwork/NeuralNetworkLayerValidator.cpp
123 39 1
Result validate()
in mlmodel/src/Validation/WordTaggerValidator.cpp
124 37 1