Model Analyzer is the tool for estimating theoretical information on deep learning models layers.
Model Analyzer is used to estimate theoretical information on your model, such as the number of operations, memory consumption, and other characteristics.
NOTE: Model Analyzer works only with models in Intermediate Representation (IR) format. Refer to the Model Optimizer documentation to learn how to obtain IR model.
The tool analyzes the following parameters:
Parameter | Explanation | Unit of Measurement | Example |
---|---|---|---|
GFlop | Total number of floating-point operations required to infer a model. Summed up over known layers only. | Number of operations | 0.88418 × 109 |
GIop | Total number of integer operations required to infer a model. Summed up over known layers only. | Number of operations | 0.86748 × 109 |
Total number of weights | Total number of trainable model parameters excluding custom constants. Summed up over known layers only. | Number of weights | 3.489 × 106 |
Minimum Memory Consumption | Theoretical minimum of memory used by a model for inference given that the memory is reused as much as possible. Minimum Memory Consumption does not depend on weights. | Number of activations | 2.408 × 106 |
Maximum Memory Consumption | Theoretical maximum of memory used by a model for inference given that the memory is not reused, meaning all internal feature maps are stored in the memory simultaneously. Maximum Memory Consumption does not depend on weights. | Number of activations | 26.833 × 106 |
Sparsity | Percentage of zero weights | Percentage | 20% |
Run this command to get a list of available arguments:
python3 model_analyzer.py -h
Argument | Explanation | Example |
---|---|---|
-h , --help |
Displays help message. | N/A |
-m , --model |
Path to an .xml file of the Intermediate Representation (IR) model. Or path to .onnx or .prototxt file of ONNX model. | ./public/model/FP16/model.xml |
-w , --weights |
Path to the .bin file of the Intermediate Representation (IR) model. If not specified, the weights file name is expected to be the same as the .xml file passed with --model option. |
./public/model/FP16/model.bin |
--ignore-unknown-layers |
Ignores unknown types of layers when counting GFLOPs. | N/A |
-o , --report-dir |
Output directory. | /Home/user/Public/report |
--model-report |
Name for the file where theoretical analysis results are stored. | model_report.csv |
--per-layer-mode |
Enables collecting per-layer complexity metrics. | N/A |
--per-layer-report |
File name for the per-layer complexity metrics. Should be specified only when --per-layer-mode option is used. |
per_layer_report.csv |
--sparsity-ignored-layers |
Specifies ignored layers names separated by comma. | Constant, Elu, Split |
--sparsity-ignore-first-conv |
Ignores first Convolution layer for sparsity computation. | N/A |
--sparsity-ignore-fc |
Ignores FullyConnected layers for sparsity computation. | N/A |
Model Analyzer supports counting GFLOPs and GIOPs for the following layers:
List of Supported Layers
- Acosh - opset7
- Asinh - opset7
- Atanh - opset7
- Add - opset7
- ArgMax
- AvgPool - opset7
- BatchNormalization
- BinaryConvolution - opset7
- Clamp - opset7
- Concat - opset7
- Const - opset7
- Constant - opset7
- Convolution - opset7
- ConvolutionBackPropData - opset7
- Crop
- Deconvolution - opset7
- DeformableConvolution - opset7
- Divide - opset7
- Eltwise
- Elu - opset7
- Exp- opset7
- FullyConnected
- GEMM - opset7
- GRN - opset7
- Gather - opset7
- GatherND - opset7
- Greater - opset7
- GreaterEqual - opset7
- GroupConvolution - opset7
- GroupConvolutionBackpropData - opset7
- HSigmoid - opset7
- HSwish - opset7
- Input opset7
- Interp - opset7
- Less - opset7
- LessEqual - opset7
- Log - opset7
- MVN - opset7
- MatMul - opset7
- MaxPool - opset7
- Mish - opset7
- Multiply - opset7
- Norm
- Normalize - opset7
- NormalizeL2 - opset7
- OneHot - opset7
- Output - opset7
- PReLU - opset7
- PSROIPooling - opset7
- Pad - opset7
- Parameter - opset7
- Permute
- Pooling - opset7
- Power - opset7
- Priorbox - opset7
- PriorboxClustered - opset7
- Proposal - opset7
- ROIPooling - opset7
- Range - opset7
- ReLu - opset7
- ReduceL1 - opset7
- ReduceL2 - opset7
- ReduceMin - opset7
- Reshape - opset7
- Result - opset7
- ReverseSequence - opset7
- ScaleShift
- ScatterNDUpdate - opset7
- Select - opset7
- Sigmoid - opset7
- Softmax - opset7
- SoftPlus - opset7
- SparseToDense
- Split - opset7
- Squeeze - opset7
- StridedSlice - opset7
- Subtract - opset7
- Swish - opset7
- Tanh - opset7
- Tile - opset7
- Unsqueeze - opset7
This is an example of running Model Analyzer with mobilenet-v2 model:
- Install OpenVINO Toolkit Developer Package:
python3 pip install openvino-dev
- Clone the repository:
git clone git@github.com:openvinotoolkit/model_analyzer.git
cd model_analyzer
- Download a model with OMZ Model Downloader:
omz_downloader --name mobilenet-v2
- Convert the model to IR with Model Converter:
omz_converter --name mobilenet-v2
- Run Model Analyzer:
python3 model_analyzer.py --model ./public/mobilenet-v2/FP16/mobilenet-v2.xml --ignore-unknown-layers
You will get the following output:
OUTPUT:
[ INFO ] Loading network files:
public/mobilenet-v2/FP16/mobilenet-v2.xml
public/mobilenet-v2/FP16/mobilenet-v2.bin
Warning, GOPS for layer(s) wasn't counted - ReduceMean
[ INFO ] GFLOPs: 0.8842
[ INFO ] GIOPs: 0.0000
[ INFO ] MParams: 3.4889
[ INFO ] Sparsity: 0.0001
[ INFO ] Minimum memory consumption: 2.4084
[ INFO ] Maximum memory consumption: 26.8328
[ INFO ] Guessed type: classificator
[ INFO ] Network status information file name: /home/user/model_analyzer/model_report.csv
Find the instructions for contributors in the DEVELOPER.md document.
- Note that Model Analyzer provides approximate theoretical information, as some of the layers may be ignored due to the model structure.
- At the analysis stage, Model Analyzer can detect layers for which no information is available. Use
--ignore-unknown-layers
option to avoid errors. Feel free to submit your suggestions on how to analyze these layers.
List of Ignored Layers
- Abs - opset7
- BatchToSpace - opset7
- Broadcast - opset7
- Bucketize - opset7
- Convert - opset7
- CtcGreedyDecoder - opset7
- DetectionOutput - opset7
- Erf - opset7
- ExperimentalDetectronDetectionOutput - opset7
- ExperimentalDetectronGenerateProposalsSingleImage - opset7
- ExperimentalDetectronPriorGridGenerator - opset7
- ExperimentalDetectronRoiFeatureExtractor - opset7
- ExperimentalDetectronTopkRois - opset7
- ExperimentalSparseWeightedSum
- FakeQuantize - opset7
- Flatten
- GatherTree - opset7
- NonMaxSuppression - opset7
- PredictionHeatMap
- ReSample
- RegionYolo - opset7
- ReorgYolo - opset7
- Slice - opset7
- SpaceToBatch - opset7
- SpatialTransformer
- TensorIterator - opset7
- TopK - opset7
- Transpose - opset7
- VariadicSplit - opset7