* Migrate POC for TensorFlow frontend Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Refactor InputModelTensorFlow API Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Repack POC to official API Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove tensorflow API from public include Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Make TF frontend work from MO and clean-up code Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply codestyle * Fix win biuld * Fix Linux build Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Implement Place class Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Determine outputs from graph * Implement all Place classes Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Make small clean-up Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code-style corrections Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Determine cut nodes * Apply codestyle * Rework to use places * Fix conversion issue * Fix build * Fix conversion * Small fixes * Add test for tf frontend * Add tests * Implement partial conversion * Use dynamic type in TFFrameworkNode * Fix build on Linux * Implement InputModelTF class Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix code by replacing InputModelTensorFlow to InputModelTF Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix to pass getPlaceByTensorName test Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Refactor and clean the code Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Finalize refactoring code Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Support freezing inputs Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Add support for pruning input ports as new model output Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code-style fixes Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * move op convertors to separate files, refactoring * openvino codestyle * openvino codestyle * fix crash of layer tests * fix missprint * Implement TensorFlow NodeContext and DecoderTFProto classes Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Switch to new NodeContext Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove ngraph_builder class and node_context_impl class Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Move decoder/graph_iterator to separate files and remove old files Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Document Decoder, GraphIterator, and NodeContext classes Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code style Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove empty file graph_iterator_proto.cpp and redundant comments Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Use base class for GraphIterator in model class and correct exception class Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Use ends_with from util library * Remain only InputModelTF constructor with GraphIterator and adopt other code Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Correct code after merge Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code style Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix code based on feedback: delete extra namespace usage, etc. Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Make legacy TF frontend default in MO and avoid reading tf models from ReadNetwork Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix build issue with FrameworkNode after upstream merge Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Correct frontend name in test and clean the code Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * refactoring of tf FrontEnd: rename namespaces, delete default opset * codestyle * fix e2e tests * change namespaces of external classes * resolve review comment * codestyle * Clean useless comments and fix tests Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Add copyright for proto files Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Make op translators a part of FrontEndTF Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Align CMakeLists.txt file with other frontends Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Add job_pool into CMakeLists.txt for tensorflow tests Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove cout and WA in ie_network_reader.cpp Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Correct DecoderBase and FrontEndTF methods, clean the code from if 0, utility.hpp, ngraph_conversions.hpp Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Clean operation translator code and remove empty implementation Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Extend cmake template files with tensorflow frontend Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code-style Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix build issues on MacOS and apply review feedback Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove ConstantFolding pass, add destructors for DecoderBase, GraphIterator, and fix Win build Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix Windows build issue Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code-style fix Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix issues with code style: remove virtual keyword, OpMap removal Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Resolve review remarks * Resolve review remarks * codestyle * resolve review remarks * fix copyright * resolve review comments Co-authored-by: Maxim Vafin <maxim.vafin@intel.com> Co-authored-by: Ivan Tikhonov <ivan.tikhonov@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