Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[PyOV] Add set_tensor binding for RemoteTensor (#26726)

Vladimir Paramuzovcd0ce9b76c49
diff --git a/src/bindings/python/src/pyopenvino/core/infer_request.cpp b/src/bindings/python/src/pyopenvino/core/infer_request.cpp
index 9f572d273dc..eed93db8db7 100644
--- a/src/bindings/python/src/pyopenvino/core/infer_request.cpp
+++ b/src/bindings/python/src/pyopenvino/core/infer_request.cpp
@@ -10,6 +10,7 @@
#include <string>
#include "pyopenvino/core/common.hpp"
+#include "pyopenvino/core/remote_tensor.hpp"
#include "pyopenvino/utils/utils.hpp"
namespace py = pybind11;
@@ -464,12 +465,29 @@ void regclass_InferRequest(py::module m) {
},
R"(
Gets output tensor of InferRequest.
-
+
:return: An output Tensor for the model.
If model has several outputs, an exception is thrown.
:rtype: openvino.runtime.Tensor
)");
+ cls.def(
+ "set_tensor",
+ [](InferRequestWrapper& self, const std::string& name, const RemoteTensorWrapper& tensor) {
+ self.m_request->set_tensor(name, tensor.tensor);
+ },
+ py::arg("name"),
+ py::arg("tensor"),
+ R"(
+ Sets input/output tensor of InferRequest.
+
+ :param name: Name of input/output tensor.
+ :type name: str
+ :param tensor: RemoteTensor object. The element_type and shape of a tensor
+ must match the model's input/output element_type and shape.
+ :type tensor: openvino.runtime.RemoteTensor
+ )");
+
cls.def(
"set_tensor",
[](InferRequestWrapper& self, const std::string& name, const ov::Tensor& tensor) {