* Added transposes insertion for Parameter and Result. * Separated into several transformations. * Corrected runtime_info format. * Fixed runtime info serialization. * Code refactoring. * Corrected checks. * Added debug output. * Added check. * Fixed unit tests. * Changed old api map format, removed debug output. * Moved serialize to rt_info property, code corrections. * Refactored RTInfo class. * Small corrections. * Small corrections. * Removed redurant import. * Added tests, added undefined default type. * Code reformat. * Fixed serialization unit tests. * Added comment. * Added comment. * Small test correction. * Changed default values of old_api_map to values from old API IR. * np.array -> int64_array * Update MO to use FE to read IR; Swith MO IR version to 11 * Preserve output node name when inserting Transpose * Codestyle * Fix layer tests * Pylint fix * Disable ref_graphs comparision in layer tests * codestyle * Updated MO IR reader. * Moved version initialization to constructor of OldApiMap. * Added shape infer after transpose insertion. * Fixed Pylint * Removed wrong attribute removal. * Added transposes insertion for Parameter and Result. * Separated into several transformations. * Corrected runtime_info format. * Fixed runtime info serialization. * Code refactoring. * Corrected checks. * Added debug output. * Added check. * Fixed unit tests. * Changed old api map format, removed debug output. * Moved serialize to rt_info property, code corrections. * Refactored RTInfo class. * Small corrections. * Small corrections. * Removed redurant import. * Added tests, added undefined default type. * Code reformat. * Fixed serialization unit tests. * Added comment. * Added comment. * Small test correction. * Changed default values of old_api_map to values from old API IR. * np.array -> int64_array * Update MO to use FE to read IR; Swith MO IR version to 11 * Preserve output node name when inserting Transpose * Codestyle * Fix layer tests * Pylint fix * Disable ref_graphs comparision in layer tests * codestyle * Updated MO IR reader. * Moved version initialization to constructor of OldApiMap. * Added shape infer after transpose insertion. * Fixed Pylint * Removed wrong attribute removal. * Serialize fix. Co-authored-by: Gleb Kazantaev <gleb.kazantaev@intel.com>
Prerequisites
Model Optimizer requires:
-
Python 3 or newer
-
[Optional] Please read about use cases that require Caffe* to be available on the machine in the documentation.
Installation instructions
- Go to the Model Optimizer folder:
cd PATH_TO_INSTALL_DIR/tools/model_optimizer
-
Create virtual environment and activate it. This option is strongly recommended as it creates a Python sandbox and dependencies for the Model Optimizer do not influence global Python configuration, installed libraries etc. At the same time, special flag ensures that system-wide Python libraries are also available in this sandbox. Skip this step only if you do want to install all Model Optimizer dependencies globally:
- Create environment:
virtualenv -p /usr/bin/python3.6 .env3 --system-site-packages
- Activate it:
. .env3/bin/activate
- Create environment:
-
Install dependencies. If you want to convert models only from particular framework, you should use one of available
requirements_*.txtfiles corresponding to the framework of choice. For example, for Caffe userequirements_caffe.txtand so on. When you decide to switch later to other frameworks, please install dependencies for them using the same mechanism:pip3 install -r requirements.txt
Or you can use the installation scripts from the "install_prerequisites" directory.
-
[OPTIONAL] If you use Windows OS, most probably you get python version of
protobuflibrary. It is known to be rather slow, and you can use a boosted version of library by building the .egg file (Python package format) yourself, using instructions below (section 'How to boost Caffe model loading') for the target OS and Python, or install it with the pre-built .egg (it is built for Python 3.4, 3.5, 3.6, 3.7):python3 -m easy_install protobuf-3.6.1-py3.6-win-amd64.egg
It overrides the protobuf python package installed by the previous command.
Set environment variable to enable boost in protobuf performance:
set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
Setup development environment
How to run unit-tests
- Run tests with:
python -m unittest discover -p "*_test.py" [-s PATH_TO_DIR]
How to capture unit-tests coverage
- Run tests with:
coverage run -m unittest discover -p "*_test.py" [-s PATH_TO_DIR]
- Build html report:
coverage html
How to run code linting
- Run the following command:
pylint mo/ extensions/ mo.py