Skip to content

Commit 2450945

Browse files
Merge branch 'master' into CVS-164224
2 parents a09568a + 652860a commit 2450945

File tree

44 files changed

+837
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+837
-170
lines changed

docs/articles_en/documentation/openvino-ir-format/operation-sets/operation-specs/generation/random-uniform-8.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The result of Philox is calculated by applying a fixed number of *key* and *coun
4242
This implementation uses 4x32_10 version of Philox algorithm, where number of rounds = 10.
4343

4444
Suppose we have *n* which determines *n*-th 4 elements of random sequence.
45-
In each round *key*, *counter* and *n* are splitted to pairs of uint32 values:
45+
In each round *key*, *counter* and *n* are split to pairs of uint32 values:
4646

4747
.. math::
4848
@@ -220,7 +220,8 @@ Example 3. *RandomUniform* output with ``global_seed`` = 80, ``op_seed`` = 100,
220220

221221
Mersenne-Twister Algorithm Explanation:
222222

223-
Link to the original paper Mersenne Twister: Mersenne twister: a 623-dimensionally equidistributed uniform pseudo-random number generator <https://dl.acm.org/doi/10.1145/272991.272995>__.
223+
| Link to the original paper Mersenne Twister:
224+
| `Mersenne twister: a 623-dimensionally equidistributed uniform pseudo-random number generator <https://dl.acm.org/doi/10.1145/272991.272995>`__.
224225
225226
The Mersenne-Twister algorithm generates random numbers by initializing a state array with a seed and then iterating through a series of transformations.
226227
Suppose we have n which determines the n-th element of the random sequence.
@@ -250,11 +251,11 @@ Whenever all state values are 'used', a new state array is generated recursively
250251

251252
.. math::
252253
253-
current_state = state[i]
254-
next_state = state[i+1] if i+1 <= 623 else state[0]
255-
next_m_state = state[i+m] if i+m <= 623 else state[i+m-623]
254+
current\_state = state[i]
255+
next\_state = state[i+1] if i+1 <= 623 else state[0]
256+
next\_m_state = state[i+m] if i+m <= 623 else state[i+m-623]
256257
257-
twisted_state = (((current_state & 0x80000000) | (next_state & 0x7fffffff)) >> 1) ^ (next_state & 1 ? 0x9908b0df : 0)
258+
twisted\_state = (((current_state & 0x80000000) | (next_state & 0x7fffffff)) >> 1) ^ (next_state & 1 ? 0x9908b0df : 0)
258259
state[i] = next_m_state ^ twisted_state
259260
260261
where m is a constant.

docs/articles_en/get-started/install-openvino/install-openvino-apt.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,21 @@ Step 1: Set Up the OpenVINO Toolkit APT Repository
5656

5757
.. code-block:: sh
5858
59-
echo "deb https://apt.repos.intel.com/openvino/2025 ubuntu24 main" | sudo tee /etc/apt/sources.list.d/intel-openvino-2025.list
59+
echo "deb https://apt.repos.intel.com/openvino ubuntu24 main" | sudo tee /etc/apt/sources.list.d/intel-openvino.list
6060
6161
.. tab-item:: Ubuntu 22
6262
:sync: ubuntu-22
6363

6464
.. code-block:: sh
6565
66-
echo "deb https://apt.repos.intel.com/openvino/2025 ubuntu22 main" | sudo tee /etc/apt/sources.list.d/intel-openvino-2025.list
66+
echo "deb https://apt.repos.intel.com/openvino ubuntu22 main" | sudo tee /etc/apt/sources.list.d/intel-openvino.list
6767
6868
.. tab-item:: Ubuntu 20
6969
:sync: ubuntu-20
7070

7171
.. code-block:: sh
7272
73-
echo "deb https://apt.repos.intel.com/openvino/2025 ubuntu20 main" | sudo tee /etc/apt/sources.list.d/intel-openvino-2025.list
73+
echo "deb https://apt.repos.intel.com/openvino ubuntu20 main" | sudo tee /etc/apt/sources.list.d/intel-openvino.list
7474
7575
7676
3. Update the list of packages via the update command:
@@ -126,7 +126,7 @@ Step 2: Install OpenVINO Runtime Using the APT Package Manager
126126
.. code-block:: sh
127127
128128
129-
sudo apt install openvino-2025.0.0
129+
sudo apt install openvino-2025.1.0
130130
131131
.. note::
132132

@@ -199,7 +199,7 @@ To uninstall OpenVINO Runtime via APT, run the following command based on your n
199199

200200
.. code-block:: sh
201201
202-
sudo apt autoremove openvino-2025.0.0
202+
sudo apt autoremove openvino-2025.1.0
203203
204204
205205
What's Next?

docs/articles_en/get-started/install-openvino/install-openvino-yum.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ Step 1: Set Up the Repository
2525
+++++++++++++++++++++++++++++
2626

2727

28-
1. Create a YUM repository file (``openvino-2025.repo``) in the ``/tmp`` directory as a normal user:
28+
1. Create a YUM repository file (``openvino.repo``) in the ``/tmp`` directory as a normal user:
2929

