Skip to content

Commit f777b5e

Browse files
authored
Merge branch 'master' into uk/changing-sub-byte-i4-element-order
2 parents 9b9611c + 55f62a0 commit f777b5e

File tree

99 files changed

+524
-340
lines changed

Some content is hidden

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

99 files changed

+524
-340
lines changed

.github/workflows/code_snippets.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,11 @@ jobs:
4646
run: cmake -DCMAKE_BUILD_TYPE=Release -DTHREADING=SEQ -B build
4747

4848
- name: Build snippets
49-
run: cmake --build build --target openvino_docs_snippets --parallel
49+
if: ${{ runner.os == 'Linux' || runner.os == 'macOS'}}
50+
run: cmake --build build --target openvino_docs_snippets --parallel $(nproc)
51+
52+
- name: Build snippets Windows
53+
if: ${{ runner.os == 'Windows'}}
54+
shell: pwsh
55+
run: cmake --build build --target openvino_docs_snippets --parallel $ENV:NUMBER_OF_PROCESSORS
56+

docs/articles_en/assets/snippets/multi_threading.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int main() {
1818
auto compiled_model_1 = core.compile_model(model, device, ov::inference_num_threads(1));
1919

2020
// Use logical processors of Efficient-cores for inference on hybrid platform
21-
auto compiled_model_2 = core.compile_model(model, device, ov::hint::scheduling_core_type(ECORE_ONLY));
21+
auto compiled_model_2 = core.compile_model(model, device, ov::hint::scheduling_core_type(ov::hint::SchedulingCoreType::ECORE_ONLY));
2222

2323
// Use one logical processor per CPU core for inference when hyper threading is on
2424
auto compiled_model_3 = core.compile_model(model, device, ov::hint::enable_hyper_threading(false));

docs/articles_en/assets/snippets/npu_remote_objects_creation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int main() {
4242

4343
{
4444
//! [wrap_dmabuf_fd]
45-
int32_t fd_heap; // create the DMA-BUF System Heap file descriptor
45+
int32_t fd_heap = 0; // create the DMA-BUF System Heap file descriptor
4646
auto remote_tensor = npu_context.create_tensor(in_element_type, in_shape, fd_heap);
4747
//! [wrap_dmabuf_fd]
4848
}

docs/articles_en/assets/snippets/ov_dynamic_shapes.c

+18-18
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,22 @@ ov_model_t* model = NULL;
6161
ov_core_read_model(core, "model.xml", NULL, &model);
6262

6363
//! [ov_dynamic_shapes:print_dynamic]
64-
ov_output_port_t* output_port = NULL;
65-
ov_output_port_t* input_port = NULL;
64+
ov_output_const_port_t* output_port = NULL;
65+
ov_output_const_port_t* input_port = NULL;
6666
ov_partial_shape_t partial_shape;
67-
char * str_partial_shape = NULL;
67+
const char * str_partial_shape = NULL;
6868

6969
// Print output partial shape
7070
{
71-
ov_model_output(model, &output_port);
71+
ov_model_const_output(model, &output_port);
7272
ov_port_get_partial_shape(output_port, &partial_shape);
7373
str_partial_shape = ov_partial_shape_to_string(partial_shape);
7474
printf("The output partial shape: %s", str_partial_shape);
7575
}
7676

7777
// Print input partial shape
7878
{
79-
ov_model_input(model, &input_port);
79+
ov_model_const_input(model, &input_port);
8080
ov_port_get_partial_shape(input_port, &partial_shape);
8181
str_partial_shape = ov_partial_shape_to_string(partial_shape);
8282
printf("The input partial shape: %s", str_partial_shape);
@@ -85,8 +85,8 @@ printf("The input partial shape: %s", str_partial_shape);
8585
// free allocated resource
8686
ov_free(str_partial_shape);
8787
ov_partial_shape_free(&partial_shape);
88-
ov_output_port_free(output_port);
89-
ov_output_port_free(input_port);
88+
ov_output_const_port_free(output_port);
89+
ov_output_const_port_free(input_port);
9090
//! [ov_dynamic_shapes:print_dynamic]
9191
ov_model_free(model);
9292
ov_core_free(core);
@@ -98,15 +98,15 @@ ov_core_create(&core);
9898

9999
//! [ov_dynamic_shapes:detect_dynamic]
100100
ov_model_t* model = NULL;
101-
ov_output_port_t* input_port = NULL;
102-
ov_output_port_t* output_port = NULL;
101+
ov_output_const_port_t* input_port = NULL;
102+
ov_output_const_port_t* output_port = NULL;
103103
ov_partial_shape_t partial_shape;
104104

105105
ov_core_read_model(core, "model.xml", NULL, &model);
106106

107107
// for input
108108
{
109-
ov_model_input_by_index(model, 0, &input_port);
109+
ov_model_const_input_by_index(model, 0, &input_port);
110110
ov_port_get_partial_shape(input_port, &partial_shape);
111111
if (ov_partial_shape_is_dynamic(partial_shape)) {
112112
// input is dynamic
@@ -115,7 +115,7 @@ if (ov_partial_shape_is_dynamic(partial_shape)) {
115115

116116
// for output
117117
{
118-
ov_model_output_by_index(model, 0, &output_port);
118+
ov_model_const_output_by_index(model, 0, &output_port);
119119
ov_port_get_partial_shape(output_port, &partial_shape);
120120
if (ov_partial_shape_is_dynamic(partial_shape)) {
121121
// output is dynamic
@@ -124,8 +124,8 @@ if (ov_partial_shape_is_dynamic(partial_shape)) {
124124

125125
// free allocated resource
126126
ov_partial_shape_free(&partial_shape);
127-
ov_output_port_free(input_port);
128-
ov_output_port_free(output_port);
127+
ov_output_const_port_free(input_port);
128+
ov_output_const_port_free(output_port);
129129
//! [ov_dynamic_shapes:detect_dynamic]
130130
ov_model_free(model);
131131
ov_core_free(core);
@@ -147,8 +147,8 @@ ov_infer_request_t* infer_request = NULL;
147147
ov_compiled_model_create_infer_request(compiled_model, &infer_request);
148148

149149
//! [ov_dynamic_shapes:set_input_tensor]
150-
ov_output_port_t* input_port = NULL;
151-
ov_element_type_e* type = NULL;
150+
ov_output_const_port_t* input_port = NULL;
151+
ov_element_type_e type = UNDEFINED;
152152
ov_shape_t input_shape_1;
153153
ov_tensor_t* input_tensor_1 = NULL;
154154
ov_tensor_t* output_tensor = NULL;
@@ -163,8 +163,8 @@ void* data_2 = NULL;
163163
// Create tensor compatible with the model input
164164
// Shape {1, 128} is compatible with any reshape statements made in previous examples
165165
{
166-
ov_model_input(model, &input_port);
167-
ov_port_get_element_type(input_port, type);
166+
ov_model_const_input(model, &input_port);
167+
ov_port_get_element_type(input_port, &type);
168168
int64_t dims[2] = {1, 128};
169169
ov_shape_create(2, dims, &input_shape_1);
170170
ov_tensor_create(type, input_shape_1, &input_tensor_1);
@@ -214,7 +214,7 @@ ov_tensor_get_shape(output_tensor, &output_shape_2);
214214
// ... read values in data_2 according to the shape output_shape_2
215215

216216
// free resource
217-
ov_output_port_free(input_port);
217+
ov_output_const_port_free(input_port);
218218
ov_shape_free(&input_shape_1);
219219
ov_tensor_free(input_tensor_1);
220220
ov_shape_free(&output_shape_1);

docs/articles_en/assets/snippets/ov_patterns.cpp

+40-70
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
// ! [ov:imports]
5-
#include <gtest/gtest.h>
6-
7-
#include "common_test_utils/matcher.hpp"
85
#include "openvino/op/abs.hpp"
96
#include "openvino/op/add.hpp"
107
#include "openvino/op/matmul.hpp"
@@ -22,7 +19,7 @@ using namespace std;
2219
// ! [ov:imports]
2320

2421
// ! [ov:create_simple_model_and_pattern]
25-
TEST(pattern, simple_model_and_pattern) {
22+
void create_simple_model_and_pattern() {
2623
// Create a sample model
2724
PartialShape shape{2, 2};
2825
auto model_param1 = std::make_shared<ov::op::v0::Parameter>(element::i32, shape);
@@ -39,17 +36,13 @@ TEST(pattern, simple_model_and_pattern) {
3936
auto pattern_abs = std::make_shared<ov::op::v0::Abs>(pattern_mul->output(0));
4037
auto pattern_relu = std::make_shared<ov::op::v0::Relu>(pattern_abs->output(0));
4138

42-
// Create a matcher and try to match the nodes
43-
TestMatcher tm;
44-
45-
// Should perfectly match
46-
ASSERT_TRUE(tm.match(pattern_relu, model_relu));
39+
// pattern_relu should perfectly match model_relu
4740
}
4841
// ! [ov:create_simple_model_and_pattern]
4942

5043

5144
// ! [ov:create_simple_model_and_pattern_wrap_type]
52-
TEST(pattern, simple_model_and_pattern_wrap_type) {
45+
void create_simple_model_and_pattern_wrap_type() {
5346
// Create a sample model
5447
PartialShape shape{2, 2};
5548
auto model_param1 = std::make_shared<ov::op::v0::Parameter>(element::i32, shape);
@@ -66,17 +59,13 @@ TEST(pattern, simple_model_and_pattern_wrap_type) {
6659
auto pattern_abs = ov::pass::pattern::wrap_type<ov::op::v0::Abs>({pattern_mul->output(0)});
6760
auto pattern_relu = ov::pass::pattern::wrap_type<ov::op::v0::Relu>({pattern_abs->output(0)});
6861

69-
// Create a matcher and try to match the nodes
70-
TestMatcher tm;
71-
72-
// Should perfectly match
73-
ASSERT_TRUE(tm.match(pattern_relu, model_relu));
62+
// pattern_relu should perfectly match model_relu
7463
}
7564
// ! [ov:create_simple_model_and_pattern_wrap_type]
7665

7766

7867
// ! [ov:wrap_type_list]
79-
TEST(pattern, wrap_type_list) {
68+
void wrap_type_list() {
8069
// Create a sample model
8170
PartialShape shape{2, 2};
8271
auto model_param1 = std::make_shared<ov::op::v0::Parameter>(element::i32, shape);
@@ -95,45 +84,42 @@ TEST(pattern, wrap_type_list) {
9584
auto pattern_abs = ov::pass::pattern::wrap_type<ov::op::v0::Abs>({pattern_mul->output(0)});
9685
auto pattern_relu = ov::pass::pattern::wrap_type<ov::op::v0::Relu, ov::op::v0::Sigmoid>({pattern_abs->output(0)});
9786

98-
// Create a matcher and try to match the nodes
99-
TestMatcher tm;
100-
101-
// The same pattern perfectly matches 2 different nodes
102-
ASSERT_TRUE(tm.match(pattern_relu, model_relu));
103-
ASSERT_TRUE(tm.match(pattern_relu, model_sig));
87+
// pattern_relu should perfectly matches model_relu and model_sig
10488
}
10589
// ! [ov:wrap_type_list]
10690

10791
void patterns_misc() {
108-
// ! [ov:any_input]
109-
auto pattern_mul = ov::pass::pattern::wrap_type<ov::op::v0::MatMul>({pattern::any_input(), pattern::any_input()});
110-
auto pattern_abs = ov::pass::pattern::wrap_type<ov::op::v0::Abs>({pattern_mul->output(0)});
111-
auto pattern_relu = ov::pass::pattern::wrap_type<ov::op::v0::Relu>({pattern_abs->output(0)});
112-
// ! [ov:any_input]
113-
114-
// ! [ov:wrap_type_predicate]
115-
ov::pass::pattern::wrap_type<ov::op::v0::Relu>({pattern::any_input()}, pattern::consumers_count(2));
116-
// ! [ov:wrap_type_predicate]
117-
118-
119-
// ! [ov:any_input_predicate]
120-
auto pattern_mul = ov::pass::pattern::wrap_type<ov::op::v0::MatMul>({pattern::any_input([](const Output<Node>& value){
121-
return value.get_shape().size() == 4;}),
122-
pattern::any_input([](const Output<Node>& value){
123-
return value.get_shape().size() == 4;})});
124-
auto pattern_abs = ov::pass::pattern::wrap_type<ov::op::v0::Abs>({pattern_mul->output(0)});
125-
auto pattern_relu = ov::pass::pattern::wrap_type<ov::op::v0::Relu>({pattern_abs->output(0)});
126-
// ! [ov:any_input_predicate]
127-
128-
129-
// ! [ov:optional_predicate]
130-
auto pattern_sig_opt = ov::pass::pattern::optional<ov::op::v0::Sigmoid>(pattern_relu, pattern::consumers_count(2));
131-
// ! [ov:optional_predicate]
92+
{
93+
// ! [ov:any_input]
94+
auto pattern_mul = ov::pass::pattern::wrap_type<ov::op::v0::MatMul>({pattern::any_input(), pattern::any_input()});
95+
auto pattern_abs = ov::pass::pattern::wrap_type<ov::op::v0::Abs>({pattern_mul->output(0)});
96+
auto pattern_relu = ov::pass::pattern::wrap_type<ov::op::v0::Relu>({pattern_abs->output(0)});
97+
// ! [ov:any_input]
98+
99+
// ! [ov:wrap_type_predicate]
100+
ov::pass::pattern::wrap_type<ov::op::v0::Relu>({pattern::any_input()}, pattern::consumers_count(2));
101+
// ! [ov:wrap_type_predicate]
102+
}
103+
{
104+
// ! [ov:any_input_predicate]
105+
auto pattern_mul = ov::pass::pattern::wrap_type<ov::op::v0::MatMul>({pattern::any_input([](const Output<Node>& value){
106+
return value.get_shape().size() == 4;}),
107+
pattern::any_input([](const Output<Node>& value){
108+
return value.get_shape().size() == 4;})});
109+
auto pattern_abs = ov::pass::pattern::wrap_type<ov::op::v0::Abs>({pattern_mul->output(0)});
110+
auto pattern_relu = ov::pass::pattern::wrap_type<ov::op::v0::Relu>({pattern_abs->output(0)});
111+
// ! [ov:any_input_predicate]
112+
113+
114+
// ! [ov:optional_predicate]
115+
auto pattern_sig_opt = ov::pass::pattern::optional<ov::op::v0::Sigmoid>(pattern_relu, pattern::consumers_count(2));
116+
// ! [ov:optional_predicate]
117+
}
132118
}
133119

134120

135121
// ! [ov:pattern_or]
136-
TEST(pattern, pattern_or) {
122+
void pattern_or() {
137123
// Create a sample model
138124
PartialShape shape{2, 2};
139125
auto model_param1 = std::make_shared<ov::op::v0::Parameter>(element::i32, shape);
@@ -158,17 +144,13 @@ TEST(pattern, pattern_or) {
158144
// Create Or node
159145
auto pattern_or = std::make_shared<ov::pass::pattern::op::Or>(OutputVector{red_pattern_sigmoid->output(0), blue_pattern_relu->output(0)});
160146

161-
// Create a matcher and try to match the nodes
162-
TestMatcher tm;
163-
164-
// The same pattern perfectly matches 2 different nodes
165-
ASSERT_TRUE(tm.match(pattern_or, model_relu));
147+
// pattern_or should perfectly matches model_relu
166148
}
167149
// ! [ov:pattern_or]
168150

169151

170152
// ! [ov:pattern_optional_middle]
171-
TEST(pattern, pattern_optional_middle) {
153+
void pattern_optional_middle() {
172154
// Create a sample model
173155
PartialShape shape{2, 2};
174156
auto model_param1 = std::make_shared<ov::op::v0::Parameter>(element::i32, shape);
@@ -186,17 +168,13 @@ TEST(pattern, pattern_optional_middle) {
186168
auto pattern_sig_opt = ov::pass::pattern::optional<ov::op::v0::Sigmoid>({pattern_abs->output(0)});
187169
auto pattern_relu = ov::pass::pattern::wrap_type<ov::op::v0::Relu>({pattern_sig_opt->output(0)});
188170

189-
// Create a matcher and try to match the nodes
190-
TestMatcher tm;
191-
192-
// Should perfectly match
193-
ASSERT_TRUE(tm.match(pattern_relu, model_relu));
171+
// pattern_relu should perfectly match model_relu
194172
}
195173
// ! [ov:pattern_optional_middle]
196174

197175

198176
// ! [ov:pattern_optional_top]
199-
TEST(pattern, pattern_optional_top) {
177+
void pattern_optional_top() {
200178
// Create a sample model
201179
PartialShape shape{2, 2};
202180
auto model_param1 = std::make_shared<ov::op::v0::Parameter>(element::i32, shape);
@@ -214,17 +192,13 @@ TEST(pattern, pattern_optional_top) {
214192
auto pattern_abs = ov::pass::pattern::wrap_type<ov::op::v0::Abs>({pattern_mul->output(0)});
215193
auto pattern_relu = ov::pass::pattern::wrap_type<ov::op::v0::Relu>({pattern_abs->output(0)});
216194

217-
// Create a matcher and try to match the nodes
218-
TestMatcher tm;
219-
220-
// Should perfectly match
221-
ASSERT_TRUE(tm.match(pattern_relu, model_relu));
195+
// pattern_relu should perfectly match model_relu
222196
}
223197
// ! [ov:pattern_optional_top]
224198

225199

226200
// ! [ov:pattern_optional_root]
227-
TEST(pattern, pattern_optional_root) {
201+
void pattern_optional_root() {
228202
// Create a sample model
229203
PartialShape shape{2, 2};
230204
auto model_param1 = std::make_shared<ov::op::v0::Parameter>(element::i32, shape);
@@ -242,10 +216,6 @@ TEST(pattern, pattern_optional_root) {
242216
auto pattern_relu = ov::pass::pattern::wrap_type<ov::op::v0::Relu>({pattern_abs->output(0)});
243217
auto pattern_sig_opt = ov::pass::pattern::optional<ov::op::v0::Sigmoid>(pattern_relu);
244218

245-
// Create a matcher and try to match the nodes
246-
TestMatcher tm;
247-
248-
// Should perfectly match
249-
ASSERT_TRUE(tm.match(pattern_relu, model_relu));
219+
// pattern_relu should perfectly match model_relu
250220
}
251221
// ! [ov:pattern_optional_root]

docs/articles_en/assets/snippets/ov_sparse_weights_decompression.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int main() {
1111
ov::AnyMap config;
1212
//! [ov:intel_cpu:sparse_weights_decompression:part0]
1313
ov::Core core; // Step 1: create ov::Core object
14-
core.set_property(ov::intel_cpu::sparse_weights_decompression_rate(0.8)); // Step 1b: Enable sparse weights decompression feature
14+
core.set_property(ov::intel_cpu::sparse_weights_decompression_rate(0.8f)); // Step 1b: Enable sparse weights decompression feature
1515
auto model = core.read_model(modelPath); // Step 2: Read Model
1616
//... // Step 3: Prepare inputs/outputs
1717
//... // Step 4: Set device configuration

docs/articles_en/documentation/openvino-extensibility/custom-gpu-operations.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ There are two options for using the custom operation configuration file:
3030
.. tab-item:: Python
3131
:sync: py
3232

33-
.. doxygensnippet:: docs/articles_en/assets/snippets/custom_kernels_api.py
33+
.. doxygensnippet:: docs/articles_en/assets/snippets/gpu/custom_kernels_api.py
3434
:language: python
3535
:fragment: [part0]
3636

3737
.. tab-item:: C++
3838
:sync: cpp
3939

40-
.. doxygensnippet:: docs/articles_en/assets/snippets/custom_kernels_api.cpp
40+
.. doxygensnippet:: docs/articles_en/assets/snippets/gpu/custom_kernels_api.cpp
4141
:language: cpp
4242
:fragment: [part0]
4343

0 commit comments

Comments
 (0)