Skip to content

Commit 5068c00

Browse files
authored
Merge branch 'master' into issue#22949
2 parents 8ab4260 + 34ebb77 commit 5068c00

35 files changed

+1919
-177
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ void regmodule_properties(py::module m) {
7272
.value("ECORE_ONLY", ov::hint::SchedulingCoreType::ECORE_ONLY);
7373

7474
py::enum_<ov::hint::ModelDistributionPolicy>(m_hint, "ModelDistributionPolicy", py::arithmetic())
75-
.value("TENSOR_PARALLEL", ov::hint::ModelDistributionPolicy::TENSOR_PARALLEL);
75+
.value("TENSOR_PARALLEL", ov::hint::ModelDistributionPolicy::TENSOR_PARALLEL)
76+
.value("PIPELINE_PARALLEL", ov::hint::ModelDistributionPolicy::PIPELINE_PARALLEL);
7677

7778
py::enum_<ov::hint::ExecutionMode>(m_hint, "ExecutionMode", py::arithmetic())
7879
.value("PERFORMANCE", ov::hint::ExecutionMode::PERFORMANCE)

src/core/include/openvino/core/any.hpp

+28
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <map>
1212
#include <memory>
13+
#include <set>
1314
#include <string>
1415
#include <typeindex>
1516
#include <typeinfo>
@@ -209,6 +210,18 @@ struct Read<std::vector<T, A>, typename std::enable_if<std::is_default_construct
209210
}
210211
};
211212

213+
template <typename K, typename C, typename A>
214+
struct Read<std::set<K, C, A>, typename std::enable_if<std::is_default_constructible<K>::value>::type> {
215+
void operator()(std::istream& is, std::set<K, C, A>& set) const {
216+
while (is.good()) {
217+
std::string str;
218+
is >> str;
219+
auto v = from_string<K>(str);
220+
set.insert(std::move(v));
221+
}
222+
}
223+
};
224+
212225
template <typename K, typename T, typename C, typename A>
213226
struct Read<
214227
std::map<K, T, C, A>,
@@ -343,6 +356,21 @@ struct Write<std::vector<T, A>> {
343356
}
344357
};
345358

