Skip to content

Commit 47b4812

Browse files
Merge branch 'master' into common-onednn
2 parents 3015a60 + 953e6a0 commit 47b4812

Some content is hidden

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

49 files changed

+686
-452
lines changed

cmake/developer_package/target_flags.cmake

+37-22
Original file line numberDiff line numberDiff line change
@@ -113,31 +113,35 @@ endif()
113113

114114
get_property(OV_GENERATOR_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
115115

116+
function(ov_get_compiler_definition definition var)
117+
if(NOT LINUX)
118+
message(FATAL_ERROR "Internal error: 'ov_get_definition' must be used only on Linux")
119+
endif()
120+
121+
execute_process(COMMAND echo "#include <string>"
122+
COMMAND "${CMAKE_CXX_COMPILER}" -x c++ - -E -dM
123+
COMMAND grep -E "^#define ${definition} "
124+
OUTPUT_VARIABLE output_value
125+
ERROR_VARIABLE error_message
126+
RESULT_VARIABLE exit_code
127+
OUTPUT_STRIP_TRAILING_WHITESPACE)
128+
129+
if(NOT exit_code EQUAL 0)
130+
message(FATAL_ERROR "Failed to detect '${definition}' definition value: ${error_message}\n${output_value}")
131+
endif()
132+
133+
if(output_value MATCHES "^#define ${definition} ([0-9]+)")
134+
set("${var}" "${CMAKE_MATCH_1}" PARENT_SCOPE)
135+
else()
136+
message(FATAL_ERROR "Internal error: failed to parse ${definition} from '${output_value}'")
137+
endif()
138+
endfunction()
139+
116140
function(ov_glibc_version)
117141
# cmake needs to look at glibc version only when we build for Linux on Linux
118142
if(LINUX)
119-
function(ov_get_definition definition var)
120-
execute_process(COMMAND echo "#include <errno.h>"
121-
COMMAND "${CMAKE_CXX_COMPILER}" -xc - -E -dM
122-
COMMAND grep -E "^#define ${definition} "
123-
OUTPUT_VARIABLE glibc_version_component
124-
ERROR_VARIABLE error_message
125-
RESULT_VARIABLE exit_code
126-
OUTPUT_STRIP_TRAILING_WHITESPACE)
127-
128-
if(NOT exit_code EQUAL 0)
129-
message(FATAL_ERROR "Failed to detect glibc version: ${error_message}\n${glibc_version_component}")
130-
endif()
131-
132-
if(glibc_version_component MATCHES "^#define ${definition} ([0-9]+)")
133-
set("${var}" "${CMAKE_MATCH_1}" PARENT_SCOPE)
134-
else()
135-
message(FATAL_ERROR "Internal error: failed to parse ${definition} from '${glibc_version_component}'")
136-
endif()
137-
endfunction()
138-
139-
ov_get_definition("__GLIBC__" _ov_glibc_major)
140-
ov_get_definition("__GLIBC_MINOR__" _ov_glibc_minor)
143+
ov_get_compiler_definition("__GLIBC__" _ov_glibc_major)
144+
ov_get_compiler_definition("__GLIBC_MINOR__" _ov_glibc_minor)
141145

142146
set(OV_GLIBC_VERSION "${_ov_glibc_major}.${_ov_glibc_minor}" PARENT_SCOPE)
143147
else()
@@ -146,3 +150,14 @@ function(ov_glibc_version)
146150
endfunction()
147151

148152
ov_glibc_version()
153+
154+
#
155+
# Detects default value for _GLIBCXX_USE_CXX11_ABI for current compiler
156+
#
157+
macro(ov_get_glibcxx_use_cxx11_abi)
158+
if(LINUX)
159+
ov_get_compiler_definition("_GLIBCXX_USE_CXX11_ABI" OV_GLIBCXX_USE_CXX11_ABI)
160+
endif()
161+
endmacro()
162+
163+
ov_get_glibcxx_use_cxx11_abi()

cmake/packaging/debian.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ macro(ov_cpack_settings)
320320

321321
set(CPACK_DEBIAN_PYOPENVINO_PACKAGE_${pyversion}_PACKAGE_NAME "python3-openvino-${cpack_name_ver}")
322322
set(python_package "${CPACK_DEBIAN_PYOPENVINO_PACKAGE_${pyversion}_PACKAGE_NAME} (= ${cpack_full_ver})")
323-
set(CPACK_DEBIAN_PYOPENVINO_PACKAGE_${pyversion}_PACKAGE_DEPENDS "python3, python3-numpy")
323+
set(CPACK_DEBIAN_PYOPENVINO_PACKAGE_${pyversion}_PACKAGE_DEPENDS "python3, python3-numpy, python3-packaging")
324324

325325
# we can have a single python installed, so we need to generate conflicts for all other versions
326326
ov_debian_generate_conflicts(${python_component} ${conflicting_versions})

docs/dev/ci/github_actions/adding_tests.md

+5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ The [`fedora.yml`](./../../../../.github/workflows/fedora.yml) workflow example
135135

136136
## Test Time and Usage
137137

138+
Be mindful about time and runners usage when adding new steps, jobs and workflows. When adding any new test or changing
139+
the scope of an existing test, always check the test execution time in your pull request. As a rule of thumb, the execution time
140+
of any workflow in the precommit should be less than 60 minutes. Also note that even if, as recommended, the execution time is
141+
less than 60 minutes, it may be unreasonably costly to run a powerful multi-core runner for a long time without a proper workload.
142+
138143
### Adding a Step
139144

140145
When adding a step in a job, check its execution time compared to other jobs. Try to

docs/dev/ci/github_actions/overview.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ included in the [Linux workflow](../../../../.github/workflows/linux.yml). They
6262
* This trigger runs the workflow on a specified interval (e.g., nightly).
6363
* In the example below: `'0 0 * * 3,6'` - learn more on [cron syntax](https://crontab.guru/)
6464
* `on: pull_request` - pre-commit trigger
65-
* This trigger runs the workflow when a PR is created targeting the `master` or `release`
65+
* This trigger runs the workflow when a pull request (PR) is created targeting the `master` or `release`
6666
branch and every time the PR is updated with new commits.
6767
* In the example below, it additionally requires that the changed files conform to the path
6868
globs specified under the `paths` key.

docs/dev/ci/github_actions/runners.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Two types of runners are available in this repository:
77
* [GitHub Actions Runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners) - runners provided and managed by GitHub
88
* [Self-hosted Runners](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners) - runners created and managed by the OpenVINO CI team and linked to the OpenVINO repositories
99

10+
Generally, it is advised to use the GitHub Actions runners for light jobs, like labelers, code style checks, etc, whereas
11+
longer workflows (such as builds or functional tests) should use the self-hosted runners.
12+
1013
The runners are specified for each job using the `runs-on` key.
1114

1215
An example `Build` job from the [`linux.yml`](./../../../../.github/workflows/linux.yml)

docs/dev/ci/github_actions/smart_ci.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Smart CI Overview
22

33
Smart CI is a feature designed to optimize pre-commit CI workflow by running only the necessary
4-
builds and tests required to validate changes in a given Pull Request (PR).
4+
builds and tests required to validate changes in a given pull request (PR).
55

66
For example, if a PR changes only the CPU plugin, GPU plugin tests are skipped in the pre-commit stage
77
for this PR, as they are unrelated. This approach reduces execution time for isolated changes

src/bindings/python/wheel/setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ def cmake_build_and_install(self, install_cfg):
277277
self.spawn(["cmake", "--install", binary_dir,
278278
"--prefix", prefix,
279279
"--config", CONFIG,
280-
"--strip",
281280
"--component", cpack_comp_name])
282281

283282
def run(self):

src/cmake/openvino.cmake

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ if(NOT BUILD_SHARED_LIBS)
5353
target_compile_definitions(${TARGET_NAME} PUBLIC OPENVINO_STATIC_LIBRARY)
5454
endif()
5555

56+
if(DEFINED OV_GLIBCXX_USE_CXX11_ABI)
57+
target_compile_definitions(${TARGET_NAME} PUBLIC _GLIBCXX_USE_CXX11_ABI=${OV_GLIBCXX_USE_CXX11_ABI})
58+
endif()
59+
5660
if(WIN32)
5761
set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME})
5862
endif()

