diff --git a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api.pyx b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api.pyx index 8e9be27b31b..ccf5b834110 100644 --- a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api.pyx +++ b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api.pyx @@ -5,10 +5,14 @@ from .cimport offline_transformations_api_impl_defs as C from ..inference_engine.ie_api cimport IENetwork from libcpp cimport bool +from libcpp.string cimport string def ApplyMOCTransformations(IENetwork network, bool cf): C.ApplyMOCTransformations(network.impl, cf) +def ApplyPOTTransformations(IENetwork network, string device): + C.ApplyPOTTransformations(network.impl, device) + def ApplyLowLatencyTransformation(IENetwork network): C.ApplyLowLatencyTransformation(network.impl) diff --git a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.cpp b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.cpp index eeb19a63ac5..74b77468ae2 100644 --- a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.cpp +++ b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.cpp @@ -5,6 +5,7 @@ #include "offline_transformations_api_impl.hpp" #include +#include #include #include @@ -21,6 +22,12 @@ void InferenceEnginePython::ApplyMOCTransformations(InferenceEnginePython::IENet manager.run_passes(network.actual->getFunction()); } +void InferenceEnginePython::ApplyPOTTransformations(InferenceEnginePython::IENetwork network, std::string device) { + ngraph::pass::Manager manager; + manager.register_pass(std::move(device)); + manager.run_passes(network.actual->getFunction()); +} + void InferenceEnginePython::ApplyLowLatencyTransformation(InferenceEnginePython::IENetwork network) { ngraph::pass::Manager manager; manager.register_pass(); diff --git a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.hpp b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.hpp index 038574423a4..b56be6c08e5 100644 --- a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.hpp +++ b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl.hpp @@ -4,6 +4,8 @@ #pragma once +#include + #include "Python.h" #include "ie_api_impl.hpp" @@ -11,6 +13,8 @@ namespace InferenceEnginePython { void ApplyMOCTransformations(InferenceEnginePython::IENetwork network, bool cf); +void ApplyPOTTransformations(InferenceEnginePython::IENetwork network, std::string device); + void ApplyLowLatencyTransformation(InferenceEnginePython::IENetwork network); void ApplyPruningTransformation(InferenceEnginePython::IENetwork network); diff --git a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl_defs.pxd b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl_defs.pxd index ce8928af39e..803ccdd7e66 100644 --- a/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl_defs.pxd +++ b/inference-engine/ie_bridges/python/src/openvino/offline_transformations/offline_transformations_api_impl_defs.pxd @@ -2,11 +2,15 @@ # SPDX-License-Identifier: Apache-2.0 from libcpp cimport bool +from libcpp.string cimport string + from ..inference_engine.ie_api_impl_defs cimport IENetwork cdef extern from "offline_transformations_api_impl.hpp" namespace "InferenceEnginePython": cdef void ApplyMOCTransformations(IENetwork network, bool cf) + cdef void ApplyPOTTransformations(IENetwork network, string device) + cdef void ApplyLowLatencyTransformation(IENetwork network) cdef void ApplyPruningTransformation(IENetwork network) diff --git a/inference-engine/src/offline_transformations/include/pot_transformations.hpp b/inference-engine/src/offline_transformations/include/pot_transformations.hpp new file mode 100644 index 00000000000..ac0d9df8ae2 --- /dev/null +++ b/inference-engine/src/offline_transformations/include/pot_transformations.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include + +namespace ngraph { +namespace pass { + +class POTTransformations; + +} // namespace pass +} // namespace ngraph + +/** + * @brief This transformation is an entry point for nGraph transformations that will be + * executed inside POT. + */ + +class ngraph::pass::POTTransformations: public ngraph::pass::FunctionPass { + std::string m_device; + +public: + NGRAPH_RTTI_DECLARATION; + explicit POTTransformations(std::string device) : m_device(std::move(device)) {} + + bool run_on_function(std::shared_ptr) override; +}; diff --git a/inference-engine/src/offline_transformations/src/pot_transformations.cpp b/inference-engine/src/offline_transformations/src/pot_transformations.cpp new file mode 100644 index 00000000000..7211b42e475 --- /dev/null +++ b/inference-engine/src/offline_transformations/src/pot_transformations.cpp @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include + +#include + +#include "pot_transformations.hpp" + +NGRAPH_RTTI_DEFINITION(ngraph::pass::POTTransformations, "POTTransformations", 0); + +bool ngraph::pass::POTTransformations::run_on_function(std::shared_ptr f) { + ngraph::pass::Manager manager(get_pass_config()); + if (m_device == "CPU") { + // TODO: register CPU passes + // manager.register_pass(); + } else { + throw ngraph_error("Device name is unsupported"); + } + manager.run_passes(f); + return false; +} \ No newline at end of file