Renamed ov::Function to ov::Model (#9051)
* Renamed ov::Function to ov::Model * Fixed all for macos * Fixed build * Fixed build * Revert changes in GPU plugin * Fixed ngraphFunctions * Fixed all for mac * Fixed new test * Fixed if for Windows * Fixed unit tests and renamed Function in python API * Fixed code style * Fixed import * Fixed conflict * Fixed merge issues
This commit is contained in:
@@ -44,7 +44,7 @@ if sys.platform == "win32":
|
||||
|
||||
# Openvino pybind bindings and python extended classes
|
||||
from openvino.pyopenvino import Dimension
|
||||
from openvino.pyopenvino import Function
|
||||
from openvino.pyopenvino import Model
|
||||
from openvino.pyopenvino import Input
|
||||
from openvino.pyopenvino import Output
|
||||
from openvino.pyopenvino import Node
|
||||
|
||||
@@ -5,7 +5,7 @@ import numpy as np
|
||||
import copy
|
||||
from typing import Any, List, Union
|
||||
|
||||
from openvino.pyopenvino import Function
|
||||
from openvino.pyopenvino import Model
|
||||
from openvino.pyopenvino import Core as CoreBase
|
||||
from openvino.pyopenvino import ExecutableNetwork as ExecutableNetworkBase
|
||||
from openvino.pyopenvino import InferRequest as InferRequestBase
|
||||
@@ -104,9 +104,9 @@ class Core(CoreBase):
|
||||
"""Core wrapper."""
|
||||
|
||||
def compile_model(
|
||||
self, model: Union[Function, str], device_name: str, config: dict = None
|
||||
self, model: Union[Model, str], device_name: str, config: dict = None
|
||||
) -> ExecutableNetwork:
|
||||
"""Compile a model from given Function."""
|
||||
"""Compile a model from given Model."""
|
||||
return ExecutableNetwork(
|
||||
super().compile_model(model, device_name, {} if config is None else config)
|
||||
)
|
||||
|
||||
@@ -2431,7 +2431,7 @@ def reshape(
|
||||
|
||||
@unary_op
|
||||
def result(data: NodeInput, name: Optional[str] = None) -> Node:
|
||||
"""Return a node which represents an output of a graph (Function).
|
||||
"""Return a node which represents an output of a graph (Model).
|
||||
|
||||
@param data: The tensor containing the input data
|
||||
@return Result node
|
||||
|
||||
@@ -32,14 +32,13 @@ void regclass_Core(py::module m) {
|
||||
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("model"),
|
||||
py::arg("device_name"),
|
||||
py::arg("config") = py::dict());
|
||||
cls.def("compile_model",
|
||||
(ov::runtime::ExecutableNetwork(
|
||||
ov::runtime::Core::*)(const std::shared_ptr<const ov::Model>&, const std::string&, const ConfigMap&)) &
|
||||
ov::runtime::Core::compile_model,
|
||||
py::arg("model"),
|
||||
py::arg("device_name"),
|
||||
py::arg("config") = py::dict());
|
||||
|
||||
cls.def("compile_model",
|
||||
(ov::runtime::ExecutableNetwork(
|
||||
@@ -72,17 +71,16 @@ void regclass_Core(py::module m) {
|
||||
py::arg("weights") = py::bytes());
|
||||
|
||||
cls.def("read_model",
|
||||
(std::shared_ptr<ov::Function>(ov::runtime::Core::*)(const std::string&, const std::string&) const) &
|
||||
(std::shared_ptr<ov::Model>(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",
|
||||
(std::shared_ptr<ov::Model>(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",
|
||||
@@ -122,14 +120,13 @@ void regclass_Core(py::module m) {
|
||||
|
||||
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("query_model",
|
||||
(ov::runtime::SupportedOpsMap(
|
||||
ov::runtime::Core::*)(const std::shared_ptr<const ov::Model>&, const std::string&, const ConfigMap&)) &
|
||||
ov::runtime::Core::query_model,
|
||||
py::arg("model"),
|
||||
py::arg("device_name"),
|
||||
py::arg("config") = py::dict());
|
||||
|
||||
cls.def(
|
||||
"add_extension",
|
||||
|
||||
@@ -56,7 +56,7 @@ void regclass_ExecutableNetwork(py::module m) {
|
||||
},
|
||||
py::arg("name"));
|
||||
|
||||
cls.def("get_runtime_function", &ov::runtime::ExecutableNetwork::get_runtime_function);
|
||||
cls.def("get_runtime_model", &ov::runtime::ExecutableNetwork::get_runtime_model);
|
||||
|
||||
cls.def_property_readonly("inputs", &ov::runtime::ExecutableNetwork::inputs);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ void regmodule_offline_transformations(py::module m) {
|
||||
|
||||
m_offline_transformations.def(
|
||||
"apply_moc_transformations",
|
||||
[](std::shared_ptr<ov::Function> function, bool cf) {
|
||||
[](std::shared_ptr<ov::Model> function, bool cf) {
|
||||
ov::pass::Manager manager;
|
||||
manager.register_pass<ngraph::pass::MOCTransformations>(cf);
|
||||
manager.run_passes(function);
|
||||
@@ -51,7 +51,7 @@ void regmodule_offline_transformations(py::module m) {
|
||||
|
||||
m_offline_transformations.def(
|
||||
"apply_pot_transformations",
|
||||
[](std::shared_ptr<ov::Function> function, std::string device) {
|
||||
[](std::shared_ptr<ov::Model> function, std::string device) {
|
||||
ov::pass::Manager manager;
|
||||
manager.register_pass<ngraph::pass::POTTransformations>(std::move(device));
|
||||
manager.run_passes(function);
|
||||
@@ -61,7 +61,7 @@ void regmodule_offline_transformations(py::module m) {
|
||||
|
||||
m_offline_transformations.def(
|
||||
"apply_low_latency_transformation",
|
||||
[](std::shared_ptr<ov::Function> function, bool use_const_initializer = true) {
|
||||
[](std::shared_ptr<ov::Model> function, bool use_const_initializer = true) {
|
||||
ov::pass::Manager manager;
|
||||
manager.register_pass<ov::pass::LowLatency2>(use_const_initializer);
|
||||
manager.run_passes(function);
|
||||
@@ -71,7 +71,7 @@ void regmodule_offline_transformations(py::module m) {
|
||||
|
||||
m_offline_transformations.def(
|
||||
"apply_pruning_transformation",
|
||||
[](std::shared_ptr<ngraph::Function> function) {
|
||||
[](std::shared_ptr<ov::Model> function) {
|
||||
ov::pass::Manager manager;
|
||||
manager.register_pass<ngraph::pass::Pruning>();
|
||||
manager.run_passes(function);
|
||||
@@ -80,7 +80,7 @@ void regmodule_offline_transformations(py::module m) {
|
||||
|
||||
m_offline_transformations.def(
|
||||
"generate_mapping_file",
|
||||
[](std::shared_ptr<ov::Function> function, std::string path, bool extract_names) {
|
||||
[](std::shared_ptr<ov::Model> function, std::string path, bool extract_names) {
|
||||
ov::pass::Manager manager;
|
||||
manager.register_pass<ngraph::pass::GenerateMappingFile>(path, extract_names);
|
||||
manager.run_passes(function);
|
||||
@@ -91,7 +91,7 @@ void regmodule_offline_transformations(py::module m) {
|
||||
|
||||
m_offline_transformations.def(
|
||||
"apply_make_stateful_transformation",
|
||||
[](std::shared_ptr<ov::Function> function, const std::map<std::string, std::string>& param_res_names) {
|
||||
[](std::shared_ptr<ov::Model> function, const std::map<std::string, std::string>& param_res_names) {
|
||||
ngraph::pass::Manager manager;
|
||||
manager.register_pass<ov::pass::MakeStateful>(param_res_names);
|
||||
manager.run_passes(function);
|
||||
@@ -101,7 +101,7 @@ void regmodule_offline_transformations(py::module m) {
|
||||
|
||||
m_offline_transformations.def(
|
||||
"compress_model_transformation",
|
||||
[](std::shared_ptr<ov::Function> function) {
|
||||
[](std::shared_ptr<ov::Model> function) {
|
||||
ov::pass::Manager manager;
|
||||
manager.register_pass<ov::pass::MarkPrecisionSensitiveSubgraphs>();
|
||||
manager.register_pass<ov::pass::CompressFloatConstants>();
|
||||
@@ -112,7 +112,7 @@ void regmodule_offline_transformations(py::module m) {
|
||||
// todo: remove as serialize as part of passManager api will be merged
|
||||
m_offline_transformations.def(
|
||||
"serialize",
|
||||
[](std::shared_ptr<ov::Function> function,
|
||||
[](std::shared_ptr<ov::Model> function,
|
||||
const std::string& path_to_xml,
|
||||
const std::string& path_to_bin,
|
||||
const std::string& version) {
|
||||
@@ -129,7 +129,7 @@ void regmodule_offline_transformations(py::module m) {
|
||||
into provided paths.
|
||||
Parameters
|
||||
----------
|
||||
function : ov.Function
|
||||
function : ov.Model
|
||||
function which will be converted to IR representation
|
||||
xml_path : str
|
||||
path where .xml file will be saved
|
||||
@@ -150,7 +150,7 @@ void regmodule_offline_transformations(py::module m) {
|
||||
parameter_b = ov.parameter(shape, dtype=np.float32, name="B")
|
||||
parameter_c = ov.parameter(shape, dtype=np.float32, name="C")
|
||||
model = (parameter_a + parameter_b) * parameter_c
|
||||
func = Function(model, [parameter_a, parameter_b, parameter_c], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b, parameter_c], "Model")
|
||||
# IR generated with default version
|
||||
serialize(func, model_path="./serialized.xml", weights_path="./serialized.bin")
|
||||
|
||||
@@ -160,7 +160,7 @@ void regmodule_offline_transformations(py::module m) {
|
||||
parameter_b = ov.parameter(shape, dtype=np.float32, name="B")
|
||||
parameter_c = ov.parameter(shape, dtype=np.float32, name="C")
|
||||
model = (parameter_a + parameter_b) * parameter_c
|
||||
func = Function(model, [parameter_a, parameter_b, parameter_c], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b, parameter_c], "Model")
|
||||
# IR generated with default version
|
||||
serialize(func, model_path="./serialized.xml", "./serialized.bin", version="IR_V11")
|
||||
// )");
|
||||
|
||||
@@ -41,7 +41,7 @@ void regclass_frontend_FrontEnd(py::module m) {
|
||||
)");
|
||||
|
||||
fem.def("convert",
|
||||
static_cast<std::shared_ptr<ov::Function> (FrontEnd::*)(InputModel::Ptr) const>(&FrontEnd::convert),
|
||||
static_cast<std::shared_ptr<ov::Model> (FrontEnd::*)(InputModel::Ptr) const>(&FrontEnd::convert),
|
||||
py::arg("model"),
|
||||
R"(
|
||||
Completely convert and normalize entire function, throws if it is not possible.
|
||||
@@ -53,24 +53,24 @@ void regclass_frontend_FrontEnd(py::module m) {
|
||||
|
||||
Returns
|
||||
----------
|
||||
convert : Function
|
||||
convert : Model
|
||||
Fully converted nGraph function.
|
||||
)");
|
||||
|
||||
fem.def("convert",
|
||||
static_cast<void (FrontEnd::*)(std::shared_ptr<ov::Function>) const>(&FrontEnd::convert),
|
||||
static_cast<void (FrontEnd::*)(std::shared_ptr<ov::Model>) const>(&FrontEnd::convert),
|
||||
py::arg("function"),
|
||||
R"(
|
||||
Completely convert the remaining, not converted part of a function.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
function : Function
|
||||
function : Model
|
||||
Partially converted nGraph function.
|
||||
|
||||
Returns
|
||||
----------
|
||||
convert : Function
|
||||
convert : Model
|
||||
Fully converted nGraph function.
|
||||
)");
|
||||
|
||||
@@ -89,7 +89,7 @@ void regclass_frontend_FrontEnd(py::module m) {
|
||||
|
||||
Returns
|
||||
----------
|
||||
convert_partially : Function
|
||||
convert_partially : Model
|
||||
Partially converted nGraph function.
|
||||
)");
|
||||
|
||||
@@ -108,7 +108,7 @@ void regclass_frontend_FrontEnd(py::module m) {
|
||||
|
||||
Returns
|
||||
----------
|
||||
decode : Function
|
||||
decode : Model
|
||||
nGraph function after decoding.
|
||||
)");
|
||||
|
||||
@@ -120,7 +120,7 @@ void regclass_frontend_FrontEnd(py::module m) {
|
||||
|
||||
Parameters
|
||||
----------
|
||||
function : Function
|
||||
function : Model
|
||||
Partially converted nGraph function.
|
||||
)");
|
||||
|
||||
|
||||
@@ -242,13 +242,13 @@ void util::DictAttributeDeserializer::on_adapter(const std::string& name,
|
||||
}
|
||||
|
||||
void util::DictAttributeDeserializer::on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::shared_ptr<ov::Function>>& adapter) {
|
||||
ov::ValueAccessor<std::shared_ptr<ov::Model>>& adapter) {
|
||||
if (m_attributes.contains(name)) {
|
||||
if (name == "body" || name == "then_body" || name == "else_body") {
|
||||
const py::dict& body_attrs = m_attributes[name.c_str()].cast<py::dict>();
|
||||
const auto& body_outputs = as_output_vector(body_attrs["results"].cast<ov::NodeVector>());
|
||||
const auto& body_parameters = body_attrs["parameters"].cast<ov::ParameterVector>();
|
||||
auto body = std::make_shared<ov::Function>(body_outputs, body_parameters);
|
||||
auto body = std::make_shared<ov::Model>(body_outputs, body_parameters);
|
||||
adapter.set(body);
|
||||
} else {
|
||||
NGRAPH_CHECK(false, "No AttributeVisitor support for accessing attribute named: ", name);
|
||||
|
||||
@@ -4,128 +4,100 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "openvino/core/attribute_visitor.hpp"
|
||||
#include "openvino/core/function.hpp"
|
||||
#include "openvino/core/model.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
#include "openvino/op/util/variable.hpp"
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
namespace util
|
||||
{
|
||||
class DictAttributeDeserializer : public ov::AttributeVisitor
|
||||
{
|
||||
public:
|
||||
DictAttributeDeserializer(
|
||||
const py::dict& attributes,
|
||||
std::unordered_map<std::string, std::shared_ptr<ov::op::util::Variable>>& variables);
|
||||
namespace util {
|
||||
class DictAttributeDeserializer : public ov::AttributeVisitor {
|
||||
public:
|
||||
DictAttributeDeserializer(const py::dict& attributes,
|
||||
std::unordered_map<std::string, std::shared_ptr<ov::op::util::Variable>>& variables);
|
||||
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<bool>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::string>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int8_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int16_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int32_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int64_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint8_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint16_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint32_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint64_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<float>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<double>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<std::string>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<int8_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<int16_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<int32_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<int64_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<uint8_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<uint16_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<uint32_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<uint64_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<float>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<double>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<bool>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::string>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int8_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int16_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int32_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int64_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint8_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint16_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint32_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint64_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<float>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<double>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<std::string>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<int8_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<int16_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<int32_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<int64_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<uint8_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<uint16_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<uint32_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<uint64_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<float>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<double>>& adapter) override;
|
||||
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::shared_ptr<ov::Function>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::shared_ptr<ov::Model>>& adapter) override;
|
||||
|
||||
protected:
|
||||
const py::dict& m_attributes;
|
||||
std::unordered_map<std::string, std::shared_ptr<ov::op::util::Variable>>& m_variables;
|
||||
};
|
||||
protected:
|
||||
const py::dict& m_attributes;
|
||||
std::unordered_map<std::string, std::shared_ptr<ov::op::util::Variable>>& m_variables;
|
||||
};
|
||||
|
||||
class DictAttributeSerializer : public ov::AttributeVisitor
|
||||
{
|
||||
public:
|
||||
explicit DictAttributeSerializer(const std::shared_ptr<ov::Node>& node);
|
||||
class DictAttributeSerializer : public ov::AttributeVisitor {
|
||||
public:
|
||||
explicit DictAttributeSerializer(const std::shared_ptr<ov::Node>& node);
|
||||
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<bool>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::string>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int8_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int16_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int32_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int64_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint8_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint16_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint32_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint64_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<float>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<double>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<std::string>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<int8_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<int16_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<int32_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<int64_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<uint8_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<uint16_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<uint32_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<uint64_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<float>>& adapter) override;
|
||||
void on_adapter(const std::string& name,
|
||||
ov::ValueAccessor<std::vector<double>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<bool>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::string>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int8_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int16_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int32_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<int64_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint8_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint16_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint32_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<uint64_t>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<float>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<double>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<std::string>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<int8_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<int16_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<int32_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<int64_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<uint8_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<uint16_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<uint32_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<uint64_t>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<float>>& adapter) override;
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<double>>& adapter) override;
|
||||
|
||||
template <typename T>
|
||||
T get_attribute(const std::string& name)
|
||||
{
|
||||
NGRAPH_CHECK(m_attributes.contains(name),
|
||||
"Couldn't find attribute \"",
|
||||
name,
|
||||
"\" in serialized node attribute dictionary.");
|
||||
return m_attributes[name.c_str()].cast<T>();
|
||||
}
|
||||
template <typename T>
|
||||
T get_attribute(const std::string& name) {
|
||||
NGRAPH_CHECK(m_attributes.contains(name),
|
||||
"Couldn't find attribute \"",
|
||||
name,
|
||||
"\" in serialized node attribute dictionary.");
|
||||
return m_attributes[name.c_str()].cast<T>();
|
||||
}
|
||||
|
||||
py::dict get_attributes() const { return m_attributes; }
|
||||
py::dict get_attributes() const {
|
||||
return m_attributes;
|
||||
}
|
||||
|
||||
protected:
|
||||
py::dict m_attributes;
|
||||
};
|
||||
} // namespace util
|
||||
protected:
|
||||
py::dict m_attributes;
|
||||
};
|
||||
} // namespace util
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "openvino/core/function.hpp" // ov::Function
|
||||
#include "pyopenvino/graph/function.hpp"
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "openvino/core/model.hpp" // ov::Model
|
||||
#include "openvino/core/partial_shape.hpp"
|
||||
#include "openvino/op/parameter.hpp" // ov::op::v0::Parameter
|
||||
#include "openvino/op/sink.hpp"
|
||||
#include "pyopenvino/core/tensor.hpp"
|
||||
#include "pyopenvino/graph/function.hpp"
|
||||
#include "pyopenvino/graph/ops/result.hpp"
|
||||
#include "pyopenvino/graph/ops/util/variable.hpp"
|
||||
#include "pyopenvino/graph/rt_map.hpp"
|
||||
@@ -44,9 +44,9 @@ ov::SinkVector cast_to_sink_vector(const std::vector<std::shared_ptr<ov::Node>>&
|
||||
return sinks;
|
||||
}
|
||||
|
||||
void regclass_graph_Function(py::module m) {
|
||||
py::class_<ov::Function, std::shared_ptr<ov::Function>> function(m, "Function", py::module_local());
|
||||
function.doc() = "openvino.runtime.Function wraps ov::Function";
|
||||
void regclass_graph_Model(py::module m) {
|
||||
py::class_<ov::Model, std::shared_ptr<ov::Model>> function(m, "Model", py::module_local());
|
||||
function.doc() = "openvino.runtime.Model wraps ov::Model";
|
||||
|
||||
function.def(py::init([](const ov::ResultVector& res,
|
||||
const std::vector<std::shared_ptr<ov::Node>>& nodes,
|
||||
@@ -54,14 +54,14 @@ void regclass_graph_Function(py::module m) {
|
||||
const std::string& name) {
|
||||
set_tensor_names(params);
|
||||
const auto sinks = cast_to_sink_vector(nodes);
|
||||
return std::make_shared<ov::Function>(res, sinks, params, name);
|
||||
return std::make_shared<ov::Model>(res, sinks, params, name);
|
||||
}),
|
||||
py::arg("results"),
|
||||
py::arg("sinks"),
|
||||
py::arg("parameters"),
|
||||
py::arg("name"),
|
||||
R"(
|
||||
Create user-defined Function which is a representation of a model.
|
||||
Create user-defined Model which is a representation of a model.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -82,13 +82,13 @@ void regclass_graph_Function(py::module m) {
|
||||
const ov::ParameterVector& parameters,
|
||||
const std::string& name) {
|
||||
set_tensor_names(parameters);
|
||||
return std::make_shared<ov::Function>(results, parameters, name);
|
||||
return std::make_shared<ov::Model>(results, parameters, name);
|
||||
}),
|
||||
py::arg("results"),
|
||||
py::arg("parameters"),
|
||||
py::arg("name") = "",
|
||||
R"(
|
||||
Create user-defined Function which is a representation of a model.
|
||||
Create user-defined Model which is a representation of a model.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -106,13 +106,13 @@ void regclass_graph_Function(py::module m) {
|
||||
const ov::ParameterVector& parameters,
|
||||
const std::string& name) {
|
||||
set_tensor_names(parameters);
|
||||
return std::make_shared<ov::Function>(result, parameters, name);
|
||||
return std::make_shared<ov::Model>(result, parameters, name);
|
||||
}),
|
||||
py::arg("result"),
|
||||
py::arg("parameters"),
|
||||
py::arg("name") = "",
|
||||
R"(
|
||||
Create user-defined Function which is a representation of a model.
|
||||
Create user-defined Model which is a representation of a model.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -129,13 +129,13 @@ void regclass_graph_Function(py::module m) {
|
||||
function.def(
|
||||
py::init([](const ov::OutputVector& results, const ov::ParameterVector& parameters, const std::string& name) {
|
||||
set_tensor_names(parameters);
|
||||
return std::make_shared<ov::Function>(results, parameters, name);
|
||||
return std::make_shared<ov::Model>(results, parameters, name);
|
||||
}),
|
||||
py::arg("results"),
|
||||
py::arg("parameters"),
|
||||
py::arg("name") = "",
|
||||
R"(
|
||||
Create user-defined Function which is a representation of a model
|
||||
Create user-defined Model which is a representation of a model
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -155,14 +155,14 @@ void regclass_graph_Function(py::module m) {
|
||||
const std::string& name) {
|
||||
set_tensor_names(parameters);
|
||||
const auto sinks = cast_to_sink_vector(nodes);
|
||||
return std::make_shared<ov::Function>(results, sinks, parameters, name);
|
||||
return std::make_shared<ov::Model>(results, sinks, parameters, name);
|
||||
}),
|
||||
py::arg("results"),
|
||||
py::arg("sinks"),
|
||||
py::arg("parameters"),
|
||||
py::arg("name") = "",
|
||||
R"(
|
||||
Create user-defined Function which is a representation of a model
|
||||
Create user-defined Model which is a representation of a model
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -185,7 +185,7 @@ void regclass_graph_Function(py::module m) {
|
||||
const std::string& name) {
|
||||
set_tensor_names(parameters);
|
||||
const auto sinks = cast_to_sink_vector(nodes);
|
||||
return std::make_shared<ov::Function>(results, sinks, parameters, variables, name);
|
||||
return std::make_shared<ov::Model>(results, sinks, parameters, variables, name);
|
||||
}),
|
||||
py::arg("results"),
|
||||
py::arg("sinks"),
|
||||
@@ -193,7 +193,7 @@ void regclass_graph_Function(py::module m) {
|
||||
py::arg("variables"),
|
||||
py::arg("name") = "",
|
||||
R"(
|
||||
Create user-defined Function which is a representation of a model
|
||||
Create user-defined Model which is a representation of a model
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -220,7 +220,7 @@ void regclass_graph_Function(py::module m) {
|
||||
const std::string& name) {
|
||||
set_tensor_names(parameters);
|
||||
const auto sinks = cast_to_sink_vector(nodes);
|
||||
return std::make_shared<ov::Function>(results, sinks, parameters, variables, name);
|
||||
return std::make_shared<ov::Model>(results, sinks, parameters, variables, name);
|
||||
}),
|
||||
py::arg("results"),
|
||||
py::arg("sinks"),
|
||||
@@ -228,7 +228,7 @@ void regclass_graph_Function(py::module m) {
|
||||
py::arg("variables"),
|
||||
py::arg("name") = "",
|
||||
R"(
|
||||
Create user-defined Function which is a representation of a model
|
||||
Create user-defined Model which is a representation of a model
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -253,14 +253,14 @@ void regclass_graph_Function(py::module m) {
|
||||
const ov::op::util::VariableVector& variables,
|
||||
const std::string& name) {
|
||||
set_tensor_names(parameters);
|
||||
return std::make_shared<ov::Function>(results, parameters, variables, name);
|
||||
return std::make_shared<ov::Model>(results, parameters, variables, name);
|
||||
}),
|
||||
py::arg("results"),
|
||||
py::arg("parameters"),
|
||||
py::arg("variables"),
|
||||
py::arg("name") = "",
|
||||
R"(
|
||||
Create user-defined Function which is a representation of a model
|
||||
Create user-defined Model which is a representation of a model
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -282,14 +282,14 @@ void regclass_graph_Function(py::module m) {
|
||||
const ov::op::util::VariableVector& variables,
|
||||
const std::string& name) {
|
||||
set_tensor_names(parameters);
|
||||
return std::make_shared<ov::Function>(results, parameters, variables, name);
|
||||
return std::make_shared<ov::Model>(results, parameters, variables, name);
|
||||
}),
|
||||
py::arg("results"),
|
||||
py::arg("parameters"),
|
||||
py::arg("variables"),
|
||||
py::arg("name") = "",
|
||||
R"(
|
||||
Create user-defined Function which is a representation of a model
|
||||
Create user-defined Model which is a representation of a model
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -306,11 +306,11 @@ void regclass_graph_Function(py::module m) {
|
||||
String to set as function's friendly name.
|
||||
)");
|
||||
|
||||
function.def("validate_nodes_and_infer_types", &ov::Function::validate_nodes_and_infer_types);
|
||||
function.def("validate_nodes_and_infer_types", &ov::Model::validate_nodes_and_infer_types);
|
||||
|
||||
function.def(
|
||||
"reshape",
|
||||
[](ov::Function& self, const std::map<std::string, ov::PartialShape>& partial_shapes) {
|
||||
[](ov::Model& self, const std::map<std::string, ov::PartialShape>& partial_shapes) {
|
||||
self.reshape(partial_shapes);
|
||||
},
|
||||
py::arg("partial_shapes"),
|
||||
@@ -327,7 +327,7 @@ void regclass_graph_Function(py::module m) {
|
||||
|
||||
function.def(
|
||||
"reshape",
|
||||
[](ov::Function& self, const std::map<ov::Output<ov::Node>, ov::PartialShape>& partial_shapes) {
|
||||
[](ov::Model& self, const std::map<ov::Output<ov::Node>, ov::PartialShape>& partial_shapes) {
|
||||
self.reshape(partial_shapes);
|
||||
},
|
||||
py::arg("partial_shapes"),
|
||||
@@ -343,7 +343,7 @@ void regclass_graph_Function(py::module m) {
|
||||
)");
|
||||
|
||||
function.def("get_output_size",
|
||||
&ov::Function::get_output_size,
|
||||
&ov::Model::get_output_size,
|
||||
R"(
|
||||
Return the number of outputs for the function.
|
||||
|
||||
@@ -353,7 +353,7 @@ void regclass_graph_Function(py::module m) {
|
||||
Number of outputs.
|
||||
)");
|
||||
function.def("get_ops",
|
||||
&ov::Function::get_ops,
|
||||
&ov::Model::get_ops,
|
||||
R"(
|
||||
Return ops used in the function.
|
||||
|
||||
@@ -363,7 +363,7 @@ void regclass_graph_Function(py::module m) {
|
||||
List of Nodes representing ops used in function.
|
||||
)");
|
||||
function.def("get_ordered_ops",
|
||||
&ov::Function::get_ordered_ops,
|
||||
&ov::Model::get_ordered_ops,
|
||||
R"(
|
||||
Return ops used in the function in topological order.
|
||||
|
||||
@@ -373,7 +373,7 @@ void regclass_graph_Function(py::module m) {
|
||||
List of sorted Nodes representing ops used in function.
|
||||
)");
|
||||
function.def("get_output_op",
|
||||
&ov::Function::get_output_op,
|
||||
&ov::Model::get_output_op,
|
||||
py::arg("i"),
|
||||
R"(
|
||||
Return the op that generates output i
|
||||
@@ -389,7 +389,7 @@ void regclass_graph_Function(py::module m) {
|
||||
Node object that generates output i
|
||||
)");
|
||||
function.def("get_output_element_type",
|
||||
&ov::Function::get_output_element_type,
|
||||
&ov::Model::get_output_element_type,
|
||||
py::arg("i"),
|
||||
R"(
|
||||
Return the element type of output i
|
||||
@@ -405,7 +405,7 @@ void regclass_graph_Function(py::module m) {
|
||||
Type object of output i
|
||||
)");
|
||||
function.def("get_output_shape",
|
||||
&ov::Function::get_output_shape,
|
||||
&ov::Model::get_output_shape,
|
||||
py::arg("i"),
|
||||
R"(
|
||||
Return the shape of element i
|
||||
@@ -421,7 +421,7 @@ void regclass_graph_Function(py::module m) {
|
||||
Shape object of element i
|
||||
)");
|
||||
function.def("get_output_partial_shape",
|
||||
&ov::Function::get_output_partial_shape,
|
||||
&ov::Model::get_output_partial_shape,
|
||||
py::arg("i"),
|
||||
R"(
|
||||
Return the partial shape of element i
|
||||
@@ -437,7 +437,7 @@ void regclass_graph_Function(py::module m) {
|
||||
PartialShape object of element i
|
||||
)");
|
||||
function.def("get_parameters",
|
||||
&ov::Function::get_parameters,
|
||||
&ov::Model::get_parameters,
|
||||
R"(
|
||||
Return the function parameters.
|
||||
|
||||
@@ -447,7 +447,7 @@ void regclass_graph_Function(py::module m) {
|
||||
ParameterVector containing function parameters.
|
||||
)");
|
||||
function.def("get_results",
|
||||
&ov::Function::get_results,
|
||||
&ov::Model::get_results,
|
||||
R"(
|
||||
Return a list of function outputs.
|
||||
|
||||
@@ -457,7 +457,7 @@ void regclass_graph_Function(py::module m) {
|
||||
ResultVector containing function parameters.
|
||||
)");
|
||||
function.def("get_result",
|
||||
&ov::Function::get_result,
|
||||
&ov::Model::get_result,
|
||||
R"(
|
||||
Return single result.
|
||||
|
||||
@@ -467,7 +467,7 @@ void regclass_graph_Function(py::module m) {
|
||||
Node object representing result.
|
||||
)");
|
||||
function.def("get_result_index",
|
||||
(int64_t(ov::Function::*)(const ov::Output<ov::Node>&) const) & ov::Function::get_result_index,
|
||||
(int64_t(ov::Model::*)(const ov::Output<ov::Node>&) const) & ov::Model::get_result_index,
|
||||
py::arg("value"),
|
||||
R"(
|
||||
Return index of result.
|
||||
@@ -485,7 +485,7 @@ void regclass_graph_Function(py::module m) {
|
||||
Index for value referencing it.
|
||||
)");
|
||||
function.def("get_result_index",
|
||||
(int64_t(ov::Function::*)(const ov::Output<const ov::Node>&) const) & ov::Function::get_result_index,
|
||||
(int64_t(ov::Model::*)(const ov::Output<const ov::Node>&) const) & ov::Model::get_result_index,
|
||||
py::arg("value"),
|
||||
R"(
|
||||
Return index of result.
|
||||
@@ -504,7 +504,7 @@ void regclass_graph_Function(py::module m) {
|
||||
)");
|
||||
|
||||
function.def("get_name",
|
||||
&ov::Function::get_name,
|
||||
&ov::Model::get_name,
|
||||
R"(
|
||||
Get the unique name of the function.
|
||||
|
||||
@@ -514,7 +514,7 @@ void regclass_graph_Function(py::module m) {
|
||||
String with a name of the function.
|
||||
)");
|
||||
function.def("get_friendly_name",
|
||||
&ov::Function::get_friendly_name,
|
||||
&ov::Model::get_friendly_name,
|
||||
R"(
|
||||
Gets the friendly name for a function. If no
|
||||
friendly name has been set via set_friendly_name
|
||||
@@ -526,7 +526,7 @@ void regclass_graph_Function(py::module m) {
|
||||
String with a friendly name of the function.
|
||||
)");
|
||||
function.def("set_friendly_name",
|
||||
&ov::Function::set_friendly_name,
|
||||
&ov::Model::set_friendly_name,
|
||||
py::arg("name"),
|
||||
R"(
|
||||
Sets a friendly name for a function. This does
|
||||
@@ -540,7 +540,7 @@ void regclass_graph_Function(py::module m) {
|
||||
String to set as the friendly name.
|
||||
)");
|
||||
function.def("is_dynamic",
|
||||
&ov::Function::is_dynamic,
|
||||
&ov::Model::is_dynamic,
|
||||
R"(
|
||||
Returns true if any of the op's defined in the function
|
||||
contains partial shape.
|
||||
@@ -549,45 +549,41 @@ void regclass_graph_Function(py::module m) {
|
||||
----------
|
||||
is_dynamic : bool
|
||||
)");
|
||||
function.def("input", (ov::Output<ov::Node>(ov::Function::*)()) & ov::Function::input);
|
||||
function.def("input", (ov::Output<ov::Node>(ov::Model::*)()) & ov::Model::input);
|
||||
|
||||
function.def("input", (ov::Output<ov::Node>(ov::Function::*)(size_t)) & ov::Function::input, py::arg("i"));
|
||||
function.def("input", (ov::Output<ov::Node>(ov::Model::*)(size_t)) & ov::Model::input, py::arg("i"));
|
||||
|
||||
function.def("input",
|
||||
(ov::Output<ov::Node>(ov::Function::*)(const std::string&)) & ov::Function::input,
|
||||
(ov::Output<ov::Node>(ov::Model::*)(const std::string&)) & ov::Model::input,
|
||||
py::arg("tensor_name"));
|
||||
|
||||
function.def("input", (ov::Output<const ov::Node>(ov::Function::*)() const) & ov::Function::input);
|
||||
function.def("input", (ov::Output<const ov::Node>(ov::Model::*)() const) & ov::Model::input);
|
||||
|
||||
function.def("input", (ov::Output<const ov::Node>(ov::Model::*)(size_t) const) & ov::Model::input, py::arg("i"));
|
||||
|
||||
function.def("input",
|
||||
(ov::Output<const ov::Node>(ov::Function::*)(size_t) const) & ov::Function::input,
|
||||
py::arg("i"));
|
||||
|
||||
function.def("input",
|
||||
(ov::Output<const ov::Node>(ov::Function::*)(const std::string&) const) & ov::Function::input,
|
||||
(ov::Output<const ov::Node>(ov::Model::*)(const std::string&) const) & ov::Model::input,
|
||||
py::arg("tensor_name"));
|
||||
|
||||
function.def("output", (ov::Output<ov::Node>(ov::Function::*)()) & ov::Function::output);
|
||||
function.def("output", (ov::Output<ov::Node>(ov::Model::*)()) & ov::Model::output);
|
||||
|
||||
function.def("output", (ov::Output<ov::Node>(ov::Function::*)(size_t)) & ov::Function::output, py::arg("i"));
|
||||
function.def("output", (ov::Output<ov::Node>(ov::Model::*)(size_t)) & ov::Model::output, py::arg("i"));
|
||||
|
||||
function.def("output",
|
||||
(ov::Output<ov::Node>(ov::Function::*)(const std::string&)) & ov::Function::output,
|
||||
(ov::Output<ov::Node>(ov::Model::*)(const std::string&)) & ov::Model::output,
|
||||
py::arg("tensor_name"));
|
||||
|
||||
function.def("output", (ov::Output<const ov::Node>(ov::Function::*)() const) & ov::Function::output);
|
||||
function.def("output", (ov::Output<const ov::Node>(ov::Model::*)() const) & ov::Model::output);
|
||||
|
||||
function.def("output", (ov::Output<const ov::Node>(ov::Model::*)(size_t) const) & ov::Model::output, py::arg("i"));
|
||||
|
||||
function.def("output",
|
||||
(ov::Output<const ov::Node>(ov::Function::*)(size_t) const) & ov::Function::output,
|
||||
py::arg("i"));
|
||||
|
||||
function.def("output",
|
||||
(ov::Output<const ov::Node>(ov::Function::*)(const std::string&) const) & ov::Function::output,
|
||||
(ov::Output<const ov::Node>(ov::Model::*)(const std::string&) const) & ov::Model::output,
|
||||
py::arg("tensor_name"));
|
||||
|
||||
function.def(
|
||||
"add_outputs",
|
||||
[](ov::Function& self, py::handle& outputs) {
|
||||
[](ov::Model& self, py::handle& outputs) {
|
||||
int i = 0;
|
||||
std::vector<ov::Output<ov::Node>> new_outputs;
|
||||
py::list _outputs;
|
||||
@@ -626,7 +622,7 @@ void regclass_graph_Function(py::module m) {
|
||||
py::arg("outputs"));
|
||||
|
||||
function.def("replace_parameter",
|
||||
&ov::Function::replace_parameter,
|
||||
&ov::Model::replace_parameter,
|
||||
py::arg("parameter_index"),
|
||||
py::arg("parameter"),
|
||||
R"(
|
||||
@@ -643,11 +639,11 @@ void regclass_graph_Function(py::module m) {
|
||||
The parameter to substitute for the `parameter_index`th parameter.
|
||||
)");
|
||||
|
||||
function.def("get_parameter_index",
|
||||
(int64_t(ov::Function::*)(const std::shared_ptr<ov::op::v0::Parameter>&) const) &
|
||||
ov::Function::get_parameter_index,
|
||||
py::arg("parameter"),
|
||||
R"(
|
||||
function.def(
|
||||
"get_parameter_index",
|
||||
(int64_t(ov::Model::*)(const std::shared_ptr<ov::op::v0::Parameter>&) const) & ov::Model::get_parameter_index,
|
||||
py::arg("parameter"),
|
||||
R"(
|
||||
Return the index position of `parameter`.
|
||||
|
||||
Return -1 if parameter not matched.
|
||||
@@ -664,7 +660,7 @@ void regclass_graph_Function(py::module m) {
|
||||
|
||||
function.def(
|
||||
"evaluate",
|
||||
[](ov::Function& self,
|
||||
[](ov::Model& self,
|
||||
ov::runtime::TensorVector& output_tensors,
|
||||
const ov::runtime::TensorVector& input_tensors,
|
||||
PyRTMap evaluation_context) -> bool {
|
||||
@@ -691,7 +687,7 @@ void regclass_graph_Function(py::module m) {
|
||||
evaluate : bool
|
||||
|
||||
)");
|
||||
function.def("__repr__", [](const ov::Function& self) {
|
||||
function.def("__repr__", [](const ov::Model& self) {
|
||||
std::string class_name = py::cast(self).get_type().attr("__name__").cast<std::string>();
|
||||
std::stringstream shapes_ss;
|
||||
for (size_t i = 0; i < self.get_output_size(); ++i) {
|
||||
@@ -708,23 +704,23 @@ void regclass_graph_Function(py::module m) {
|
||||
// extract the pointer stored in the PyCapsule under the name CAPSULE_NAME
|
||||
auto* capsule_ptr = PyCapsule_GetPointer(pybind_capsule_ptr, CAPSULE_NAME);
|
||||
|
||||
auto* ngraph_function = static_cast<std::shared_ptr<ov::Function>*>(capsule_ptr);
|
||||
auto* ngraph_function = static_cast<std::shared_ptr<ov::Model>*>(capsule_ptr);
|
||||
if (ngraph_function && *ngraph_function) {
|
||||
return *ngraph_function;
|
||||
} else {
|
||||
throw std::runtime_error("The provided capsule does not contain an ov::Function");
|
||||
throw std::runtime_error("The provided capsule does not contain an ov::Model");
|
||||
}
|
||||
});
|
||||
function.def_static("to_capsule", [](std::shared_ptr<ov::Function>& ngraph_function) {
|
||||
function.def_static("to_capsule", [](std::shared_ptr<ov::Model>& ngraph_function) {
|
||||
// create a shared pointer on the heap before putting it in the capsule
|
||||
// this secures the lifetime of the object transferred by the capsule
|
||||
auto* sp_copy = new std::shared_ptr<ov::Function>(ngraph_function);
|
||||
auto* sp_copy = new std::shared_ptr<ov::Model>(ngraph_function);
|
||||
|
||||
// a destructor callback that will delete the heap allocated shared_ptr
|
||||
// when the capsule is destructed
|
||||
auto sp_deleter = [](PyObject* capsule) {
|
||||
auto* capsule_ptr = PyCapsule_GetPointer(capsule, CAPSULE_NAME);
|
||||
auto* function_sp = static_cast<std::shared_ptr<ov::Function>*>(capsule_ptr);
|
||||
auto* function_sp = static_cast<std::shared_ptr<ov::Model>*>(capsule_ptr);
|
||||
if (function_sp) {
|
||||
delete function_sp;
|
||||
}
|
||||
@@ -736,16 +732,13 @@ void regclass_graph_Function(py::module m) {
|
||||
return pybind_capsule;
|
||||
});
|
||||
|
||||
function.def_property_readonly("inputs", (std::vector<ov::Output<ov::Node>>(ov::Model::*)()) & ov::Model::inputs);
|
||||
function.def_property_readonly("inputs",
|
||||
(std::vector<ov::Output<ov::Node>>(ov::Function::*)()) & ov::Function::inputs);
|
||||
function.def_property_readonly(
|
||||
"inputs",
|
||||
(std::vector<ov::Output<const ov::Node>>(ov::Function::*)() const) & ov::Function::inputs);
|
||||
function.def_property_readonly("outputs",
|
||||
(std::vector<ov::Output<ov::Node>>(ov::Function::*)()) & ov::Function::outputs);
|
||||
(std::vector<ov::Output<const ov::Node>>(ov::Model::*)() const) & ov::Model::inputs);
|
||||
function.def_property_readonly("outputs", (std::vector<ov::Output<ov::Node>>(ov::Model::*)()) & ov::Model::outputs);
|
||||
function.def_property_readonly(
|
||||
"outputs",
|
||||
(std::vector<ov::Output<const ov::Node>>(ov::Function::*)() const) & ov::Function::outputs);
|
||||
function.def_property_readonly("name", &ov::Function::get_name);
|
||||
function.def_property("friendly_name", &ov::Function::get_friendly_name, &ov::Function::set_friendly_name);
|
||||
(std::vector<ov::Output<const ov::Node>>(ov::Model::*)() const) & ov::Model::outputs);
|
||||
function.def_property_readonly("name", &ov::Model::get_name);
|
||||
function.def_property("friendly_name", &ov::Model::get_friendly_name, &ov::Model::set_friendly_name);
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
void regclass_graph_Function(py::module m);
|
||||
void regclass_graph_Model(py::module m);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "openvino/core/function.hpp"
|
||||
#include "openvino/core/model.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
#include "openvino/core/preprocess/pre_post_process.hpp"
|
||||
#include "pyopenvino/core/common.hpp"
|
||||
@@ -390,7 +390,7 @@ void regclass_graph_PrePostProcessor(py::module m) {
|
||||
"PrePostProcessor");
|
||||
proc.doc() = "openvino.runtime.preprocess.PrePostProcessor wraps ov::preprocess::PrePostProcessor";
|
||||
|
||||
proc.def(py::init<const std::shared_ptr<ov::Function>&>());
|
||||
proc.def(py::init<const std::shared_ptr<ov::Model>&>());
|
||||
|
||||
proc.def("input", [](ov::preprocess::PrePostProcessor& me) {
|
||||
return &me.input();
|
||||
|
||||
@@ -103,7 +103,7 @@ PYBIND11_MODULE(pyopenvino, m) {
|
||||
py::module m_preprocess =
|
||||
m.def_submodule("preprocess", "Package openvino.runtime.preprocess that wraps ov::preprocess");
|
||||
regclass_graph_PrePostProcessor(m_preprocess);
|
||||
regclass_graph_Function(m);
|
||||
regclass_graph_Model(m);
|
||||
regmodule_graph_passes(m);
|
||||
regmodule_graph_util(m);
|
||||
regmodule_graph_layout_helpers(m);
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace py = pybind11;
|
||||
PYBIND11_MODULE(test_utils_api, m) {
|
||||
m.def(
|
||||
"compare_functions",
|
||||
[](const ov::Function& lhs, const ov::Function& rhs) {
|
||||
const auto lhs_ptr = std::const_pointer_cast<ov::Function>(lhs.shared_from_this());
|
||||
const auto rhs_ptr = std::const_pointer_cast<ov::Function>(rhs.shared_from_this());
|
||||
[](const ov::Model& lhs, const ov::Model& rhs) {
|
||||
const auto lhs_ptr = std::const_pointer_cast<ov::Model>(lhs.shared_from_this());
|
||||
const auto rhs_ptr = std::const_pointer_cast<ov::Model>(rhs.shared_from_this());
|
||||
|
||||
const auto fc = FunctionsComparator::with_default()
|
||||
.enable(FunctionsComparator::ATTRIBUTES)
|
||||
|
||||
@@ -112,7 +112,7 @@ xfail_issue_39662 = xfail_test(reason="RuntimeError: 'ScatterElementsUpdate' lay
|
||||
xfail_issue_37973 = xfail_test(reason="TF Inception V2 - AssertionError: zoo models results mismatch")
|
||||
xfail_issue_47430 = xfail_test(reason="FCN ResNet models - AssertionError: zoo models results mismatch")
|
||||
xfail_issue_47495 = xfail_test(reason="BertSquad-10 from MSFT - AssertionError: zoo models results mismatch")
|
||||
xfail_issue_49207 = xfail_test(reason="Function references undeclared parameters")
|
||||
xfail_issue_49207 = xfail_test(reason="Model references undeclared parameters")
|
||||
xfail_issue_48145 = xfail_test(reason="BertSquad-8 - AssertionError: Items are not equal: ACTUAL: 4 "
|
||||
"DESIRED: 3")
|
||||
xfail_issue_48190 = xfail_test(reason="RobertaBase-11 - AssertionError: Items are not equal: "
|
||||
|
||||
@@ -631,26 +631,26 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::Function> convert(InputModel::Ptr model) const override {
|
||||
std::shared_ptr<ov::Model> convert(InputModel::Ptr model) const override {
|
||||
m_stat.m_convert_model++;
|
||||
return std::make_shared<ov::Function>(ov::NodeVector{}, ov::ParameterVector{});
|
||||
return std::make_shared<ov::Model>(ov::NodeVector{}, ov::ParameterVector{});
|
||||
}
|
||||
|
||||
void convert(std::shared_ptr<ov::Function> func) const override {
|
||||
void convert(std::shared_ptr<ov::Model> func) const override {
|
||||
m_stat.m_convert++;
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::Function> convert_partially(InputModel::Ptr model) const override {
|
||||
std::shared_ptr<ov::Model> convert_partially(InputModel::Ptr model) const override {
|
||||
m_stat.m_convert_partially++;
|
||||
return std::make_shared<ov::Function>(ov::NodeVector{}, ov::ParameterVector{});
|
||||
return std::make_shared<ov::Model>(ov::NodeVector{}, ov::ParameterVector{});
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::Function> decode(InputModel::Ptr model) const override {
|
||||
std::shared_ptr<ov::Model> decode(InputModel::Ptr model) const override {
|
||||
m_stat.m_decode++;
|
||||
return std::make_shared<ov::Function>(ov::NodeVector{}, ov::ParameterVector{});
|
||||
return std::make_shared<ov::Model>(ov::NodeVector{}, ov::ParameterVector{});
|
||||
}
|
||||
|
||||
void normalize(std::shared_ptr<ov::Function> function) const override {
|
||||
void normalize(std::shared_ptr<ov::Model> function) const override {
|
||||
m_stat.m_normalize++;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import numpy as np
|
||||
from openvino.runtime import Core
|
||||
|
||||
from openvino.runtime.exceptions import UserInputError
|
||||
from openvino.runtime import Function, Node, PartialShape, Type
|
||||
from openvino.runtime import Model, Node, PartialShape, Type
|
||||
from openvino.runtime.utils.types import NumericData, get_shape, get_dtype
|
||||
|
||||
import tests
|
||||
@@ -50,17 +50,17 @@ class Runtime(object):
|
||||
def __repr__(self) -> str:
|
||||
return "<Runtime: Backend='{}'>".format(self.backend_name)
|
||||
|
||||
def computation(self, node_or_function: Union[Node, Function], *inputs: Node) -> "Computation":
|
||||
def computation(self, node_or_function: Union[Node, Model], *inputs: Node) -> "Computation":
|
||||
"""Return a callable Computation object."""
|
||||
if isinstance(node_or_function, Node):
|
||||
ng_function = Function(node_or_function, inputs, node_or_function.name)
|
||||
ng_function = Model(node_or_function, inputs, node_or_function.name)
|
||||
return Computation(self, ng_function)
|
||||
elif isinstance(node_or_function, Function):
|
||||
elif isinstance(node_or_function, Model):
|
||||
return Computation(self, node_or_function)
|
||||
else:
|
||||
raise TypeError(
|
||||
"Runtime.computation must be called with an nGraph Function object "
|
||||
"or an nGraph node object an optionally Parameter node objects. "
|
||||
"Runtime.computation must be called with an OpenVINO Model object "
|
||||
"or an OpenVINO node object an optionally Parameter node objects. "
|
||||
"Called with: %s",
|
||||
node_or_function,
|
||||
)
|
||||
@@ -69,7 +69,7 @@ class Runtime(object):
|
||||
class Computation(object):
|
||||
"""nGraph callable computation object."""
|
||||
|
||||
def __init__(self, runtime: Runtime, ng_function: Function) -> None:
|
||||
def __init__(self, runtime: Runtime, ng_function: Model) -> None:
|
||||
self.runtime = runtime
|
||||
self.function = ng_function
|
||||
self.parameters = ng_function.get_parameters()
|
||||
|
||||
@@ -8,7 +8,7 @@ from sys import platform
|
||||
from pathlib import Path
|
||||
|
||||
import openvino.runtime.opset8 as ov
|
||||
from openvino.runtime import Function, Core, ExecutableNetwork, Tensor, tensor_from_file, compile_model
|
||||
from openvino.runtime import Model, Core, ExecutableNetwork, Tensor, tensor_from_file, compile_model
|
||||
|
||||
from ..conftest import model_path, model_onnx_path, plugins_path, read_image
|
||||
|
||||
@@ -40,7 +40,7 @@ def test_core_class():
|
||||
input_shape = [1, 3, 4, 4]
|
||||
param = ov.parameter(input_shape, np.float32, name="parameter")
|
||||
relu = ov.relu(param, name="relu")
|
||||
func = Function([relu], [param], "test")
|
||||
func = Model([relu], [param], "test")
|
||||
func.get_ordered_ops()[2].friendly_name = "friendly"
|
||||
|
||||
core = Core()
|
||||
@@ -66,10 +66,10 @@ def test_compile_model(device):
|
||||
def test_read_model_from_ir():
|
||||
core = Core()
|
||||
func = core.read_model(model=test_net_xml, weights=test_net_bin)
|
||||
assert isinstance(func, Function)
|
||||
assert isinstance(func, Model)
|
||||
|
||||
func = core.read_model(model=test_net_xml)
|
||||
assert isinstance(func, Function)
|
||||
assert isinstance(func, Model)
|
||||
|
||||
|
||||
def test_read_model_from_tensor():
|
||||
@@ -77,31 +77,31 @@ def test_read_model_from_tensor():
|
||||
model = open(test_net_xml).read()
|
||||
tensor = tensor_from_file(test_net_bin)
|
||||
func = core.read_model(model=model, weights=tensor)
|
||||
assert isinstance(func, Function)
|
||||
assert isinstance(func, Model)
|
||||
|
||||
|
||||
def test_read_model_as_path():
|
||||
core = Core()
|
||||
func = core.read_model(model=Path(test_net_xml), weights=Path(test_net_bin))
|
||||
assert isinstance(func, Function)
|
||||
assert isinstance(func, Model)
|
||||
|
||||
func = core.read_model(model=test_net_xml, weights=Path(test_net_bin))
|
||||
assert isinstance(func, Function)
|
||||
assert isinstance(func, Model)
|
||||
|
||||
func = core.read_model(model=Path(test_net_xml))
|
||||
assert isinstance(func, Function)
|
||||
assert isinstance(func, Model)
|
||||
|
||||
|
||||
def test_read_model_from_onnx():
|
||||
core = Core()
|
||||
func = core.read_model(model=test_net_onnx)
|
||||
assert isinstance(func, Function)
|
||||
assert isinstance(func, Model)
|
||||
|
||||
|
||||
def test_read_model_from_onnx_as_path():
|
||||
core = Core()
|
||||
func = core.read_model(model=Path(test_net_onnx))
|
||||
assert isinstance(func, Function)
|
||||
assert isinstance(func, Model)
|
||||
|
||||
|
||||
def test_read_net_from_buffer():
|
||||
@@ -111,7 +111,7 @@ def test_read_net_from_buffer():
|
||||
with open(model_path()[0], "rb") as f:
|
||||
xml = f.read()
|
||||
func = core.read_model(model=xml, weights=bin)
|
||||
assert isinstance(func, Function)
|
||||
assert isinstance(func, Model)
|
||||
|
||||
|
||||
def test_net_from_buffer_valid():
|
||||
@@ -302,7 +302,7 @@ def test_add_extension(device):
|
||||
else:
|
||||
core.add_extension(library_path="libtemplate_extension.so")
|
||||
func = core.read_model(model=model, init_from_buffer=True)
|
||||
assert isinstance(func, Function)
|
||||
assert isinstance(func, Model)
|
||||
|
||||
# input_blob = next(iter(network.input_info))
|
||||
# n, c, h, w = network.input_info[input_blob].input_data.shape
|
||||
@@ -379,4 +379,4 @@ def test_read_model_from_buffer_no_weights(device):
|
||||
</net>""")
|
||||
core = Core()
|
||||
func = core.read_model(model=model)
|
||||
assert isinstance(func, Function)
|
||||
assert isinstance(func, Model)
|
||||
|
||||
@@ -6,7 +6,7 @@ import pytest
|
||||
import numpy as np
|
||||
|
||||
from ..conftest import model_path, read_image
|
||||
from openvino.runtime import Function, ConstOutput, Shape
|
||||
from openvino.runtime import Model, ConstOutput, Shape
|
||||
|
||||
from openvino.runtime import Core, Tensor
|
||||
|
||||
@@ -33,12 +33,12 @@ def test_get_config(device):
|
||||
assert config == "NO"
|
||||
|
||||
|
||||
def test_get_runtime_function(device):
|
||||
def test_get_runtime_model(device):
|
||||
core = Core()
|
||||
func = core.read_model(model=test_net_xml, weights=test_net_bin)
|
||||
exec_net = core.compile_model(func, device)
|
||||
runtime_func = exec_net.get_runtime_function()
|
||||
assert isinstance(runtime_func, Function)
|
||||
runtime_func = exec_net.get_runtime_model()
|
||||
assert isinstance(runtime_func, Model)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="After infer will be implemented")
|
||||
|
||||
@@ -6,7 +6,7 @@ import pytest
|
||||
|
||||
import openvino.runtime.opset8 as ops
|
||||
|
||||
from openvino.runtime import Function, Tensor, set_batch, get_batch, Dimension, Layout
|
||||
from openvino.runtime import Model, Tensor, set_batch, get_batch, Dimension, Layout
|
||||
from openvino.runtime import Type, PartialShape, Shape
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ def test_function_add_outputs_tensor_name():
|
||||
relu1.get_output_tensor(0).set_names({"relu_t1"})
|
||||
assert "relu_t1" in relu1.get_output_tensor(0).names
|
||||
relu2 = ops.relu(relu1, name="relu2")
|
||||
function = Function(relu2, [param], "TestFunction")
|
||||
function = Model(relu2, [param], "TestFunction")
|
||||
assert len(function.get_results()) == 1
|
||||
new_outs = function.add_outputs("relu_t1")
|
||||
assert len(function.get_results()) == 2
|
||||
@@ -47,7 +47,7 @@ def test_function_add_outputs_op_name():
|
||||
relu1 = ops.relu(param, name="relu1")
|
||||
relu1.get_output_tensor(0).set_names({"relu_t1"})
|
||||
relu2 = ops.relu(relu1, name="relu2")
|
||||
function = Function(relu2, [param], "TestFunction")
|
||||
function = Model(relu2, [param], "TestFunction")
|
||||
assert len(function.get_results()) == 1
|
||||
new_outs = function.add_outputs(("relu1", 0))
|
||||
assert len(function.get_results()) == 2
|
||||
@@ -62,7 +62,7 @@ def test_function_add_output_port():
|
||||
relu1 = ops.relu(param, name="relu1")
|
||||
relu1.get_output_tensor(0).set_names({"relu_t1"})
|
||||
relu2 = ops.relu(relu1, name="relu2")
|
||||
function = Function(relu2, [param], "TestFunction")
|
||||
function = Model(relu2, [param], "TestFunction")
|
||||
assert len(function.get_results()) == 1
|
||||
new_outs = function.add_outputs(relu1.output(0))
|
||||
assert len(function.get_results()) == 2
|
||||
@@ -77,7 +77,7 @@ def test_function_add_output_incorrect_tensor_name():
|
||||
relu1 = ops.relu(param, name="relu1")
|
||||
relu1.get_output_tensor(0).set_names({"relu_t1"})
|
||||
relu2 = ops.relu(relu1, name="relu2")
|
||||
function = Function(relu2, [param], "TestFunction")
|
||||
function = Model(relu2, [param], "TestFunction")
|
||||
assert len(function.get_results()) == 1
|
||||
with pytest.raises(RuntimeError) as e:
|
||||
function.add_outputs("relu_t")
|
||||
@@ -90,7 +90,7 @@ def test_function_add_output_incorrect_idx():
|
||||
relu1 = ops.relu(param, name="relu1")
|
||||
relu1.get_output_tensor(0).set_names({"relu_t1"})
|
||||
relu2 = ops.relu(relu1, name="relu2")
|
||||
function = Function(relu2, [param], "TestFunction")
|
||||
function = Model(relu2, [param], "TestFunction")
|
||||
assert len(function.get_results()) == 1
|
||||
with pytest.raises(RuntimeError) as e:
|
||||
function.add_outputs(("relu1", 10))
|
||||
@@ -105,7 +105,7 @@ def test_function_add_output_incorrect_name():
|
||||
relu1 = ops.relu(param, name="relu1")
|
||||
relu1.get_output_tensor(0).set_names({"relu_t1"})
|
||||
relu2 = ops.relu(relu1, name="relu2")
|
||||
function = Function(relu2, [param], "TestFunction")
|
||||
function = Model(relu2, [param], "TestFunction")
|
||||
assert len(function.get_results()) == 1
|
||||
with pytest.raises(RuntimeError) as e:
|
||||
function.add_outputs(("relu_1", 0))
|
||||
@@ -120,7 +120,7 @@ def test_add_outputs_several_tensors():
|
||||
relu2 = ops.relu(relu1, name="relu2")
|
||||
relu2.get_output_tensor(0).set_names({"relu_t2"})
|
||||
relu3 = ops.relu(relu2, name="relu3")
|
||||
function = Function(relu3, [param], "TestFunction")
|
||||
function = Model(relu3, [param], "TestFunction")
|
||||
assert len(function.get_results()) == 1
|
||||
new_outs = function.add_outputs(["relu_t1", "relu_t2"])
|
||||
assert len(function.get_results()) == 3
|
||||
@@ -139,7 +139,7 @@ def test_add_outputs_several_ports():
|
||||
relu2 = ops.relu(relu1, name="relu2")
|
||||
relu2.get_output_tensor(0).set_names({"relu_t2"})
|
||||
relu3 = ops.relu(relu2, name="relu3")
|
||||
function = Function(relu3, [param], "TestFunction")
|
||||
function = Model(relu3, [param], "TestFunction")
|
||||
assert len(function.get_results()) == 1
|
||||
new_outs = function.add_outputs([("relu1", 0), ("relu2", 0)])
|
||||
assert len(function.get_results()) == 3
|
||||
@@ -156,7 +156,7 @@ def test_add_outputs_incorrect_value():
|
||||
relu1 = ops.relu(param, name="relu1")
|
||||
relu1.get_output_tensor(0).set_names({"relu_t1"})
|
||||
relu2 = ops.relu(relu1, name="relu2")
|
||||
function = Function(relu2, [param], "TestFunction")
|
||||
function = Model(relu2, [param], "TestFunction")
|
||||
assert len(function.get_results()) == 1
|
||||
with pytest.raises(TypeError) as e:
|
||||
function.add_outputs(0)
|
||||
@@ -168,7 +168,7 @@ def test_add_outputs_incorrect_outputs_list():
|
||||
param = ops.parameter(input_shape, dtype=np.float32, name="data")
|
||||
relu1 = ops.relu(param, name="relu1")
|
||||
relu1.get_output_tensor(0).set_names({"relu_t1"})
|
||||
function = Function(relu1, [param], "TestFunction")
|
||||
function = Model(relu1, [param], "TestFunction")
|
||||
assert len(function.get_results()) == 1
|
||||
with pytest.raises(TypeError) as e:
|
||||
function.add_outputs([0, 0])
|
||||
@@ -179,7 +179,7 @@ def test_validate_nodes_and_infer_types():
|
||||
param1 = ops.parameter(Shape([2, 1]), dtype=np.float32, name="data1")
|
||||
param2 = ops.parameter(Shape([2, 1]), dtype=np.float32, name="data2")
|
||||
add = ops.add(param1, param2)
|
||||
func = Function(add, [param1, param2], "TestFunction")
|
||||
func = Model(add, [param1, param2], "TestFunction")
|
||||
|
||||
invalid_shape = Shape([3, 7])
|
||||
param3 = ops.parameter(invalid_shape, dtype=np.float32, name="data3")
|
||||
@@ -194,7 +194,7 @@ def test_get_result_index():
|
||||
input_shape = PartialShape([1])
|
||||
param = ops.parameter(input_shape, dtype=np.float32, name="data")
|
||||
relu = ops.relu(param, name="relu")
|
||||
function = Function(relu, [param], "TestFunction")
|
||||
function = Model(relu, [param], "TestFunction")
|
||||
assert len(function.outputs) == 1
|
||||
assert function.get_result_index(function.outputs[0]) == 0
|
||||
|
||||
@@ -203,7 +203,7 @@ def test_get_result_index_invalid():
|
||||
shape1 = PartialShape([1])
|
||||
param1 = ops.parameter(shape1, dtype=np.float32, name="data1")
|
||||
relu1 = ops.relu(param1, name="relu1")
|
||||
function = Function(relu1, [param1], "TestFunction")
|
||||
function = Model(relu1, [param1], "TestFunction")
|
||||
|
||||
shape2 = PartialShape([2])
|
||||
param2 = ops.parameter(shape2, dtype=np.float32, name="data2")
|
||||
@@ -217,7 +217,7 @@ def test_parameter_index():
|
||||
input_shape = PartialShape([1])
|
||||
param = ops.parameter(input_shape, dtype=np.float32, name="data")
|
||||
relu = ops.relu(param, name="relu")
|
||||
function = Function(relu, [param], "TestFunction")
|
||||
function = Model(relu, [param], "TestFunction")
|
||||
assert function.get_parameter_index(param) == 0
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ def test_parameter_index_invalid():
|
||||
shape1 = PartialShape([1])
|
||||
param1 = ops.parameter(shape1, dtype=np.float32, name="data1")
|
||||
relu = ops.relu(param1, name="relu")
|
||||
function = Function(relu, [param1], "TestFunction")
|
||||
function = Model(relu, [param1], "TestFunction")
|
||||
shape2 = PartialShape([2])
|
||||
param2 = ops.parameter(shape2, dtype=np.float32, name="data2")
|
||||
assert function.get_parameter_index(param2) == -1
|
||||
@@ -238,7 +238,7 @@ def test_replace_parameter():
|
||||
param2 = ops.parameter(shape2, dtype=np.float32, name="data")
|
||||
relu = ops.relu(param1, name="relu")
|
||||
|
||||
function = Function(relu, [param1], "TestFunction")
|
||||
function = Model(relu, [param1], "TestFunction")
|
||||
param_index = function.get_parameter_index(param1)
|
||||
function.replace_parameter(param_index, param2)
|
||||
assert function.get_parameter_index(param2) == param_index
|
||||
@@ -249,7 +249,7 @@ def test_evaluate():
|
||||
param1 = ops.parameter(Shape([2, 1]), dtype=np.float32, name="data1")
|
||||
param2 = ops.parameter(Shape([2, 1]), dtype=np.float32, name="data2")
|
||||
add = ops.add(param1, param2)
|
||||
func = Function(add, [param1, param2], "TestFunction")
|
||||
func = Model(add, [param1, param2], "TestFunction")
|
||||
|
||||
input1 = np.array([2, 1], dtype=np.float32).reshape(2, 1)
|
||||
input2 = np.array([3, 7], dtype=np.float32).reshape(2, 1)
|
||||
@@ -263,7 +263,7 @@ def test_evaluate_invalid_input_shape():
|
||||
param1 = ops.parameter(Shape([2, 1]), dtype=np.float32, name="data1")
|
||||
param2 = ops.parameter(Shape([2, 1]), dtype=np.float32, name="data2")
|
||||
add = ops.add(param1, param2)
|
||||
func = Function(add, [param1, param2], "TestFunction")
|
||||
func = Model(add, [param1, param2], "TestFunction")
|
||||
|
||||
with pytest.raises(RuntimeError) as e:
|
||||
assert func.evaluate(
|
||||
|
||||
@@ -8,7 +8,7 @@ import datetime
|
||||
import time
|
||||
|
||||
import openvino.runtime.opset8 as ops
|
||||
from openvino.runtime import Core, AsyncInferQueue, Tensor, ProfilingInfo, Function
|
||||
from openvino.runtime import Core, AsyncInferQueue, Tensor, ProfilingInfo, Model
|
||||
|
||||
from ..conftest import model_path, read_image
|
||||
|
||||
@@ -22,7 +22,7 @@ def create_function_with_memory(input_shape, data_type):
|
||||
add = ops.add(rv, input_data, name="MemoryAdd")
|
||||
node = ops.assign(add, "var_id_667")
|
||||
res = ops.result(add, "res")
|
||||
func = Function(results=[res], sinks=[node], parameters=[input_data], name="name")
|
||||
func = Model(results=[res], sinks=[node], parameters=[input_data], name="name")
|
||||
return func
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import openvino.runtime as ov
|
||||
from openvino.pyopenvino import Variant
|
||||
|
||||
from openvino.runtime.exceptions import UserInputError
|
||||
from openvino.runtime import Function, PartialShape, Shape, Type, layout_helpers
|
||||
from openvino.runtime import Model, PartialShape, Shape, Type, layout_helpers
|
||||
from openvino.runtime import Tensor
|
||||
from openvino.pyopenvino import DescriptorTensor
|
||||
from openvino.runtime.op import Parameter
|
||||
@@ -31,7 +31,7 @@ def test_ngraph_function_api():
|
||||
assert parameter_a.partial_shape == PartialShape([2, 2])
|
||||
parameter_a.layout = ov.Layout("NCWH")
|
||||
assert parameter_a.layout == ov.Layout("NCWH")
|
||||
function = Function(model, [parameter_a, parameter_b, parameter_c], "TestFunction")
|
||||
function = Model(model, [parameter_a, parameter_b, parameter_c], "TestFunction")
|
||||
|
||||
function.get_parameters()[1].set_partial_shape(PartialShape([3, 4, 5]))
|
||||
|
||||
@@ -540,7 +540,7 @@ def test_sink_function_ctor():
|
||||
add = ops.add(rv, input_data, name="MemoryAdd")
|
||||
node = ops.assign(add, "var_id_667")
|
||||
res = ops.result(add, "res")
|
||||
function = Function(results=[res], sinks=[node], parameters=[input_data], name="TestFunction")
|
||||
function = Model(results=[res], sinks=[node], parameters=[input_data], name="TestFunction")
|
||||
|
||||
ordered_ops = function.get_ordered_ops()
|
||||
op_types = [op.get_type_name() for op in ordered_ops]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import numpy as np
|
||||
|
||||
import openvino.runtime.opset8 as ov
|
||||
from openvino.runtime import Dimension, Function, PartialShape, Shape
|
||||
from openvino.runtime import Dimension, Model, PartialShape, Shape
|
||||
|
||||
|
||||
def test_dimension():
|
||||
@@ -227,9 +227,9 @@ def test_repr_dynamic_shape():
|
||||
parameter_a = ov.parameter(shape, dtype=np.float32, name="A")
|
||||
parameter_b = ov.parameter(shape, dtype=np.float32, name="B")
|
||||
model = parameter_a + parameter_b
|
||||
function = Function(model, [parameter_a, parameter_b], "simple_dyn_shapes_graph")
|
||||
function = Model(model, [parameter_a, parameter_b], "simple_dyn_shapes_graph")
|
||||
|
||||
assert repr(function) == "<Function: 'simple_dyn_shapes_graph' ({?,2})>"
|
||||
assert repr(function) == "<Model: 'simple_dyn_shapes_graph' ({?,2})>"
|
||||
|
||||
ops = function.get_ordered_ops()
|
||||
for op in ops:
|
||||
|
||||
@@ -10,7 +10,7 @@ import numpy as np
|
||||
import pytest
|
||||
|
||||
import openvino.runtime.opset8 as ov
|
||||
from openvino.runtime import Function, PartialShape, Shape
|
||||
from openvino.runtime import Model, PartialShape, Shape
|
||||
from openvino.runtime.passes import Manager
|
||||
from tests.test_ngraph.util import count_ops_of_type
|
||||
from openvino.runtime import Core
|
||||
@@ -19,7 +19,7 @@ from openvino.runtime import Core
|
||||
def test_constant_folding():
|
||||
node_constant = ov.constant(np.array([[0.0, 0.1, -0.1], [-2.5, 2.5, 3.0]], dtype=np.float32))
|
||||
node_ceil = ov.ceiling(node_constant)
|
||||
func = Function(node_ceil, [], "TestFunction")
|
||||
func = Model(node_ceil, [], "TestFunction")
|
||||
|
||||
assert count_ops_of_type(func, node_ceil) == 1
|
||||
assert count_ops_of_type(func, node_constant) == 1
|
||||
@@ -47,7 +47,7 @@ def test_serialize_seperate_paths_kwargs():
|
||||
parameter_b = ov.parameter(shape, dtype=np.float32, name="B")
|
||||
parameter_c = ov.parameter(shape, dtype=np.float32, name="C")
|
||||
model = (parameter_a + parameter_b) * parameter_c
|
||||
func = Function(model, [parameter_a, parameter_b, parameter_c], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b, parameter_c], "Model")
|
||||
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass(pass_name="Serialize", xml_path=xml_path, bin_path=bin_path)
|
||||
@@ -71,7 +71,7 @@ def test_serialize_seperate_paths_args():
|
||||
parameter_c = ov.parameter(shape, dtype=np.float32, name="C")
|
||||
parameter_d = ov.parameter(shape, dtype=np.float32, name="D")
|
||||
model = ((parameter_a + parameter_b) * parameter_c) / parameter_d
|
||||
func = Function(model, [parameter_a, parameter_b, parameter_c, parameter_d], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b, parameter_c, parameter_d], "Model")
|
||||
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass("Serialize", xml_path, bin_path)
|
||||
@@ -94,7 +94,7 @@ def test_serialize_pass_mixed_args_kwargs():
|
||||
parameter_a = ov.parameter(shape, dtype=np.float32, name="A")
|
||||
parameter_b = ov.parameter(shape, dtype=np.float32, name="B")
|
||||
model = parameter_a - parameter_b
|
||||
func = Function(model, [parameter_a, parameter_b], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b], "Model")
|
||||
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass("Serialize", xml_path, bin_path=bin_path)
|
||||
@@ -119,7 +119,7 @@ def test_serialize_pass_mixed_args_kwargs_v2():
|
||||
parameter_c = ov.parameter(shape, dtype=np.float32, name="C")
|
||||
parameter_d = ov.parameter(shape, dtype=np.float32, name="D")
|
||||
model = ov.floor(ov.minimum(ov.abs(parameter_a), ov.multiply(parameter_b, parameter_c)))
|
||||
func = Function(model, [parameter_a, parameter_b, parameter_c], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b, parameter_c], "Model")
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass("Serialize", xml_path=xml_path, bin_path=bin_path)
|
||||
pass_manager.run_passes(func)
|
||||
@@ -147,7 +147,7 @@ def test_serialize_results():
|
||||
core = Core()
|
||||
node_constant = ov.constant(np.array([[0.0, 0.1, -0.1], [-2.5, 2.5, 3.0]], dtype=np.float32))
|
||||
node_ceil = ov.ceiling(node_constant)
|
||||
func = Function(node_ceil, [], "Function")
|
||||
func = Model(node_ceil, [], "Model")
|
||||
|
||||
xml_path = "serialized_function.xml"
|
||||
bin_path = "serialized_function.bin"
|
||||
@@ -175,7 +175,7 @@ def test_serialize_pass_tuple():
|
||||
parameter_c = ov.parameter(shape, dtype=np.float32, name="C")
|
||||
parameter_d = ov.parameter(shape, dtype=np.float32, name="D")
|
||||
model = ov.floor(ov.minimum(ov.abs(parameter_a), ov.multiply(parameter_b, parameter_c)))
|
||||
func = Function(model, [parameter_a, parameter_b, parameter_c], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b, parameter_c], "Model")
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass("Serialize", output_files=(xml_path, bin_path))
|
||||
pass_manager.run_passes(func)
|
||||
@@ -199,7 +199,7 @@ def test_default_version():
|
||||
parameter_c = ov.parameter(shape, dtype=np.float32, name="C")
|
||||
parameter_d = ov.parameter(shape, dtype=np.float32, name="D")
|
||||
model = ov.floor(ov.minimum(ov.abs(parameter_a), ov.multiply(parameter_b, parameter_c)))
|
||||
func = Function(model, [parameter_a, parameter_b, parameter_c], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b, parameter_c], "Model")
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass("Serialize", output_files=(xml_path, bin_path))
|
||||
pass_manager.run_passes(func)
|
||||
@@ -223,7 +223,7 @@ def test_default_version_IR_V11_tuple():
|
||||
parameter_c = ov.parameter(shape, dtype=np.float32, name="C")
|
||||
parameter_d = ov.parameter(shape, dtype=np.float32, name="D")
|
||||
model = ov.floor(ov.minimum(ov.abs(parameter_a), ov.multiply(parameter_b, parameter_c)))
|
||||
func = Function(model, [parameter_a, parameter_b, parameter_c], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b, parameter_c], "Model")
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass("Serialize", output_files=(xml_path, bin_path), version="IR_V11")
|
||||
pass_manager.run_passes(func)
|
||||
@@ -247,7 +247,7 @@ def test_default_version_IR_V11_seperate_paths():
|
||||
parameter_c = ov.parameter(shape, dtype=np.float32, name="C")
|
||||
parameter_d = ov.parameter(shape, dtype=np.float32, name="D")
|
||||
model = ov.floor(ov.minimum(ov.abs(parameter_a), ov.multiply(parameter_b, parameter_c)))
|
||||
func = Function(model, [parameter_a, parameter_b, parameter_c], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b, parameter_c], "Model")
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass("Serialize", xml_path=xml_path, bin_path=bin_path, version="IR_V11")
|
||||
pass_manager.run_passes(func)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import numpy as np
|
||||
|
||||
import openvino.runtime.opset8 as ov
|
||||
from openvino.runtime import AxisSet, Function, Shape, Type
|
||||
from openvino.runtime import AxisSet, Model, Shape, Type
|
||||
from openvino.runtime.op import Constant, Parameter
|
||||
from tests.runtime import get_runtime
|
||||
|
||||
@@ -88,7 +88,7 @@ def binary_op_exec(op_str):
|
||||
A = Parameter(element_type, shape)
|
||||
B = Parameter(element_type, shape)
|
||||
parameter_list = [A, B]
|
||||
function = Function([binary_op(op_str, A, B)], parameter_list, "test")
|
||||
function = Model([binary_op(op_str, A, B)], parameter_list, "test")
|
||||
|
||||
a_arr = np.array([[1, 6], [7, 4]], dtype=np.float32)
|
||||
b_arr = np.array([[5, 2], [3, 8]], dtype=np.float32)
|
||||
@@ -108,7 +108,7 @@ def binary_op_comparison(op_str):
|
||||
A = Parameter(element_type, shape)
|
||||
B = Parameter(element_type, shape)
|
||||
parameter_list = [A, B]
|
||||
function = Function([binary_op(op_str, A, B)], parameter_list, "test")
|
||||
function = Model([binary_op(op_str, A, B)], parameter_list, "test")
|
||||
a_arr = np.array([[1, 5], [3, 2]], dtype=np.float32)
|
||||
b_arr = np.array([[2, 4], [3, 1]], dtype=np.float32)
|
||||
|
||||
@@ -192,7 +192,7 @@ def test_add_with_mul():
|
||||
B = Parameter(element_type, shape)
|
||||
C = Parameter(element_type, shape)
|
||||
parameter_list = [A, B, C]
|
||||
function = Function([ov.multiply(ov.add(A, B), C)], parameter_list, "test")
|
||||
function = Model([ov.multiply(ov.add(A, B), C)], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, A, B, C)
|
||||
@@ -306,7 +306,7 @@ def unary_op_exec(op_str, input_list):
|
||||
shape = Shape(np.array(input_list).shape)
|
||||
A = Parameter(element_type, shape)
|
||||
parameter_list = [A]
|
||||
function = Function([unary_op(op_str, A)], parameter_list, "test")
|
||||
function = Model([unary_op(op_str, A)], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
@@ -442,7 +442,7 @@ def test_reshape():
|
||||
shape = Shape([2, 3])
|
||||
A = Parameter(element_type, shape)
|
||||
parameter_list = [A]
|
||||
function = Function([ov.reshape(A, Shape([3, 2]), special_zero=False)], parameter_list, "test")
|
||||
function = Model([ov.reshape(A, Shape([3, 2]), special_zero=False)], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
@@ -457,7 +457,7 @@ def test_broadcast():
|
||||
element_type = Type.f32
|
||||
A = Parameter(element_type, Shape([3]))
|
||||
parameter_list = [A]
|
||||
function = Function([ov.broadcast(A, [3, 3])], parameter_list, "test")
|
||||
function = Model([ov.broadcast(A, [3, 3])], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
@@ -472,7 +472,7 @@ def test_broadcast():
|
||||
def test_constant():
|
||||
element_type = Type.f32
|
||||
parameter_list = []
|
||||
function = Function([Constant(element_type, Shape([3, 3]), list(range(9)))], parameter_list, "test")
|
||||
function = Model([Constant(element_type, Shape([3, 3]), list(range(9)))], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
@@ -490,7 +490,7 @@ def test_concat():
|
||||
C = Parameter(element_type, Shape([1, 2]))
|
||||
parameter_list = [A, B, C]
|
||||
axis = 0
|
||||
function = Function([ov.concat([A, B, C], axis)], parameter_list, "test")
|
||||
function = Model([ov.concat([A, B, C], axis)], parameter_list, "test")
|
||||
|
||||
a_arr = np.array([[1, 2]], dtype=np.float32)
|
||||
b_arr = np.array([[5, 6]], dtype=np.float32)
|
||||
@@ -527,7 +527,7 @@ def test_select():
|
||||
C = Parameter(element_type, Shape([1, 2]))
|
||||
parameter_list = [A, B, C]
|
||||
|
||||
function = Function([ov.select(A, B, C)], parameter_list, "test")
|
||||
function = Model([ov.select(A, B, C)], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
@@ -569,7 +569,7 @@ def test_max_pool():
|
||||
auto_pad,
|
||||
idx_elem_type,
|
||||
)
|
||||
function = Function([model], parameter_list, "test")
|
||||
function = Model([model], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
@@ -594,7 +594,7 @@ def test_max_pool():
|
||||
auto_pad,
|
||||
idx_elem_type,
|
||||
)
|
||||
function = Function([model], parameter_list, "test")
|
||||
function = Model([model], parameter_list, "test")
|
||||
|
||||
size = 4
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
@@ -628,7 +628,7 @@ def test_max_pool():
|
||||
auto_pad,
|
||||
idx_elem_type,
|
||||
)
|
||||
function = Function([model], parameter_list, "test")
|
||||
function = Model([model], parameter_list, "test")
|
||||
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
result = computation(input_arr)[0]
|
||||
@@ -653,7 +653,7 @@ def test_max_pool():
|
||||
auto_pad,
|
||||
idx_elem_type,
|
||||
)
|
||||
function = Function([model], parameter_list, "test")
|
||||
function = Model([model], parameter_list, "test")
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
result = computation(input_arr)[0]
|
||||
|
||||
@@ -731,7 +731,7 @@ def test_convolution_simple():
|
||||
dilations = [1, 1]
|
||||
|
||||
model = ov.convolution(data, filters, strides, pads_begin, pads_end, dilations)
|
||||
function = Function([model], parameter_list, "test")
|
||||
function = Model([model], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
@@ -759,7 +759,7 @@ def test_convolution_with_strides():
|
||||
dilations = [1, 1]
|
||||
|
||||
model = ov.convolution(data, filters, strides, pads_begin, pads_end, dilations)
|
||||
function = Function([model], parameter_list, "test")
|
||||
function = Model([model], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
@@ -786,7 +786,7 @@ def test_convolution_with_filter_dilation():
|
||||
dilations = [2, 2]
|
||||
|
||||
model = ov.convolution(data, filters, strides, pads_begin, pads_end, dilations)
|
||||
function = Function([model], parameter_list, "test")
|
||||
function = Model([model], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
@@ -814,7 +814,7 @@ def test_convolution_with_padding():
|
||||
pads_end = [0, 0]
|
||||
|
||||
model = ov.convolution(data, filters, strides, pads_begin, pads_end, dilations)
|
||||
function = Function([model], parameter_list, "test")
|
||||
function = Model([model], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
@@ -843,7 +843,7 @@ def test_convolution_with_non_zero_padding():
|
||||
pads_end = [1, 2]
|
||||
|
||||
model = ov.convolution(data, filters, strides, pads_begin, pads_end, dilations)
|
||||
function = Function([model], parameter_list, "test")
|
||||
function = Model([model], parameter_list, "test")
|
||||
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function, *parameter_list)
|
||||
|
||||
@@ -6,7 +6,7 @@ import pytest
|
||||
|
||||
import openvino.runtime as ov
|
||||
import openvino.runtime.opset8 as ops
|
||||
from openvino.runtime import Function, Output, Type
|
||||
from openvino.runtime import Model, Output, Type
|
||||
from openvino.runtime.utils.decorators import custom_preprocess_function
|
||||
from openvino.runtime import Core
|
||||
from tests.runtime import get_runtime
|
||||
@@ -17,7 +17,7 @@ def test_ngraph_preprocess_mean():
|
||||
shape = [2, 2]
|
||||
parameter_a = ops.parameter(shape, dtype=np.float32, name="A")
|
||||
model = parameter_a
|
||||
function = Function(model, [parameter_a], "TestFunction")
|
||||
function = Model(model, [parameter_a], "TestFunction")
|
||||
|
||||
p = PrePostProcessor(function)
|
||||
inp = p.input()
|
||||
@@ -38,7 +38,7 @@ def test_ngraph_preprocess_mean_vector():
|
||||
shape = [2, 2]
|
||||
parameter_a = ops.parameter(shape, dtype=np.float32, name="A")
|
||||
model = parameter_a
|
||||
function = Function(model, [parameter_a], "TestFunction")
|
||||
function = Model(model, [parameter_a], "TestFunction")
|
||||
layout = ov.Layout("NCHW")
|
||||
|
||||
p = PrePostProcessor(function)
|
||||
@@ -59,7 +59,7 @@ def test_ngraph_preprocess_scale_vector():
|
||||
shape = [2, 2]
|
||||
parameter_a = ops.parameter(shape, dtype=np.float32, name="A")
|
||||
model = parameter_a
|
||||
function = Function(model, [parameter_a], "TestFunction")
|
||||
function = Model(model, [parameter_a], "TestFunction")
|
||||
layout = ov.Layout("NCHW")
|
||||
|
||||
p = PrePostProcessor(function)
|
||||
@@ -81,7 +81,7 @@ def test_ngraph_preprocess_mean_scale_convert():
|
||||
shape = [2, 2]
|
||||
param1 = ops.parameter(shape, dtype=np.int32, name="A")
|
||||
param2 = ops.parameter(shape, dtype=np.int32, name="B")
|
||||
function = Function([param1, param2], [param1, param2], "TestFunction")
|
||||
function = Model([param1, param2], [param1, param2], "TestFunction")
|
||||
|
||||
@custom_preprocess_function
|
||||
def custom_preprocess(output: Output):
|
||||
@@ -111,7 +111,7 @@ def test_ngraph_preprocess_input_output_by_name():
|
||||
shape = [2, 2]
|
||||
param1 = ops.parameter(shape, dtype=np.int32, name="A")
|
||||
param2 = ops.parameter(shape, dtype=np.int32, name="B")
|
||||
function = Function([param1, param2], [param1, param2], "TestFunction")
|
||||
function = Model([param1, param2], [param1, param2], "TestFunction")
|
||||
|
||||
@custom_preprocess_function
|
||||
def custom_preprocess(output: Output):
|
||||
@@ -145,7 +145,7 @@ def test_ngraph_preprocess_output_postprocess():
|
||||
shape = [2, 2]
|
||||
parameter_a = ops.parameter(shape, dtype=np.int32, name="A")
|
||||
model = parameter_a
|
||||
function = Function(model, [parameter_a], "TestFunction")
|
||||
function = Model(model, [parameter_a], "TestFunction")
|
||||
layout1 = ov.Layout("NCHW")
|
||||
layout2 = ov.Layout("NHWC")
|
||||
layout3 = [0, 1]
|
||||
@@ -177,7 +177,7 @@ def test_ngraph_preprocess_spatial_static_shape():
|
||||
shape = [2, 2, 2]
|
||||
parameter_a = ops.parameter(shape, dtype=np.int32, name="A")
|
||||
model = parameter_a
|
||||
function = Function(model, [parameter_a], "TestFunction")
|
||||
function = Model(model, [parameter_a], "TestFunction")
|
||||
layout = ov.Layout("CHW")
|
||||
|
||||
color_format = ColorFormat.RGB
|
||||
@@ -205,7 +205,7 @@ def test_ngraph_preprocess_set_shape():
|
||||
shape = [1, 1, 1]
|
||||
parameter_a = ops.parameter(shape, dtype=np.int32, name="A")
|
||||
model = parameter_a
|
||||
function = Function(model, [parameter_a], "TestFunction")
|
||||
function = Model(model, [parameter_a], "TestFunction")
|
||||
|
||||
@custom_preprocess_function
|
||||
def custom_crop(out_node: Output):
|
||||
@@ -256,7 +256,7 @@ def test_ngraph_preprocess_steps(algorithm, color_format1, color_format2, is_fai
|
||||
shape = [1, 1, 3, 3]
|
||||
parameter_a = ops.parameter(shape, dtype=np.float32, name="A")
|
||||
model = parameter_a
|
||||
function = Function(model, [parameter_a], "TestFunction")
|
||||
function = Model(model, [parameter_a], "TestFunction")
|
||||
layout1 = ov.Layout("NCWH")
|
||||
layout2 = ov.Layout("NCHW")
|
||||
|
||||
@@ -284,7 +284,7 @@ def test_ngraph_preprocess_postprocess_layout():
|
||||
shape = [1, 1, 3, 3]
|
||||
parameter_a = ops.parameter(shape, dtype=np.float32, name="A")
|
||||
model = parameter_a
|
||||
function = Function(model, [parameter_a], "TestFunction")
|
||||
function = Model(model, [parameter_a], "TestFunction")
|
||||
layout1 = ov.Layout("NCWH")
|
||||
layout2 = ov.Layout("NCHW")
|
||||
|
||||
@@ -309,7 +309,7 @@ def test_ngraph_preprocess_reverse_channels():
|
||||
shape = [1, 2, 2, 2]
|
||||
parameter_a = ops.parameter(shape, dtype=np.float32, name="A")
|
||||
model = parameter_a
|
||||
function = Function(model, [parameter_a], "TestFunction")
|
||||
function = Model(model, [parameter_a], "TestFunction")
|
||||
layout1 = ov.Layout("NCWH")
|
||||
|
||||
p = PrePostProcessor(function)
|
||||
@@ -331,7 +331,7 @@ def test_ngraph_preprocess_resize_algorithm():
|
||||
shape = [1, 1, 3, 3]
|
||||
parameter_a = ops.parameter(shape, dtype=np.float32, name="A")
|
||||
model = parameter_a
|
||||
function = Function(model, [parameter_a], "TestFunction")
|
||||
function = Model(model, [parameter_a], "TestFunction")
|
||||
resize_alg = ResizeAlgorithm.RESIZE_CUBIC
|
||||
layout1 = ov.Layout("NCWH")
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@ import onnx
|
||||
from onnx.backend.base import Backend, BackendRep
|
||||
from onnx.helper import make_graph, make_model, make_tensor_value_info
|
||||
|
||||
from openvino.runtime import Function
|
||||
from openvino.runtime import Model
|
||||
from tests.runtime import get_runtime
|
||||
from tests.test_onnx.utils.onnx_helpers import import_onnx_model, np_dtype_to_tensor_type
|
||||
|
||||
|
||||
class OpenVinoOnnxBackendRep(BackendRep):
|
||||
def __init__(self, ng_model_function, device="CPU"): # type: (List[Function], str) -> None
|
||||
def __init__(self, ng_model_function, device="CPU"): # type: (List[Model], str) -> None
|
||||
super().__init__()
|
||||
self.device = device
|
||||
self.ng_model_function = ng_model_function
|
||||
|
||||
@@ -5,7 +5,7 @@ import numpy as np
|
||||
import onnx
|
||||
from onnx.mapping import NP_TYPE_TO_TENSOR_TYPE
|
||||
|
||||
from openvino.runtime import Core, Tensor, Function
|
||||
from openvino.runtime import Core, Tensor, Model
|
||||
|
||||
|
||||
def np_dtype_to_tensor_type(data_type: np.dtype) -> int:
|
||||
@@ -17,7 +17,7 @@ def np_dtype_to_tensor_type(data_type: np.dtype) -> int:
|
||||
return NP_TYPE_TO_TENSOR_TYPE[data_type]
|
||||
|
||||
|
||||
def import_onnx_model(model: onnx.ModelProto) -> Function:
|
||||
def import_onnx_model(model: onnx.ModelProto) -> Model:
|
||||
onnx.checker.check_model(model)
|
||||
model_byte_string = model.SerializeToString()
|
||||
ie = Core()
|
||||
|
||||
@@ -8,7 +8,7 @@ from openvino.offline_transformations_pybind import apply_moc_transformations, a
|
||||
apply_low_latency_transformation, apply_pruning_transformation, apply_make_stateful_transformation, \
|
||||
compress_model_transformation, serialize
|
||||
|
||||
from openvino.runtime import Function, PartialShape, Core
|
||||
from openvino.runtime import Model, PartialShape, Core
|
||||
import openvino.runtime as ov
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ def get_test_function():
|
||||
param = ov.opset8.parameter(PartialShape([1, 3, 22, 22]), name="parameter")
|
||||
relu = ov.opset8.relu(param)
|
||||
res = ov.opset8.result(relu, name="result")
|
||||
return Function([res], [param], "test")
|
||||
return Model([res], [param], "test")
|
||||
|
||||
|
||||
def test_moc_transformations():
|
||||
@@ -93,7 +93,7 @@ def test_serialize_pass_v2():
|
||||
parameter_a = ov.opset8.parameter(shape, dtype=np.float32, name="A")
|
||||
parameter_b = ov.opset8.parameter(shape, dtype=np.float32, name="B")
|
||||
model = ov.opset8.floor(ov.opset8.minimum(ov.opset8.abs(parameter_a), parameter_b))
|
||||
func = Function(model, [parameter_a, parameter_b], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b], "Model")
|
||||
|
||||
serialize(func, xml_path, bin_path)
|
||||
|
||||
@@ -111,7 +111,7 @@ def test_serialize_pass_v2():
|
||||
def test_compress_model_transformation():
|
||||
node_constant = ov.opset8.constant(np.array([[0.0, 0.1, -0.1], [-2.5, 2.5, 3.0]], dtype=np.float32))
|
||||
node_ceil = ov.opset8.ceiling(node_constant)
|
||||
func = Function(node_ceil, [], "TestFunction")
|
||||
func = Model(node_ceil, [], "TestFunction")
|
||||
assert func.get_ordered_ops()[0].get_element_type().get_type_name() == "f32"
|
||||
compress_model_transformation(func)
|
||||
|
||||
@@ -127,7 +127,7 @@ def test_Version_default():
|
||||
parameter_a = ov.opset8.parameter(shape, dtype=np.float32, name="A")
|
||||
parameter_b = ov.opset8.parameter(shape, dtype=np.float32, name="B")
|
||||
model = ov.opset8.floor(ov.opset8.minimum(ov.opset8.abs(parameter_a), parameter_b))
|
||||
func = Function(model, [parameter_a, parameter_b], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b], "Model")
|
||||
|
||||
serialize(func, xml_path, bin_path)
|
||||
res_func = core.read_model(model=xml_path, weights=bin_path)
|
||||
@@ -147,7 +147,7 @@ def test_Version_ir_v10():
|
||||
parameter_a = ov.opset8.parameter(shape, dtype=np.float32, name="A")
|
||||
parameter_b = ov.opset8.parameter(shape, dtype=np.float32, name="B")
|
||||
model = ov.opset8.floor(ov.opset8.minimum(ov.opset8.abs(parameter_a), parameter_b))
|
||||
func = Function(model, [parameter_a, parameter_b], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b], "Model")
|
||||
|
||||
serialize(func, xml_path, bin_path, "IR_V10")
|
||||
res_func = core.read_model(model=xml_path, weights=bin_path)
|
||||
@@ -167,7 +167,7 @@ def test_Version_ir_v11():
|
||||
parameter_a = ov.opset8.parameter(shape, dtype=np.float32, name="A")
|
||||
parameter_b = ov.opset8.parameter(shape, dtype=np.float32, name="B")
|
||||
model = ov.opset8.floor(ov.opset8.minimum(ov.opset8.abs(parameter_a), parameter_b))
|
||||
func = Function(model, [parameter_a, parameter_b], "Function")
|
||||
func = Model(model, [parameter_a, parameter_b], "Model")
|
||||
|
||||
serialize(func, xml_path, bin_path, "IR_V11")
|
||||
res_func = core.read_model(model=xml_path, weights=bin_path)
|
||||
|
||||
@@ -117,7 +117,7 @@ xfail_issue_39662 = xfail_test(reason="RuntimeError: 'ScatterElementsUpdate' lay
|
||||
xfail_issue_37973 = xfail_test(reason="TF Inception V2 - AssertionError: zoo models results mismatch")
|
||||
xfail_issue_47430 = xfail_test(reason="FCN ResNet models - AssertionError: zoo models results mismatch")
|
||||
xfail_issue_47495 = xfail_test(reason="BertSquad-10 from MSFT - AssertionError: zoo models results mismatch")
|
||||
xfail_issue_49207 = xfail_test(reason="Function references undeclared parameters")
|
||||
xfail_issue_49207 = xfail_test(reason="Model references undeclared parameters")
|
||||
xfail_issue_48145 = xfail_test(reason="BertSquad-8 - AssertionError: Items are not equal: ACTUAL: 4 "
|
||||
"DESIRED: 3")
|
||||
xfail_issue_48190 = xfail_test(reason="RobertaBase-11 - AssertionError: Items are not equal: "
|
||||
|
||||
Reference in New Issue
Block a user