Skip to content

Commit 7021ae0

Browse files
authored
Merge branch 'openvinotoolkit:master' into softmax_cross_entropy_loss_for_onnx_fe
2 parents 26e590b + ce69c62 commit 7021ae0

File tree

10 files changed

+313
-388
lines changed

10 files changed

+313
-388
lines changed

.github/workflows/windows_vs2019_release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
repo_token: ${{ secrets.GITHUB_TOKEN }}
4646
skip_when_only_listed_labels_set: 'docs'
4747
skip_when_only_listed_files_changed: '*.md,*.rst,*.png,*.jpg,*.svg,*/layer_tests_summary/*,*/conformance/*'
48-
48+
4949
- name: Get target branch
5050
id: set_target_branch
5151
run: |
@@ -192,7 +192,7 @@ jobs:
192192
sparse-checkout: |
193193
src/bindings/js
194194
path: 'openvino'
195-
195+
196196
- name: Download OpenVINO artifacts (JS)
197197
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
198198
with:
@@ -223,7 +223,7 @@ jobs:
223223
run: call npm test
224224

225225
- name: Add msbuild to PATH
226-
uses: microsoft/setup-msbuild@v2
226+
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2
227227

228228
- name: E2E of openvino-node package
229229
working-directory: ${{ env.OPENVINO_JS_DIR }}/node

.github/workflows/workflows_scans.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,37 @@ concurrency:
1818
permissions: read-all
1919

2020
jobs:
21+
codeql:
22+
name: github_actions_workflows_scan/codeql
23+
# Runner size impacts CodeQL analysis time. To learn more, please see:
24+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
25+
# - https://gh.io/supported-runners-and-hardware-resources
26+
# - https://gh.io/using-larger-runners
27+
# Consider using larger runners for possible analysis time improvements.
28+
runs-on: ubuntu-22.04
29+
timeout-minutes: 60
30+
permissions:
31+
security-events: write
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
timeout-minutes: 15
36+
with:
37+
submodules: 'false'
38+
sparse-checkout: .github/workflows
39+
40+
# Initializes the CodeQL tools for scanning.
41+
- name: Initialize CodeQL
42+
uses: github/codeql-action/init@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
43+
with:
44+
languages: "actions"
45+
build-mode: "none"
46+
47+
- name: Perform CodeQL Analysis
48+
uses: github/codeql-action/analyze@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
49+
with:
50+
category: "/language:actions"
51+
2152
semgrep:
2253
name: github_actions_workflows_scan/semgrep
2354
runs-on: ubuntu-latest

src/common/util/include/openvino/util/common_util.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pragma once
66

77
#include <algorithm>
8+
#include <array>
89
#include <cctype>
910
#include <cstring>
1011
#include <numeric>
@@ -173,5 +174,11 @@ inline void erase_if(Container& data, const PredicateT& predicate) {
173174

174175
std::string filter_lines_by_prefix(const std::string& str, const std::string& prefix);
175176

177+
template <class T = void, class... Args>
178+
constexpr std::array<std::conditional_t<std::is_void_v<T>, std::common_type_t<Args...>, T>, sizeof...(Args)> make_array(
179+
Args&&... args) {
180+
return {std::forward<Args>(args)...};
181+
}
182+
176183
} // namespace util
177184
} // namespace ov

src/core/include/openvino/core/type/element_type.hpp

