-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
600 additions
and
471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "pyopenvino/core/core.hpp" | ||
|
||
#include <ie_extension.h> | ||
#include <pybind11/stl.h> | ||
|
||
#include <openvino/runtime/core.hpp> | ||
#include <pyopenvino/core/tensor.hpp> | ||
|
||
#include "common.hpp" | ||
|
||
namespace py = pybind11; | ||
|
||
using ConfigMap = std::map<std::string, std::string>; | ||
|
||
std::string to_string(py::handle handle) { | ||
auto encodedString = PyUnicode_AsUTF8String(handle.ptr()); | ||
return PyBytes_AsString(encodedString); | ||
} | ||
|
||
void regclass_Core(py::module m) { | ||
py::class_<ov::runtime::Core, std::shared_ptr<ov::runtime::Core>> cls(m, "Core"); | ||
cls.def(py::init<const std::string&>(), py::arg("xml_config_file") = ""); | ||
|
||
cls.def("set_config", | ||
(void (ov::runtime::Core::*)(const ConfigMap&, const std::string&)) & ov::runtime::Core::set_config, | ||
py::arg("config"), | ||
py::arg("device_name") = ""); | ||
|
||
cls.def( | ||
"compile_model", | ||
(ov::runtime::ExecutableNetwork( | ||
ov::runtime::Core::*)(const std::shared_ptr<const ov::Function>&, const std::string&, const ConfigMap&)) & | ||
ov::runtime::Core::compile_model, | ||
py::arg("network"), | ||
py::arg("device_name"), | ||
py::arg("config") = py::dict()); | ||
|
||
cls.def( | ||
"add_extension", | ||
[](ov::runtime::Core& self, const std::string& extension_path) { | ||
auto extension_ptr = InferenceEngine::make_so_pointer<InferenceEngine::IExtension>(extension_path); | ||
auto extension = std::dynamic_pointer_cast<InferenceEngine::IExtension>(extension_ptr); | ||
self.add_extension(extension); | ||
}, | ||
py::arg("extension_path")); | ||
|
||
cls.def("get_versions", &ov::runtime::Core::get_versions); | ||
|
||
cls.def("read_model", | ||
(std::shared_ptr<ov::Function>(ov::runtime::Core::*)(const std::string&, const std::string&) const) & | ||
ov::runtime::Core::read_model, | ||
py::arg("model"), | ||
py::arg("weights") = ""); | ||
|
||
cls.def( | ||
"read_model", | ||
(std::shared_ptr<ov::Function>(ov::runtime::Core::*)(const std::string&, const ov::runtime::Tensor&) const) & | ||
ov::runtime::Core::read_model, | ||
py::arg("model"), | ||
py::arg("weights")); | ||
|
||
cls.def( | ||
"read_model", | ||
[](ov::runtime::Core& self, py::object model, py::object weights) { | ||
return self.read_model(py::str(model), py::str(weights)); | ||
}, | ||
py::arg("model"), | ||
py::arg("weights") = ""); | ||
|
||
cls.def( | ||
"import_model", | ||
(ov::runtime::ExecutableNetwork(ov::runtime::Core::*)(std::istream&, const std::string&, const ConfigMap&)) & | ||
ov::runtime::Core::import_model, | ||
py::arg("model_file"), | ||
py::arg("device_name"), | ||
py::arg("config") = py::none()); | ||
|
||
cls.def( | ||
"get_config", | ||
[](ov::runtime::Core& self, const std::string& device_name, const std::string& name) -> py::handle { | ||
return Common::parse_parameter(self.get_config(device_name, name)); | ||
}, | ||
py::arg("device_name"), | ||
py::arg("name")); | ||
|
||
cls.def( | ||
"get_metric", | ||
[](ov::runtime::Core& self, const std::string device_name, const std::string name) -> py::handle { | ||
return Common::parse_parameter(self.get_metric(device_name, name)); | ||
}, | ||
py::arg("device_name"), | ||
py::arg("name")); | ||
|
||
cls.def("register_plugin", &ov::runtime::Core::register_plugin, py::arg("plugin_name"), py::arg("device_name")); | ||
|
||
cls.def("register_plugins", &ov::runtime::Core::register_plugins, py::arg("xml_config_file")); | ||
|
||
cls.def("unload_plugin", &ov::runtime::Core::unload_plugin, py::arg("device_name")); | ||
|
||
cls.def( | ||
"query_model", | ||
(ov::runtime::SupportedOpsMap( | ||
ov::runtime::Core::*)(const std::shared_ptr<const ov::Function>&, const std::string&, const ConfigMap&)) & | ||
ov::runtime::Core::query_model, | ||
py::arg("model"), | ||
py::arg("device_name"), | ||
py::arg("config") = py::dict()); | ||
|
||
cls.def_property_readonly("available_devices", &ov::runtime::Core::get_available_devices); | ||
} |
File renamed without changes.
76 changes: 76 additions & 0 deletions
76
runtime/bindings/python/src/pyopenvino/core/executable_network.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "openvino/runtime/executable_network.hpp" | ||
|
||
#include <pybind11/stl.h> | ||
|
||
#include "common.hpp" | ||
#include "pyopenvino/core/containers.hpp" | ||
#include "pyopenvino/core/ie_infer_request.hpp" | ||
#include "pyopenvino/core/ie_input_info.hpp" | ||
|
||
namespace py = pybind11; | ||
|
||
void regclass_ExecutableNetwork(py::module m) { | ||
py::class_<ov::runtime::ExecutableNetwork, std::shared_ptr<ov::runtime::ExecutableNetwork>> cls( | ||
m, | ||
"ExecutableNetwork"); | ||
|
||
cls.def("create_infer_request", &ov::runtime::ExecutableNetwork::create_infer_request); | ||
|
||
// cls.def("infer_new_request", [](ov::runtime::ExecutableNetwork& self, const py::dict& inputs) { | ||
// TODO: implment after https://github.com/openvinotoolkit/openvino/pull/7962 | ||
// will be merged as a seperate ticket | ||
// }); | ||
|
||
cls.def("export_model", &ov::runtime::ExecutableNetwork::export_model, py::arg("network_model")); | ||
|
||
cls.def( | ||
"get_config", | ||
[](ov::runtime::ExecutableNetwork& self, const std::string& name) -> py::handle { | ||
return Common::parse_parameter(self.get_config(name)); | ||
}, | ||
py::arg("name")); | ||
|
||
cls.def( | ||
"get_metric", | ||
[](ov::runtime::ExecutableNetwork& self, const std::string& name) -> py::handle { | ||
return Common::parse_parameter(self.get_metric(name)); | ||
}, | ||
py::arg("name")); | ||
|
||
cls.def("get_runtime_function", &ov::runtime::ExecutableNetwork::get_runtime_function); | ||
|
||
cls.def_property_readonly("inputs", &ov::runtime::ExecutableNetwork::inputs); | ||
|
||
cls.def("input", | ||
(ov::Output<const ov::Node>(ov::runtime::ExecutableNetwork::*)() const) & | ||
ov::runtime::ExecutableNetwork::input); | ||
|
||
cls.def("input", | ||
(ov::Output<const ov::Node>(ov::runtime::ExecutableNetwork::*)(size_t) const) & | ||
ov::runtime::ExecutableNetwork::input, | ||
py::arg("i")); | ||
|
||
cls.def("input", | ||
(ov::Output<const ov::Node>(ov::runtime::ExecutableNetwork::*)(const std::string&) const) & | ||
ov::runtime::ExecutableNetwork::input, | ||
py::arg("tensor_name")); | ||
|
||
cls.def_property_readonly("outputs", &ov::runtime::ExecutableNetwork::outputs); | ||
|
||
cls.def("output", | ||
(ov::Output<const ov::Node>(ov::runtime::ExecutableNetwork::*)() const) & | ||
ov::runtime::ExecutableNetwork::output); | ||
|
||
cls.def("output", | ||
(ov::Output<const ov::Node>(ov::runtime::ExecutableNetwork::*)(size_t) const) & | ||
ov::runtime::ExecutableNetwork::output, | ||
py::arg("i")); | ||
|
||
cls.def("output", | ||
(ov::Output<const ov::Node>(ov::runtime::ExecutableNetwork::*)(const std::string&) const) & | ||
ov::runtime::ExecutableNetwork::output, | ||
py::arg("tensor_name")); | ||
} |
File renamed without changes.
160 changes: 0 additions & 160 deletions
160
runtime/bindings/python/src/pyopenvino/core/ie_core.cpp
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.