3030
.. code-block:: sh
3131
32-
tee > /tmp/openvino-2025.repo << EOF
32+
tee > /tmp/openvino.repo << EOF
3333
[OpenVINO]
34-
name=Intel(R) Distribution of OpenVINO 2025
35-
baseurl=https://yum.repos.intel.com/openvino/2025
34+
name=Intel(R) Distribution of OpenVINO
35+
baseurl=https://yum.repos.intel.com/openvino
3636
enabled=1
3737
gpgcheck=1
3838
repo_gpgcheck=1
3939
gpgkey=https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
4040
EOF
4141
42-
2. Move the new ``openvino-2025.repo`` file to the YUM configuration directory, i.e. ``/etc/yum.repos.d``:
42+
2. Move the new ``openvino.repo`` file to the YUM configuration directory, i.e. ``/etc/yum.repos.d``:
4343
4444
.. code-block:: sh
4545
46-
sudo mv /tmp/openvino-2025.repo /etc/yum.repos.d
46+
sudo mv /tmp/openvino.repo /etc/yum.repos.d
4747
4848
3. Verify that the new repository is set up properly.
4949
@@ -93,7 +93,7 @@ Install OpenVINO Runtime
9393
.. code-block:: sh
9494
9595
96-
sudo yum install openvino-2025.0.0
96+
sudo yum install openvino-2025.1.0
9797
9898
9999
@@ -164,7 +164,7 @@ To uninstall OpenVINO Runtime via YUM, run the following command based on your n
164164
165165
.. code-block:: sh
166166
167-
sudo yum autoremove openvino-2025.0.0
167+
sudo yum autoremove openvino-2025.1.0
168168
169169
170170