359+
template <typename K, typename C, typename A>
360+
struct Write<std::set<K, C, A>> {
361+
void operator()(std::ostream& os, const std::set<K, C, A>& set) const {
362+
if (!set.empty()) {
363+
std::size_t i = 0;
364+
for (auto&& v : set) {
365+
os << to_string(v);
366+
if (i < (set.size() - 1))
367+
os << ' ';
368+
++i;
369+
}
370+
}
371+
}
372+
};
373+
346374
template <typename K, typename T, typename C, typename A>
347375
struct Write<std::map<K, T, C, A>> {
348376
void operator()(std::ostream& os, const std::map<K, T, C, A>& map) const {

src/core/tests/any.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ TEST_F(AnyTests, AnyAsMapOfAnys) {
158158
ASSERT_EQ(refMap["testParamString"].as<std::string>(), testString);
159159
}
160160

161+
TEST_F(AnyTests, AnyAsSetOfAnys) {
162+
std::set<std::string> refSet0;
163+
std::set<int> refSet1;
164+
refSet0.insert("test");
165+
refSet1.insert(4);
166+
Any s0 = refSet0;
167+
Any s1 = refSet1;
168+
bool isSet0 = s0.is<std::set<std::string>>();
169+
bool isSet1 = s1.is<std::set<int>>();
170+
ASSERT_TRUE(isSet0);
171+
ASSERT_TRUE(isSet1);
172+
auto testSet0 = s0.as<std::set<std::string>>();
173+
auto testSet1 = s1.as<std::set<int>>();
174+
ASSERT_NE(testSet0.count("test"), 0);
175+
ASSERT_NE(testSet1.count(4), 0);
176+
}
177+
161178
TEST_F(AnyTests, AnyAsMapOfMapOfAnys) {
162179
std::map<std::string, Any> refMap1;
163180
refMap1["testParamInt"] = 4;

src/frontends/onnx/frontend/src/op/batch_norm.cpp

+41-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ ov::OutputVector batch_norm(const ov::frontend::onnx::Node& node) {
5252
OPENVINO_THROW("Cannot create OpenVINO batch norm with unsupported number of inputs");
5353
}
5454
} // namespace set_1
55+
/*
56+
Opset 6 is skipped because there are no significant difference between opset1 and opset6.
57+
Found difference is:
58+
1. In Training, the computation of ReduceMean and ReduceVar uses float
59+
to avoid overflow for float16 inputs.
60+
*/
5561

5662
namespace set_7 {
5763
// This version supports ONNX BatchNormalization-7 and BatchNormalization-9
@@ -71,8 +77,42 @@ ov::OutputVector batch_norm(const ov::frontend::onnx::Node& node) {
7177

7278
return {std::make_shared<v5::BatchNormInference>(x, scale, bias, mean, var, epsilon)};
7379
}
74-
7580
} // namespace set_7
81+
/*
82+
Opset 9 is skipped because there are no significant difference between opset7 and opset9.
83+
Found difference is:
84+
1. removed -> spatial : int (default is 1)
85+
If true, compute the mean and variance across per activation. If false, compute the mean and variance across
86+
per feature over each mini-batch.
87+
88+
*/
89+
90+
namespace set_14 {
91+
// This version supports ONNX BatchNormalization-14 BatchNormalization-15
92+
ov::OutputVector batch_norm(const ov::frontend::onnx::Node& node) {
93+
ov::OutputVector inputs{node.get_ov_inputs()};
94+
auto x = inputs.at(0);
95+
auto scale = inputs.at(1);
96+
auto bias = inputs.at(2);
97+
auto mean = inputs.at(3);
98+
auto var = inputs.at(4);
99+
100+
double epsilon{node.get_attribute_value<double>("epsilon", 1e-5)};
101+
int64_t training_mode{node.get_attribute_value<int64_t>("training_mode", 0)};
102+
103+
CHECK_VALID_NODE(node,
104+
training_mode == false && node.get_outputs_size() == 1,
105+
"Training mode of BatchNormalization is not supported.");
106+
return {std::make_shared<v5::BatchNormInference>(x, scale, bias, mean, var, epsilon)};
107+
}
108+
} // namespace set_14
109+
/*
110+
Opset 15 is skipped because there are no significant difference between opset14 and opset15.
111+
Found difference is:
112+
1. In Training, the computation of ReduceMean and ReduceVar uses float
113+
to avoid overflow for float16 inputs.
114+
*/
115+
76116
} // namespace op
77117
} // namespace onnx
78118
} // namespace frontend

src/frontends/onnx/frontend/src/op/batch_norm.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ namespace set_7 {
1919
ov::OutputVector batch_norm(const ov::frontend::onnx::Node& node);
2020

2121
} // namespace set_7
22+
23+
namespace set_14 {
24+
ov::OutputVector batch_norm(const ov::frontend::onnx::Node& node);
25+
26+
} // namespace set_14
2227
} // namespace op
2328
} // namespace onnx
2429
} // namespace frontend

