Implement TelemetryExtension and enable op statistic collection in ONNX/Paddle/TF FrontEnds (#8666)

* Moved so loader to utils

* Fixed extension tests

* Fixed tests and style

* Fixed style and tests

* Fixed ARM build

* Fix windows

* Fix ieFuncTests

* Wrap runtime exception

* Fixed tests

* Added separate new extension

* Fixed unicode extension loading

* Try to fix windows

* Fixed windows

* Fixed macro

* Fixed doc

* Fixed build

* Fixed comments

* Try to fix build

* Fixed build

* Fixed build

* Fixed shared_from_this

* Temp commit

* Changed extension

* Fixed merge conflicts

* Removed ngraph namespace from new extensions

* Fixed code style

* Added core add_extension methods and tests

* Added new tests

* Implement tile operation

* Enabled new extensions support

* Fixed build

* Fixed code style

* Try to fix windows

* Changed base extension class

* Removed redundant Ptr

* Fixed comments

* Fixed friend decl

* Fixed Windows export

* Fixed centos

* Added template add_extension method

* WIP: experiments with FE extensions, python callback in C++ code, draft of transformation, op and telemetry extensions

* Move destructor to public

* WIP: merge with core extension WIP branch

* Temporary WA for defualt ctor in VariantTemp. TODO: revert back before merging to master

* Removed BaseExtension class

* Added variadic add_extension methods

* Fixed doc and typo

* Added BaseOpDestructor

* Allow to create new extension only for new operations

* Revert tests

* Fixed comments

* Fixed comments

* WIP with various types of extensions, finalizing merge

* Fixed merge artefacts and finalized Json extensions

* TelemetryExtension initial commit

* Telemetry tests

* Add telemetry to frontends

* delete debug prints

* missprint

* Resolve review comments

* update tests

* fix tests

* Collect op statistics in InputModel for PDPD, TF; Update tests

* delete debug prints, codestyle

* fix paddle frontend

* Add event_category to TelemetryExtension ctor, update event_send calls, update tests

* Add convertion_method Temetry event to MO

* pass TelemetryExtension to ONNX frontend

* Fix default argument

* Clean up

* delete unnecessary m_telemetry members

* fix windows build

* fix win build again

* try to link frontend manager statically to ONNXFrontEnd

* use static frontend_manager in unit tests

* fix win build: split declaration and definition of TelemetryException

* Resolve review remarks

* send Telemetry events for subgraph ops in ONXX, fix unit tests

* fix build

* add missign files

* resolve review comments, fix centos

* Add blank lines

* Set correct TID for Telemetry

* resolve review commetns

Co-authored-by: Ilya Churaev <ilya.churaev@intel.com>
Co-authored-by: Lyalin, Sergey <sergey.lyalin@intel.com>
This commit is contained in:
Ivan Tikhonov
2021-12-01 09:51:00 +03:00
committed by GitHub
parent 803531ea14
commit 20bf6ca6c4
34 changed files with 584 additions and 92 deletions

View File

@@ -14,6 +14,8 @@ from _pyngraph import FrontEnd
from _pyngraph import InputModel
from _pyngraph import Place
from _pyngraph import TelemetryExtension
# exceptions
from _pyngraph import NotImplementedFailure
from _pyngraph import InitializationFailure

View File

@@ -2,27 +2,26 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/stl_bind.h>
#include "common/frontend_exceptions.hpp"
#include "frontend_manager.hpp"
#include "common/telemetry_extension.hpp"
#include "manager.hpp"
#include "pyngraph/function.hpp"
namespace py = pybind11;
using namespace ov::frontend;
void regclass_pyngraph_FrontEnd(py::module m) {
py::class_<ov::frontend::FrontEnd, std::shared_ptr<ov::frontend::FrontEnd>> fem(m,
"FrontEnd",
py::dynamic_attr(),
py::module_local());
py::class_<FrontEnd, std::shared_ptr<FrontEnd>> fem(m, "FrontEnd", py::dynamic_attr(), py::module_local());
fem.doc() = "ngraph.impl.FrontEnd wraps ngraph::frontend::FrontEnd";
fem.def(
"load",
[](ov::frontend::FrontEnd& self, const std::string& s) {
[](FrontEnd& self, const std::string& s) {
return self.load(s);
},
py::arg("path"),
@@ -40,12 +39,10 @@ void regclass_pyngraph_FrontEnd(py::module m) {
Loaded input model.
)");
fem.def(
"convert",
static_cast<std::shared_ptr<ngraph::Function> (ov::frontend::FrontEnd::*)(ov::frontend::InputModel::Ptr) const>(
&ov::frontend::FrontEnd::convert),
py::arg("model"),
R"(
fem.def("convert",
static_cast<std::shared_ptr<ngraph::Function> (FrontEnd::*)(InputModel::Ptr) const>(&FrontEnd::convert),
py::arg("model"),
R"(
Completely convert and normalize entire function, throws if it is not possible.
Parameters
@@ -60,8 +57,7 @@ void regclass_pyngraph_FrontEnd(py::module m) {
)");
fem.def("convert",
static_cast<void (ov::frontend::FrontEnd::*)(std::shared_ptr<ngraph::Function>) const>(
&ov::frontend::FrontEnd::convert),
static_cast<void (FrontEnd::*)(std::shared_ptr<ngraph::Function>) const>(&FrontEnd::convert),
py::arg("function"),
R"(
Completely convert the remaining, not converted part of a function.
@@ -78,7 +74,7 @@ void regclass_pyngraph_FrontEnd(py::module m) {
)");
fem.def("convert_partially",
&ov::frontend::FrontEnd::convert_partially,
&FrontEnd::convert_partially,
py::arg("model"),
R"(
Convert only those parts of the model that can be converted leaving others as-is.
@@ -97,7 +93,7 @@ void regclass_pyngraph_FrontEnd(py::module m) {
)");
fem.def("decode",
&ov::frontend::FrontEnd::decode,
&FrontEnd::decode,
py::arg("model"),
R"(
Convert operations with one-to-one mapping with decoding nodes.
@@ -116,7 +112,7 @@ void regclass_pyngraph_FrontEnd(py::module m) {
)");
fem.def("normalize",
&ov::frontend::FrontEnd::normalize,
&FrontEnd::normalize,
py::arg("function"),
R"(
Runs normalization passes on function that was loaded with partial conversion.
@@ -128,7 +124,7 @@ void regclass_pyngraph_FrontEnd(py::module m) {
)");
fem.def("get_name",
&ov::frontend::FrontEnd::get_name,
&FrontEnd::get_name,
R"(
Gets name of this FrontEnd. Can be used by clients
if frontend is selected automatically by FrontEndManager::load_by_model.
@@ -139,7 +135,33 @@ void regclass_pyngraph_FrontEnd(py::module m) {
Current frontend name. Empty string if not implemented.
)");
fem.def("__repr__", [](const ov::frontend::FrontEnd& self) -> std::string {
fem.def("add_extension",
static_cast<void (FrontEnd::*)(const std::shared_ptr<ov::Extension>& extension)>(&FrontEnd::add_extension));
fem.def("__repr__", [](const FrontEnd& self) -> std::string {
return "<FrontEnd '" + self.get_name() + "'>";
});
}
void regclass_pyngraph_Extension(py::module m) {
py::class_<ov::Extension, std::shared_ptr<ov::Extension>> ext(m, "Extension", py::dynamic_attr());
}
void regclass_pyngraph_TelemetryExtension(py::module m) {
{
py::class_<TelemetryExtension, std::shared_ptr<TelemetryExtension>, ov::Extension> ext(m,
"TelemetryExtension",
py::dynamic_attr());
ext.def(py::init([](const std::string& event_category,
const TelemetryExtension::event_callback& send_event,
const TelemetryExtension::error_callback& send_error,
const TelemetryExtension::error_callback& send_stack_trace) {
return std::make_shared<TelemetryExtension>(event_category, send_event, send_error, send_stack_trace);
}));
ext.def("send_event", &TelemetryExtension::send_event);
ext.def("send_error", &TelemetryExtension::send_error);
ext.def("send_stack_trace", &TelemetryExtension::send_stack_trace);
}
}

View File

@@ -9,3 +9,5 @@
namespace py = pybind11;
void regclass_pyngraph_FrontEnd(py::module m);
void regclass_pyngraph_Extension(py::module m);
void regclass_pyngraph_TelemetryExtension(py::module m);

View File

@@ -50,6 +50,8 @@ PYBIND11_MODULE(_pyngraph, m) {
regclass_pyngraph_NotImplementedFailureFrontEnd(m);
regclass_pyngraph_FrontEndManager(m);
regclass_pyngraph_FrontEnd(m);
regclass_pyngraph_Extension(m);
regclass_pyngraph_TelemetryExtension(m);
regclass_pyngraph_InputModel(m);
regclass_pyngraph_Input(m);
regclass_pyngraph_Output(m);