Lines changed: 77 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ enum class Type_t {
7070
/// \ingroup ov_element_cpp_api
7171
class OPENVINO_API Type {
7272
public:
73-
Type() = default;
74-
Type(const Type&) = default;
73+
constexpr Type() = default;
74+
constexpr Type(const Type&) = default;
7575
constexpr Type(const Type_t t) : m_type{t} {}
7676
explicit Type(const std::string& type);
77-
Type& operator=(const Type&) = default;
77+
constexpr Type& operator=(const Type&) = default;
7878
std::string c_type_string() const;
7979
size_t size() const;
8080
size_t hash() const;
@@ -95,6 +95,8 @@ class OPENVINO_API Type {
9595
// The name of this type, the enum name of this type
9696
std::string get_type_name() const;
9797
friend OPENVINO_API std::ostream& operator<<(std::ostream&, const Type&);
98+
99+
OPENVINO_DEPRECATED("This function is deprecated and will be removed in 2026.0.")
98100
static std::vector<const Type*> get_known_types();
99101

100102
/// \brief Checks whether this element type is merge-compatible with `t`.
@@ -137,129 +139,131 @@ using TypeVector = std::vector<Type>;
137139

138140
/// \brief undefined element type
139141
/// \ingroup ov_element_cpp_api
140-
constexpr Type undefined(Type_t::undefined);
142+
inline constexpr Type undefined(Type_t::undefined);
141143
/// \brief dynamic element type
142144
/// \ingroup ov_element_cpp_api
143-
constexpr Type dynamic(Type_t::dynamic);
145+
inline constexpr Type dynamic(Type_t::dynamic);
144146
/// \brief boolean element type
145147
/// \ingroup ov_element_cpp_api
146-
constexpr Type boolean(Type_t::boolean);
148+
inline constexpr Type boolean(Type_t::boolean);
147149
/// \brief bf16 element type
148150
/// \ingroup ov_element_cpp_api
149-
constexpr Type bf16(Type_t::bf16);
151+
inline constexpr Type bf16(Type_t::bf16);
150152
/// \brief f16 element type
151153
/// \ingroup ov_element_cpp_api
152-
constexpr Type f16(Type_t::f16);
154+
inline constexpr Type f16(Type_t::f16);
153155
/// \brief f32 element type
154156
/// \ingroup ov_element_cpp_api
155-
constexpr Type f32(Type_t::f32);
157+
inline constexpr Type f32(Type_t::f32);
156158
/// \brief f64 element type
157159
/// \ingroup ov_element_cpp_api
158-
constexpr Type f64(Type_t::f64);
160+
inline constexpr Type f64(Type_t::f64);
159161
/// \brief i4 element type
160162
/// \ingroup ov_element_cpp_api
161-
constexpr Type i4(Type_t::i4);
163+
inline constexpr Type i4(Type_t::i4);
162164
/// \brief i8 element type
163165
/// \ingroup ov_element_cpp_api
164-
constexpr Type i8(Type_t::i8);
166+
inline constexpr Type i8(Type_t::i8);
165167
/// \brief i16 element type
166168
/// \ingroup ov_element_cpp_api
167-
constexpr Type i16(Type_t::i16);
169+
inline constexpr Type i16(Type_t::i16);
168170
/// \brief i32 element type
169171
/// \ingroup ov_element_cpp_api
170-
constexpr Type i32(Type_t::i32);
172+
inline constexpr Type i32(Type_t::i32);
171173
/// \brief i64 element type
172174
/// \ingroup ov_element_cpp_api
173-
constexpr Type i64(Type_t::i64);
175+
inline constexpr Type i64(Type_t::i64);
174176
/// \brief binary element type
175177
/// \ingroup ov_element_cpp_api
176-
constexpr Type u1(Type_t::u1);
178+
inline constexpr Type u1(Type_t::u1);
177179
/// \brief u2 element type
178180
/// \ingroup ov_element_cpp_api
179-
constexpr Type u2(Type_t::u2);
181+
inline constexpr Type u2(Type_t::u2);
180182
/// \brief u3 element type
181183
/// \ingroup ov_element_cpp_api
182-
constexpr Type u3(Type_t::u3);
184+
inline constexpr Type u3(Type_t::u3);
183185
/// \brief u4 element type
184186
/// \ingroup ov_element_cpp_api
185-
constexpr Type u4(Type_t::u4);
187+
inline constexpr Type u4(Type_t::u4);
186188
/// \brief u6 element type
187189
/// \ingroup ov_element_cpp_api
188-
constexpr Type u6(Type_t::u6);
190+
inline constexpr Type u6(Type_t::u6);
189191
/// \brief u8 element type
190192
/// \ingroup ov_element_cpp_api
191-
constexpr Type u8(Type_t::u8);
193+
inline constexpr Type u8(Type_t::u8);
192194
/// \brief u16 element type
193195
/// \ingroup ov_element_cpp_api
194-
constexpr Type u16(Type_t::u16);
196+
inline constexpr Type u16(Type_t::u16);
195197
/// \brief u32 element type
196198
/// \ingroup ov_element_cpp_api
197-
constexpr Type u32(Type_t::u32);
199+
inline constexpr Type u32(Type_t::u32);
198200
/// \brief u64 element type
199201
/// \ingroup ov_element_cpp_api
200-
constexpr Type u64(Type_t::u64);
202+
inline constexpr Type u64(Type_t::u64);
201203
/// \brief nf4 element type
202204
/// \ingroup ov_element_cpp_api
203-
constexpr Type nf4(Type_t::nf4);
205+
inline constexpr Type nf4(Type_t::nf4);
204206
/// \brief f8e4m3 element type
205207
/// \ingroup ov_element_cpp_api
206-
constexpr Type f8e4m3(Type_t::f8e4m3);
208+
inline constexpr Type f8e4m3(Type_t::f8e4m3);
207209
/// \brief f8e4m3 element type
208210
/// \ingroup ov_element_cpp_api
209-
constexpr Type f8e5m2(Type_t::f8e5m2);
211+
inline constexpr Type f8e5m2(Type_t::f8e5m2);
210212
/// \brief string element type
211213
/// \ingroup ov_element_cpp_api
212-
constexpr Type string(Type_t::string);
214+
inline constexpr Type string(Type_t::string);
213215
/// \brief f4e2m1 element type
214216
/// \ingroup ov_element_cpp_api
215-
constexpr Type f4e2m1(Type_t::f4e2m1);
217+
inline constexpr Type f4e2m1(Type_t::f4e2m1);
216218
/// \brief f8e8m0 element type
217219
/// \ingroup ov_element_cpp_api
218-
constexpr Type f8e8m0(Type_t::f8e8m0);
220+
inline constexpr Type f8e8m0(Type_t::f8e8m0);
219221

220-
template <typename T>
221-
Type from() {
222-
OPENVINO_THROW("Unknown type");
222+
template <class T>
223+
constexpr Type from() {
224+
if constexpr (std::is_same_v<T, char> || std::is_same_v<T, bool>) {
225+
return boolean;
226+
} else if constexpr (std::is_same_v<T, ov::float16>) {
227+
return f16;
228+
} else if constexpr (std::is_same_v<T, float>) {
229+
return f32;
230+
} else if constexpr (std::is_same_v<T, double>) {
231+
return f64;
232+
} else if constexpr (std::is_same_v<T, int8_t>) {
233+
return i8;
234+
} else if constexpr (std::is_same_v<T, int16_t>) {
235+
return i16;
236+
} else if constexpr (std::is_same_v<T, int32_t>) {
237+
return i32;
238+
} else if constexpr (std::is_same_v<T, int64_t>) {
239+
return i64;
240+
} else if constexpr (std::is_same_v<T, uint8_t>) {
241+
return u8;
242+
} else if constexpr (std::is_same_v<T, uint16_t>) {
243+
return u16;
244+
} else if constexpr (std::is_same_v<T, uint32_t>) {
245+
return u32;
246+
} else if constexpr (std::is_same_v<T, uint64_t>) {
247+
return u64;
248+
} else if constexpr (std::is_same_v<T, ov::bfloat16>) {
249+
return bf16;
250+
} else if constexpr (std::is_same_v<T, ov::float8_e4m3>) {
251+
return f8e4m3;
252+
} else if constexpr (std::is_same_v<T, ov::float8_e5m2>) {
253+
return f8e5m2;
254+
} else if constexpr (std::is_same_v<T, std::string>) {
255+
return string;
256+
} else if constexpr (std::is_same_v<T, ov::float4_e2m1>) {
257+
return f4e2m1;
258+
} else if constexpr (std::is_same_v<T, ov::float8_e8m0>) {
259+
return f8e8m0;
260+
} else {
261+
OPENVINO_THROW("Unknown type");
262+
}
223263
}
224-
template <>
225-
OPENVINO_API Type from<char>();
226-
template <>
227-
OPENVINO_API Type from<bool>();
228-
template <>
229-
OPENVINO_API Type from<float>();
230-
template <>
231-
OPENVINO_API Type from<double>();
232-
template <>
233-
OPENVINO_API Type from<int8_t>();
234-
template <>
235-
OPENVINO_API Type from<int16_t>();
236-
template <>
237-
OPENVINO_API Type from<int32_t>();
238-
template <>
239-
OPENVINO_API Type from<int64_t>();
240-
template <>
241-
OPENVINO_API Type from<uint8_t>();
242-
template <>
243-
OPENVINO_API Type from<uint16_t>();
244-
template <>
245-
OPENVINO_API Type from<uint32_t>();
246-
template <>
247-
OPENVINO_API Type from<uint64_t>();
248-
template <>
249-
OPENVINO_API Type from<ov::bfloat16>();
250-
template <>
251-
OPENVINO_API Type from<ov::float16>();
252-
template <>
253-
OPENVINO_API Type from<ov::float8_e4m3>();
254-
template <>
255-
OPENVINO_API Type from<ov::float8_e5m2>();
256-
template <>
257-
OPENVINO_API Type from<std::string>();
258-
template <>
259-
OPENVINO_API Type from<ov::float4_e2m1>();
260-
template <>
261-
OPENVINO_API Type from<ov::float8_e8m0>();
262264

265+
OPENVINO_DEPRECATED(
266+
"This function is deprecated and will be removed in 2026.0. Use ov::fundamental_type_for<Type> instead")
263267
OPENVINO_API Type fundamental_type_for(const Type& type);
264268

265269
OPENVINO_API
@@ -281,12 +285,12 @@ template <>
281285
class OPENVINO_API AttributeAdapter<ov::element::Type> : public ValueAccessor<std::string> {
282286
public:
283287
OPENVINO_RTTI("AttributeAdapter<ov::element::Type>");
284-
AttributeAdapter(ov::element::Type& value) : m_ref(value) {}
288+
constexpr AttributeAdapter(ov::element::Type& value) : m_ref(value) {}
285289

286290
const std::string& get() override;
287291
void set(const std::string& value) override;
288292

289-
operator ov::element::Type&() {
293+
constexpr operator ov::element::Type&() {
290294
return m_ref;
291295
}
292296

0 commit comments

Comments
 (0)