src/bindings/python/src/pyopenvino/core/tensor.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ void regclass_Tensor(py::module m) {
216216

217217
cls.def(py::init([](py::object& image) {
218218
if (!py::isinstance(image, py::module::import("PIL.Image").attr("Image"))) {
219-
throw py::type_error("Input must be a PIL.Image.Image object");
219+
throw py::type_error(
220+
"Input argument must be a PIL.Image.Image/numpy.array/List[int, float, str] object");
220221
}
221222
auto numpy = py::module::import("numpy");
222223
py::array np_array = numpy.attr("array")(image);
@@ -225,19 +226,19 @@ void regclass_Tensor(py::module m) {
225226
}),
226227
py::arg("image"),
227228
R"(
228-
Constructs Tensor from a Pillow Image.
229+
Constructs Tensor from a Pillow Image.
229230
230-
:param image: Pillow Image to create the tensor from.
231-
:type image: PIL.Image.Image
232-
:Example:
233-
.. code-block:: python
231+
:param image: Pillow Image to create the tensor from.
232+
:type image: PIL.Image.Image
233+
:Example:
234+
.. code-block:: python
234235
235-
from PIL import Image
236-
import openvino as ov
236+
from PIL import Image
237+
import openvino as ov
237238
238-
img = Image.open("example.jpg")
239-
tensor = ov.Tensor(img)
240-
)");
239+
img = Image.open("example.jpg")
240+
tensor = ov.Tensor(img)
241+
)");
241242

242243
cls.def("get_element_type",
243244
&ov::Tensor::get_element_type,

src/bindings/python/src/pyopenvino/graph/op.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,17 @@ bool PyOp::evaluate(ov::TensorVector& output_values, const ov::TensorVector& inp
5353
}
5454

5555
bool PyOp::has_evaluate() const {
56-
PYBIND11_OVERRIDE(bool, ov::op::Op, has_evaluate);
56+
py::gil_scoped_acquire gil; // Acquire the GIL while in this scope.
57+
// Try to look up the overridden method on the Python side.
58+
py::function overrided_py_method = pybind11::get_override(this, "has_evaluate");
59+
if (overrided_py_method) { // method is found
60+
return static_cast<py::bool_>(overrided_py_method()); // Call the Python function.
61+
}
62+
py::function overrided_evaluate_method = pybind11::get_override(this, "evaluate");
63+
if (overrided_evaluate_method) {
64+
return true;
65+
}
66+
return false;
5767
}
5868

5969
void PyOp::update_type_info() {

src/bindings/python/tests/test_graph/test_custom_op.py

+12
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ def visit_attributes(self, visitor):
106106
visitor.on_attributes(self._attrs)
107107
return True
108108

109+
def evaluate(self, outputs, inputs):
110+
inputs[0].copy_to(outputs[0])
111+
return True
112+
109113

110114
# request - https://docs.pytest.org/en/7.1.x/reference/reference.html#request
111115
@pytest.fixture
@@ -156,6 +160,14 @@ def test_visit_attributes_custom_op(prepared_paths, attributes, expectation, rai
156160
if e is not None:
157161
assert raise_msg in str(e.value)
158162

163+
input_data = np.ones([2, 1], dtype=np.float32)
164+
expected_output = np.maximum(0.0, input_data)
165+
166+
compiled_model = compile_model(model_with_op_attr)
167+
input_tensor = Tensor(input_data)
168+
results = compiled_model({"data1": input_tensor})
169+
assert np.allclose(results[list(results)[0]], expected_output, 1e-4, 1e-4)
170+
159171

160172
def test_custom_add_op():
161173
data1 = np.array([1, 2, 3])

src/core/include/openvino/runtime/tensor.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,12 @@ using TensorVector = std::vector<Tensor>;
270270
/// length of the file content and `offset`. Default value is [?].
271271
/// \param offset_in_bytes Read file starting from specified offset. Default is 0. The remining size of the file should
272272
/// be compatible with shape.
273+
/// \param mmap Use mmap that postpones real read from file until data is accessed. If mmap is used, the file
274+
/// should not be modified until returned tensor is destroyed.
273275
OPENVINO_API
274276
Tensor read_tensor_data(const std::filesystem::path& file_name,
275277
const element::Type& element_type = element::u8,
276278
const PartialShape& shape = PartialShape::dynamic(1),
277-
std::size_t offset_in_bytes = 0);
279+
std::size_t offset_in_bytes = 0,
280+
bool mmap = true);
278281
} // namespace ov

src/core/src/op/constant.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,19 @@ bool Constant::has_evaluate() const {
658658
}
659659

660660
bool Constant::evaluate_lower(TensorVector& outputs) const {
661-
return evaluate(outputs, {});
661+
if (!outputs.empty() && outputs[0].get_element_type() != m_element_type)
662+
return evaluate(outputs, {}); // for TypeRelaxed<Constant>
663+
outputs.resize(1);
664+
outputs[0] = get_tensor_view();
665+
return get_data_ptr() != nullptr;
662666
}
667+
663668
bool Constant::evaluate_upper(TensorVector& outputs) const {
664-
return evaluate(outputs, {});
669+
if (!outputs.empty() && outputs[0].get_element_type() != m_element_type)
670+
return evaluate(outputs, {}); // for TypeRelaxed<Constant>
671+
outputs.resize(1);
672+
outputs[0] = get_tensor_view();
673+
return get_data_ptr() != nullptr;
665674
}
666675

667676
bool Constant::can_constant_fold(const OutputVector& input_values) const {

src/core/src/runtime/tensor.cpp

+32-14
Original file line numberDiff line numberDiff line change
@@ -162,26 +162,44 @@ ov::Shape calc_static_shape_for_file(const std::filesystem::path& file_name,
162162
dynamic_dimension = Dimension(new_dimension_size);
163163
return partial_shape_copy.get_shape();
164164
}
165+
166+
void read_tensor_data(const std::filesystem::path& file_name, Tensor& tensor, size_t offset) {
167+
OPENVINO_ASSERT(tensor.get_element_type() != ov::element::string);
168+
std::ifstream fin(file_name, std::ios::binary);
169+
fin.seekg(offset);
170+
auto bytes_to_read = tensor.get_byte_size();
171+
fin.read(static_cast<char*>(tensor.data()), bytes_to_read);
172+
OPENVINO_ASSERT(static_cast<size_t>(fin.gcount()) == bytes_to_read,
173+
"Cannot read ",
174+
bytes_to_read,
175+
"bytes from ",
176+
file_name);
177+
}
165178
} // namespace
166179

167180
Tensor read_tensor_data(const std::filesystem::path& file_name,
168181
const ov::element::Type& element_type,
169182
const ov::PartialShape& partial_shape,
170-
size_t offset_in_bytes) {
183+
size_t offset_in_bytes,
184+
bool mmap) {
171185
OPENVINO_ASSERT(element_type != ov::element::string);
172186
auto static_shape = calc_static_shape_for_file(file_name, element_type, partial_shape, offset_in_bytes);
173-
174-
auto mapped_memory = ov::load_mmap_object(file_name);
175-
auto shared_buffer =
176-
std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::MappedMemory>>>(mapped_memory->data() + offset_in_bytes,
177-
mapped_memory->size() - offset_in_bytes,
178-
mapped_memory);
179-
180-
auto view_tensor = Tensor(element_type, static_shape, shared_buffer->get_ptr());
181-
auto impl = get_tensor_impl(view_tensor);
182-
impl._so = shared_buffer;
183-
view_tensor = make_tensor(impl);
184-
185-
return view_tensor;
187+
if (mmap) {
188+
auto mapped_memory = ov::load_mmap_object(file_name);
189+
auto shared_buffer = std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::MappedMemory>>>(
190+
mapped_memory->data() + offset_in_bytes,
191+
mapped_memory->size() - offset_in_bytes,
192+
mapped_memory);
193+
194+
auto view_tensor = Tensor(element_type, static_shape, shared_buffer->get_ptr());
195+
auto impl = get_tensor_impl(view_tensor);
196+
impl._so = shared_buffer;
197+
view_tensor = make_tensor(impl);
198+
return view_tensor;
199+
} else {
200+
ov::Tensor tensor(element_type, static_shape);
201+
read_tensor_data(file_name, tensor, offset_in_bytes);
202+
return tensor;
203+
}
186204
}
187205
} // namespace ov

0 commit comments

Comments
 (0)