src/common/snippets/src/pass/collapse_subgraph.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -606,11 +606,12 @@ TokenizeSnippets::TokenizeSnippets() {
606606
}
607607

608608
// The each data node (Parameter (and non-Scalar Constants), Result, Buffers with the same ID) requires the own unique GPR.
609-
// At the moment, CPU Plugin has limitation for GPR registers: there are only 12 available registers.
609+
// At the moment, CPU Plugin has limitation for GPR registers: there are 12 available GPRs,
610+
// and one of them must be reserved for runtime parameters, so only 11 can be used during kernel execution.
610611
// This limitation will be resolved once generator supports gprs spills [75622].
611612
// TODO [75567]: move this plugin-specific constraint to the plugin callback
612613
const auto unique_buffer_count = op::Subgraph::get_estimated_buffer_count(ops_for_buffer_count);
613-
if (body_parameters.size() + body_results.size() + hidden_data_count + unique_buffer_count > 12) {
614+
if (body_parameters.size() + body_results.size() + hidden_data_count + unique_buffer_count > 11) {
614615
const std::string message_reset = "new subgraph is created. Impossible to schedule subgraph with " +
615616
std::to_string(body_parameters.size()) + " inputs, " + std::to_string(body_results.size()) + " outputs and " +
616617
std::to_string(hidden_data_count) + " non-scalar constants and " + std::to_string(unique_buffer_count) + "buffers.";

src/common/snippets/src/pass/mha_tokenization.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ ov::snippets::pass::TokenizeMHASnippets::TokenizeMHASnippets(const SnippetsToken
454454

455455
// TODO [75567]: move this plugin-specific constraint to the plugin callback
456456
const auto last_node = ordered_ops.back();
457-
if (potential_body_params_count + last_node->get_output_size() + hidden_virtual_ports_count + buffer_count > 12) {
457+
if (potential_body_params_count + last_node->get_output_size() + hidden_virtual_ports_count + buffer_count > 11) {
458458
return false;
459459
}
460460

src/core/src/constant_fold_utils.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "openvino/op/convert_like.hpp"
88
#include "openvino/op/convert_promote_types.hpp"
99
#include "openvino/op/fake_convert.hpp"
10+
#include "openvino/op/random_uniform.hpp"
1011
#include "openvino/op/range.hpp"
1112
#include "openvino/op/util/assign_base.hpp"
1213
#include "openvino/op/util/multi_subgraph_base.hpp"
@@ -78,7 +79,7 @@ static bool is_node_whitelisted(const ov::Node* const node) {
7879
#define WHITELIST \
7980
ov::op::util::AssignBase, ov::op::v0::Ceiling, ov::op::v0::Constant, ov::op::v0::Convert, ov::op::v1::ConvertLike, \
8081
ov::op::v14::ConvertPromoteTypes, ov::op::v13::FakeConvert, ov::op::util::MultiSubGraphOp, \
81-
ov::op::util::ReadValueBase
82+
ov::op::v8::RandomUniform, ov::op::util::ReadValueBase
8283
// any node that is on WHITELIST does not require precision conversion
8384
return is_any_of_type<WHITELIST>(node);
8485
#undef WHITELIST

src/core/src/pass/constant_folding.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,26 @@ static bool restore_original_input_precision(const std::shared_ptr<ov::Node>& no
7474
return restored;
7575
}
7676

77+
class RequiresPrecisionConversion : public ov::RuntimeAttribute {
78+
public:
79+
OPENVINO_RTTI("requires_precision_conversion", "0");
80+
81+
bool is_copyable() const override {
82+
return false;
83+
}
84+
};
85+
7786
static void mark_node_requires_precision_conversion(const std::shared_ptr<ov::Node>& node) {
78-
node->get_rt_info()["requires_precision_conversion"] = true;
87+
node->get_rt_info()[RequiresPrecisionConversion::get_type_info_static()] = RequiresPrecisionConversion{};
7988
}
8089

8190
static bool node_has_requires_precision_conversion_attribute(const std::shared_ptr<const ov::Node>& node) {
82-
return node->get_rt_info().count("requires_precision_conversion") > 0;
91+
return node->get_rt_info().count(RequiresPrecisionConversion::get_type_info_static()) > 0;
8392
}
8493

8594
static void remove_requires_precision_conversion_attribute(const std::shared_ptr<ov::Node>& node) {
8695
auto& rt_info = node->get_rt_info();
87-
auto it = rt_info.find("requires_precision_conversion");
96+
auto it = rt_info.find(RequiresPrecisionConversion::get_type_info_static());
8897
if (it != rt_info.end()) {
8998
rt_info.erase(it);
9099
}

src/core/tests/pass/constant_folding.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -4029,6 +4029,24 @@ TEST_P(UnsupportedTypesTest, type_relaxed) {
40294029
ASSERT_EQ(m->get_results().size(), 1);
40304030
}
40314031

4032+
TEST_P(UnsupportedTypesTest, random_uniform) {
4033+
// Make sure that ConstantFolding with RandomUniform doesn't throw
4034+
const auto& type = GetParam();
4035+
auto shape = op::v0::Constant::create(element::i32, Shape{2}, {2, 3});
4036+
auto min_val = op::v0::Constant::create(type, Shape{}, {-1});
4037+
auto max_val = op::v0::Constant::create(type, Shape{}, {3});
4038+
auto random = std::make_shared<op::v8::RandomUniform>(shape, min_val, max_val, type);
4039+
auto m = make_shared<Model>(random, ParameterVector{});
4040+
4041+
EXPECT_NO_THROW(run_constant_folding(m));
4042+
4043+
EXPECT_EQ(m->get_ops().size(), 5);
4044+
// RandomUniform is not constantfolded
4045+
EXPECT_EQ(count_ops_of_type<op::v8::RandomUniform>(m), 1);
4046+
EXPECT_EQ(count_ops_of_type<op::v0::Constant>(m), 3);
4047+
ASSERT_EQ(m->get_results().size(), 1);
4048+
}
4049+
40324050
static std::string unsupported_types_test_case_name(const testing::TestParamInfo<element::Type>& info) {
40334051
return info.param.get_type_name();
40344052
}

src/frontends/pytorch/src/op/celu.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (C) 2018-2024 Intel Corporation
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
5+
#include "openvino/frontend/pytorch/node_context.hpp"
6+
#include "openvino/op/divide.hpp"
7+
#include "openvino/op/elu.hpp"
8+
#include "openvino/op/multiply.hpp"
9+
#include "utils.hpp"
10+
11+
namespace ov {
12+
namespace frontend {
13+
namespace pytorch {
14+
namespace op {
15+
16+
using namespace ov::op;
17+
18+
OutputVector translate_celu(const NodeContext& context) {
19+
// aten::celu(%x_copy.1, %self.alpha)
20+
num_inputs_check(context, 1, 2);
21+
auto x = context.get_input(0);
22+
Output<Node> alpha;
23+
if (context.input_is_none(1)) {
24+
alpha = context.mark_node(v0::Constant::create(element::f32, Shape{}, {1.}));
25+
} else {
26+
alpha = context.get_input(1);
27+
}
28+
29+
alpha = context.mark_node(std::make_shared<v1::ConvertLike>(alpha, x));
30+
auto divide_node = context.mark_node(std::make_shared<v1::Divide>(x, alpha));
31+
auto elu_node = context.mark_node(std::make_shared<v0::Elu>(divide_node, 1.));
32+
33+
auto elu = context.mark_node(std::make_shared<v1::Multiply>(alpha, elu_node));
34+
return {elu};
35+
};
36+
37+
} // namespace op
38+
} // namespace pytorch
39+
} // namespace frontend
40+
} // namespace ov

src/frontends/pytorch/src/op/elu.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,30 @@
55
#include "openvino/op/elu.hpp"
66

77
#include "openvino/frontend/pytorch/node_context.hpp"
8+
#include "openvino/op/multiply.hpp"
89
#include "utils.hpp"
910

1011
namespace ov {
1112
namespace frontend {
1213
namespace pytorch {
1314
namespace op {
1415

16+
using namespace ov::op;
17+
1518
OutputVector translate_elu(const NodeContext& context) {
1619
// aten::elu(Tensor self, Scalar alpha=1, Scalar scale=1, Scalar input_scale=1) -> Tensor
1720
num_inputs_check(context, 2, 4);
1821
auto x = context.get_input(0);
1922
auto alpha = context.const_input<float>(1);
20-
// TODO: Figure out what scale and input_scale do
21-
PYTORCH_OP_CONVERSION_CHECK(context.input_is_none(2) || context.const_input<int64_t>(2) == 1,
22-
"Unexpected value of scale input for elu operation");
23+
auto elu = context.mark_node(std::make_shared<v0::Elu>(x, alpha));
24+
if (!context.input_is_none(2)) {
25+
auto scale = context.get_input(2);
26+
scale = context.mark_node(std::make_shared<v1::ConvertLike>(scale, elu));
27+
elu = context.mark_node(std::make_shared<v1::Multiply>(elu, scale));
28+
}
2329
PYTORCH_OP_CONVERSION_CHECK(context.input_is_none(3) || context.const_input<int64_t>(3) == 1,
2430
"Unexpected value of input_scale input for elu operation");
25-
return {context.mark_node(std::make_shared<ov::op::v0::Elu>(x, alpha))};
31+
return {elu};
2632
};
2733

2834
} // namespace op

src/frontends/pytorch/src/op/pad.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ OutputVector translate_constant_pad_nd_fx(const NodeContext& context) {
126126
return translate_pad_common(context, data, paddings, pad_value);
127127
}
128128

129+
OutputVector translate_reflection_pad_nd_fx(const NodeContext& context) {
130+
num_inputs_check(context, 2, 2);
131+
auto data = context.get_input(0);
132+
auto paddings = context.const_input<std::vector<int64_t>>(1);
133+
Output<Node> pad_value = context.mark_node(v0::Constant::create(element::f32, Shape{}, {0}));
134+
return translate_pad_common(context, data, paddings, pad_value, "reflect");
135+
}
136+
129137
} // namespace op
130138
} // namespace pytorch
131139
} // namespace frontend

0 commit comments

Comments
 (0)