src/frontends/onnx/frontend/src/ops_bridge.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ OperatorsBridge::OperatorsBridge() {
360360
REGISTER_OPERATOR("AveragePool", 1, average_pool);
361361
REGISTER_OPERATOR("BatchNormalization", 1, batch_norm);
362362
REGISTER_OPERATOR("BatchNormalization", 7, batch_norm);
363+
REGISTER_OPERATOR("BatchNormalization", 14, batch_norm);
363364
REGISTER_OPERATOR("BitShift", 1, bitshift);
364365
REGISTER_OPERATOR("BitwiseAnd", 1, bitwise_and);
365366
REGISTER_OPERATOR("BitwiseNot", 1, bitwise_not);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
ir_version: 3
2+
producer_name: "OpenVINO ONNX Frontend"
3+
graph {
4+
node {
5+
input: "x"
6+
input: "s"
7+
input: "bias"
8+
input: "mean"
9+
input: "var"
10+
output: "y"
11+
op_type: "BatchNormalization"
12+
}
13+
name: "test_batchnorm_example"
14+
input {
15+
name: "x"
16+
type {
17+
tensor_type {
18+
elem_type: 1
19+
shape {
20+
dim {
21+
dim_value: 1
22+
}
23+
dim {
24+
dim_value: 2
25+
}
26+
dim {
27+
dim_value: 1
28+
}
29+
dim {
30+
dim_value: 3
31+
}
32+
}
33+
}
34+
}
35+
}
36+
input {
37+
name: "s"
38+
type {
39+
tensor_type {
40+
elem_type: 1
41+
shape {
42+
dim {
43+
dim_value: 2
44+
}
45+
}
46+
}
47+
}
48+
}
49+
input {
50+
name: "bias"
51+
type {
52+
tensor_type {
53+
elem_type: 1
54+
shape {
55+
dim {
56+
dim_value: 2
57+
}
58+
}
59+
}
60+
}
61+
}
62+
input {
63+
name: "mean"
64+
type {
65+
tensor_type {
66+
elem_type: 1
67+
shape {
68+
dim {
69+
dim_value: 2
70+
}
71+
}
72+
}
73+
}
74+
}
75+
input {
76+
name: "var"
77+
type {
78+
tensor_type {
79+
elem_type: 1
80+
shape {
81+
dim {
82+
dim_value: 2
83+
}
84+
}
85+
}
86+
}
87+
}
88+
output {
89+
name: "y"
90+
type {
91+
tensor_type {
92+
elem_type: 1
93+
shape {
94+
dim {
95+
dim_value: 1
96+
}
97+
dim {
98+
dim_value: 2
99+
}
100+
dim {
101+
dim_value: 1
102+
}
103+
dim {
104+
dim_value: 3
105+
}
106+
}
107+
}
108+
}
109+
}
110+
}
111+
opset_import {
112+
version: 1
113+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
ir_version: 3
2+
producer_name: "OpenVINO ONNX Frontend"
3+
graph {
4+
node {
5+
input: "x"
6+
input: "s"
7+
input: "bias"
8+
input: "mean"
9+
input: "var"
10+
output: "y"
11+
op_type: "BatchNormalization"
12+
}
13+
name: "test_batchnorm_example"
14+
input {
15+
name: "x"
16+
type {
17+
tensor_type {
18+
elem_type: 1
19+
shape {
20+
dim {
21+
dim_value: 1
22+
}
23+
dim {
24+
dim_value: 2
25+
}
26+
dim {
27+
dim_value: 1
28+
}
29+
dim {
30+
dim_value: 3
31+
}
32+
}
33+
}
34+
}
35+
}
36+
input {
37+
name: "s"
38+
type {
39+
tensor_type {
40+
elem_type: 1
41+
shape {
42+
dim {
43+
dim_value: 2
44+
}
45+
}
46+
}
47+
}
48+
}
49+
input {
50+
name: "bias"
51+
type {
52+
tensor_type {
53+
elem_type: 1
54+
shape {
55+
dim {
56+
dim_value: 2
57+
}
58+
}
59+
}
60+
}
61+
}
62+
input {
63+
name: "mean"
64+
type {
65+
tensor_type {
66+
elem_type: 1
67+
shape {
68+
dim {
69+
dim_value: 2
70+
}
71+
}
72+
}
73+
}
74+
}
75+
input {
76+
name: "var"
77+
type {
78+
tensor_type {
79+
elem_type: 1
80+
shape {
81+
dim {
82+
dim_value: 2
83+
}
84+
}
85+
}
86+
}
87+
}
88+
output {
89+
name: "y"
90+
type {
91+
tensor_type {
92+
elem_type: 1
93+
shape {
94+
dim {
95+
dim_value: 1
96+
}
97+
dim {
98+
dim_value: 2
99+
}
100+
dim {
101+
dim_value: 1
102+
}
103+
dim {
104+
dim_value: 3
105+
}
106+
}
107+
}
108+
}
109+
}
110+
}
111+
opset_import {
112+
version: 14
113+
}

0 commit comments

Comments
 (0)