Skip to content

openvinotoolkit/model_analyzer

Repository files navigation

OpenVINO™ Model Analyzer

Model Analyzer is the tool for estimating theoretical information on deep learning models layers.

📝 Description

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%

⚙️ Command-Line Interface

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

💻 Run Model Analyzer

This is an example of running Model Analyzer with mobilenet-v2 model:

  1. Install OpenVINO Toolkit Developer Package:
python3 pip install openvino-dev
  1. Clone the repository:
git clone git@github.com:openvinotoolkit/model_analyzer.git
cd model_analyzer
  1. Download a model with OMZ Model Downloader:
omz_downloader --name mobilenet-v2
  1. Convert the model to IR with Model Converter:
omz_converter --name mobilenet-v2 
  1. 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.

⚠️ Limitations

  1. Note that Model Analyzer provides approximate theoretical information, as some of the layers may be ignored due to the model structure.
  2. 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

About

Model Analyzer is the Network Statistic Information tool

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages