6ef59ce3e4
* Preprocessing API - base classes Includes API definition for trivial mean/scale operations (which don't require layout) Mean/scale with 'layout' support will be done under separate task together with Layout Current test code coverage: 100% * Python bindings for base preprocessing API * remove pre_post_process directory from ngraph/core * remove files from ngraph/python dir * move pyngraph pre_post_process files from ngraph/python to runtime * remove pre_post_process test from CMakeList * move include to the header * update include path for pre_post_process * style fix * bind InputTensorInfo::set_layout * cleaned test_preprocess * fix test expected output * remove duplicate test * update description of set_element_type * fix style * move preprocess from pyngraph to pyopenvino/graph * update test_preprocess imports and remove unnecessary test * remove duplicate import * update custom method * update test * update test * create decorator that changes Node into Output<Node> * create function that cast Node to Output<Node> * update test_preprocess to use decorator for custom function * change _cast_to_output -> _from_node * move frontend folder to pyopenvino * rename includes and add compile options * include frontend to pyopenvino * move __init__.py * move tests * remove mock from tests_compatibility * rename import module * Fix code style cpp * refactor a few lines * style fix * update few lines in mo * add tests fro scale and mean with vector input * style fix * add docstring for custom_preprocess_function * bind InputInfo network method * style fix * Add pyopenvino to dependencies * bind OutputInfo * fix description of preprocess submodule * fix style * update copyright year * Fix mock * update docstring * bind OutputTensorInfo * bind OutputNetworkInfo and InputNetworkInfo * bind ColorFormat and ResizeAlgorithm * clean imports * fix typo * add PostProcessSteps to init * bind PreProcessSteps * create additional tests * Fix mo test * remove module local * fix code style * update comment * fix return type * update docs * fix code style * change ngraph.Type to ov.Type * fix typo * move _from_node to node_output.hpp * add read_model from buffer * update imports * add new line * remove bad quotes * update imports * style fix * add new line * rename functin args * remove Type import * update tests * style fix * test clean * remove blank line * update PrePostProcessor init and build methods * create test with model update tests with new PrePostProcessor init and build * # Conflicts: # inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api.pyx # inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.cpp # inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.hpp # inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl_defs.pxd # inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp # inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp # model-optimizer/mo/moc_frontend/serialize.py # thirdparty/gflags/gflags # thirdparty/gtest/gtest * Stash * move preprocess module from openvino.impl to openvino * fix building * fix code style * try to move MO to use new api * Intermediate commit * try to move MO to use new api * Test pybind11 custom holder for Preprocessing types (InputInfo and PreProcessingSteps) * Initial code for source_target layout handling for preprocessing Initial implementation of reverse input channels * Use input's tensor names instead of friendly names * Skeleton for guessing layouts and clearing it after preprocessing * updated package_BOM.txt * Use reference_wrapper for preprocess bindings * Update tests * Layout::find_permutation - support of dynamic layouts Covered case for 'trivial convert' where no permutation is needed It is needed for Model Optimizer for logic which will guess model's layout, like "?c??" * Stash * add bindings to I420_SINGLE_PLANE and I420_THREE_PLANES * remove init from all classes except PrePostProcessor and add RGBX and BGRX to ColorFormat enum * Guess layout so that existing mean/scale tests passed * update test name * Draft to guess layout for 'reverse_input_channels' * More unit tests (error cases) * pylint & flake8 * pylint - ignore import error * Stash * Moved preprocessing to 'back' folder * More tests * Update package_BOM * Support layout_values with no names Support layout set for 'outputs' Tests * Export more enum names from nrgaph * Basic --layout parsing * removed debug prints * Further updates after rebase * Update imports * Removed part from 8829 * Fix imports in test code * Minor cosmetics * Don't guess 'C' if layout is already set by model Expose 'Layout::empty' method * Style fix * Apply review comments Restricted 'heuristics' C++: Added 'fp16', 'fp64' support to mean/scale * Applied review comments * Added some dynamic test cases * Move call of 'apply_preprocessing' to 'serialize.py' * Unnecessary change * Added more comments to code Co-authored-by: pszmel <piotr.szmelczynski@intel.com> Co-authored-by: Alexey Lebedev <alexey.lebedev@intel.com> Co-authored-by: bszmelcz <bartosz.szmelczynski@intel.com> Co-authored-by: Anastasia Kuporosova <anastasia.kuporosova@intel.com> Co-authored-by: y <ilya.lavrenov@intel.com> Co-authored-by: Vafin, Maxim <maxim.vafin@intel.com>
46 lines
1.8 KiB
Python
46 lines
1.8 KiB
Python
# Copyright (C) 2018-2021 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import argparse
|
|
import os
|
|
from mo.pipeline.common import get_ir_version
|
|
from mo.back.ie_ir_ver_2.emitter import append_ir_info
|
|
from mo.back.preprocessing import apply_preprocessing
|
|
from mo.utils.cli_parser import get_meta_info, parse_transform
|
|
|
|
from openvino.runtime import Function # pylint: disable=no-name-in-module,import-error
|
|
|
|
|
|
def moc_emit_ir(ngraph_function: Function, argv: argparse.Namespace):
|
|
output_dir = argv.output_dir if argv.output_dir != '.' else os.getcwd()
|
|
|
|
# Apply preprocessing (mean/scale/reverse_channels/convert_layout/etc)
|
|
apply_preprocessing(ov_function=ngraph_function, argv=argv)
|
|
|
|
# Apply transformations
|
|
from mo.back.offline_transformations import apply_user_transformations, apply_moc_transformations
|
|
apply_user_transformations(ngraph_function, parse_transform(argv.transform))
|
|
apply_moc_transformations(ngraph_function)
|
|
|
|
if argv.compress_fp16:
|
|
from mo.back.offline_transformations import compress_model
|
|
compress_model(ngraph_function)
|
|
|
|
orig_model_name = os.path.normpath(os.path.join(output_dir, argv.model_name))
|
|
|
|
from openvino.offline_transformations_pybind import serialize # pylint: disable=import-error,no-name-in-module
|
|
serialize(ngraph_function, (orig_model_name + ".xml").encode('utf-8'), (orig_model_name + ".bin").encode('utf-8'))
|
|
|
|
del argv.feManager
|
|
|
|
# add meta information to IR
|
|
append_ir_info(file=orig_model_name,
|
|
meta_info=get_meta_info(argv),
|
|
mean_data=None,
|
|
input_names=None)
|
|
|
|
print('[ SUCCESS ] Generated IR version {} model.'.format(get_ir_version(argv)))
|
|
print('[ SUCCESS ] XML file: {}.xml'.format(orig_model_name))
|
|
print('[ SUCCESS ] BIN file: {}.bin'.format(orig_model_name))
|
|
return 0
|