Skip to content

Commit

Permalink
Merge branch 'master' into workflow_metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
ababushk authored Mar 15, 2024
2 parents 419cefe + 2725fb4 commit 5e89584
Show file tree
Hide file tree
Showing 9 changed files with 574 additions and 229 deletions.
468 changes: 468 additions & 0 deletions .github/workflows/linux_sanitizers.yml

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions cmake/developer_package/compile_flags/sanitizer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,15 @@ if(DEFINED SANITIZER_COMPILER_FLAGS)
# prevent unloading libraries at runtime, so sanitizer can resolve their symbols
if(NOT OV_COMPILER_IS_APPLECLANG)
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -Wl,-z,nodelete")

if(OV_COMPILER_IS_CLANG)
if(BUILD_SHARED_LIBS)
# clang does not provide rpath if -shared-libasan is used
# https://stackoverflow.com/questions/68571138/asan-dynamic-runtime-is-missing-on-ubuntu-18, https://bugs.llvm.org/show_bug.cgi?id=51271
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS},-rpath=$(dirname $($CXX --print-file-name libclang_rt.asan-x86_64.so))")
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=lld")
endif()

# clang does not provide rpath if -shared-libasan is used
# https://stackoverflow.com/questions/68571138/asan-dynamic-runtime-is-missing-on-ubuntu-18, https://bugs.llvm.org/show_bug.cgi?id=51271
if(BUILD_SHARED_LIBS AND ENABLE_SANITIZER AND OV_COMPILER_IS_CLANG)
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS},-rpath=$(dirname $($CXX --print-file-name libclang_rt.asan-x86_64.so))")
endif()

if(OV_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=lld")
endif()
endif()
else()
Expand Down
30 changes: 29 additions & 1 deletion src/frontends/tensorflow_common/src/op/pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "openvino/op/constant.hpp"
#include "openvino/op/convert.hpp"
#include "openvino/op/gather.hpp"
#include "openvino/op/unsqueeze.hpp"
#include "utils.hpp"

using namespace std;
Expand Down Expand Up @@ -82,10 +83,37 @@ OutputVector translate_pad_op(const NodeContext& node) {
}

OutputVector translate_padv2_op(const NodeContext& node) {
default_op_checks(node, 3, {"PadV2"});
default_op_checks(node, 3, {"PadV2"}, true);
auto input = node.get_input(0);
auto paddings = node.get_input(1);
auto constant_value = node.get_input(2);
if (auto complex_type_mark = as_type_ptr<ComplexTypeMark>(input.get_node_shared_ptr())) {
input = complex_type_mark->input_value(0);
element::Type complex_part_type = complex_type_mark->get_complex_part_type();

auto gather_index_real = make_shared<v0::Constant>(element::i32, Shape{}, 0);
auto gather_index_imag = make_shared<v0::Constant>(element::i32, Shape{}, 1);
auto minus_one = make_shared<v0::Constant>(element::i32, Shape{1}, -1);
auto x_real = make_shared<v8::Gather>(input, gather_index_real, minus_one)->output(0);
auto x_imag = make_shared<v8::Gather>(input, gather_index_imag, minus_one)->output(0);

auto constant_complex_type_mark = as_type_ptr<ComplexTypeMark>(constant_value.get_node_shared_ptr());
auto constant_input = constant_complex_type_mark->input_value(0);
auto constant_value_real = make_shared<v8::Gather>(constant_input, gather_index_real, minus_one)->output(0);
auto constant_value_imag = make_shared<v8::Gather>(constant_input, gather_index_imag, minus_one)->output(0);

auto y_real = translate_pad_base_op(node, x_real, paddings, constant_value_real)[0];
auto y_imag = translate_pad_base_op(node, x_imag, paddings, constant_value_imag)[0];

auto real_unsqueeze = make_shared<v0::Unsqueeze>(y_real, minus_one);
auto imag_unsqueeze = make_shared<v0::Unsqueeze>(y_imag, minus_one);

auto concat_result = make_shared<v0::Concat>(OutputVector{real_unsqueeze, imag_unsqueeze}, -1);

set_node_name(node.get_name(), concat_result);
auto complex_result = make_shared<ComplexTypeMark>(concat_result->output(0), complex_part_type);
return {complex_result};
}

return translate_pad_base_op(node, input, paddings, constant_value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,42 @@
// SPDX-License-Identifier: Apache-2.0
//

#include <common_test_utils/data_utils.hpp>
#include <common_test_utils/ov_tensor_utils.hpp>
#include <single_layer_tests/experimental_detectron_prior_grid_generator.hpp>
#include "single_op_tests/experimental_detectron_prior_grid_generator.hpp"

namespace {
using ov::test::ExperimentalDetectronPriorGridGeneratorLayerTest;

const std::initializer_list<ov::test::subgraph::ExperimentalDetectronPriorGridGeneratorTestParam> params{
// flatten = true (output tensor is 2D)
{{true, 0, 0, 4.0f, 4.0f},
ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 4, 5}, {1, 3, 100, 200}})},
std::vector<std::vector<ov::test::InputShape>> shapes = {
ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 4, 5}, {1, 3, 100, 200}}),
ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 3, 7}, {1, 3, 100, 200}}),
// task #72587
//{
// {true, 3, 6, 64.0f, 64.0f},
// ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 100, 100}, {1, 3, 100, 200}})
//},
//// flatten = false (output tensor is 4D)
{{false, 0, 0, 8.0f, 8.0f},
ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 3, 7}, {1, 3, 100, 200}})},
// task #72587
//{
// {false, 5, 3, 32.0f, 32.0f},
// ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 100, 100}, {1, 3, 100, 200}})
//},
};

template <typename T>
std::vector<std::pair<std::string, std::vector<ov::Tensor>>> getInputTensors() {
std::vector<std::pair<std::string, std::vector<ov::Tensor>>> tensors{
{"test#1",
{ov::test::utils::create_tensor<T>(
ov::element::from<T>(),
{3, 4},
std::vector<T>{-24.5, -12.5, 24.5, 12.5, -16.5, -16.5, 16.5, 16.5, -12.5, -24.5, 12.5, 24.5})}},
{"test#2",
{ov::test::utils::create_tensor<T>(
ov::element::from<T>(),
{3, 4},
std::vector<T>{-44.5, -24.5, 44.5, 24.5, -32.5, -32.5, 32.5, 32.5, -24.5, -44.5, 24.5, 44.5})}},
{"test#3",
{ov::test::utils::create_tensor<T>(
ov::element::from<T>(),
{3, 4},
std::
vector<T>{-364.5, -184.5, 364.5, 184.5, -256.5, -256.5, 256.5, 256.5, -180.5, -360.5, 180.5, 360.5})}},
{"test#4",
{ov::test::utils::create_tensor<T>(
ov::element::from<T>(),
{3, 4},
std::vector<T>{-180.5, -88.5, 180.5, 88.5, -128.5, -128.5, 128.5, 128.5, -92.5, -184.5, 92.5, 184.5})}}};
return tensors;
}

using ov::test::subgraph::ExperimentalDetectronPriorGridGeneratorLayerTest;
std::vector<ov::op::v6::ExperimentalDetectronPriorGridGenerator::Attributes> attributes = {
// flatten = true (output tensor is 2D)
{true, 0, 0, 4.0f, 4.0f},
// flatten = false (output tensor is 4D)
{false, 0, 0, 8.0f, 8.0f},
// task #72587
// {true, 3, 6, 64.0f, 64.0f},
// {false, 5, 3, 32.0f, 32.0f},
};

INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronPriorGridGenerator_f32,
ExperimentalDetectronPriorGridGeneratorLayerTest,
testing::Combine(testing::ValuesIn(params),
testing::ValuesIn(getInputTensors<float>()),
testing::ValuesIn({ov::element::Type_t::f32}),
testing::Combine(testing::ValuesIn(shapes),
testing::ValuesIn(attributes),
testing::Values(ov::element::f32),
testing::Values(ov::test::utils::DEVICE_GPU)),
ExperimentalDetectronPriorGridGeneratorLayerTest::getTestCaseName);

INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronPriorGridGenerator_f16,
ExperimentalDetectronPriorGridGeneratorLayerTest,
testing::Combine(testing::ValuesIn(params),
testing::ValuesIn(getInputTensors<ov::float16>()),
testing::ValuesIn({ov::element::Type_t::f16}),
testing::Combine(testing::ValuesIn(shapes),
testing::ValuesIn(attributes),
testing::Values(ov::element::f16),
testing::Values(ov::test::utils::DEVICE_GPU)),
ExperimentalDetectronPriorGridGeneratorLayerTest::getTestCaseName);
} // namespace

This file was deleted.

This file was deleted.

This file was deleted.

46 changes: 46 additions & 0 deletions tests/layer_tests/tensorflow_tests/test_tf_Pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,49 @@ def test_pad_complex(self, params, ie_device, precision, ir_version, temp_dir, u
self._test(*self.create_pad_complex_net(**params),
ie_device, precision, ir_version, temp_dir=temp_dir,
use_legacy_frontend=use_legacy_frontend)


class TestComplexPadV2(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
rng = np.random.default_rng()
assert 'param_real:0' in inputs_info
assert 'param_imag:0' in inputs_info
param_real_shape = inputs_info['param_real:0']
param_imag_shape = inputs_info['param_imag:0']
inputs_data = {}
inputs_data['param_real:0'] = 4 * rng.random(param_real_shape).astype(np.float32) - 2
inputs_data['param_imag:0'] = 4 * rng.random(param_imag_shape).astype(np.float32) - 2
return inputs_data

def create_pad_complex_net(self, input_shape, pads_values, const_value):
tf.compat.v1.reset_default_graph()
# Create the graph and model
with tf.compat.v1.Session() as sess:
param_real = tf.compat.v1.placeholder(np.float32, input_shape, 'param_real')
param_imag = tf.compat.v1.placeholder(np.float32, input_shape, 'param_imag')
complex = tf.raw_ops.Complex(real=param_real, imag=param_imag)
paddings = tf.constant(pads_values, dtype=tf.int32)
real_part, imag_part = const_value
constant_values = tf.complex(real_part, imag_part)
pad = tf.raw_ops.PadV2(input=complex, paddings=paddings, constant_values=constant_values, name='padv2')
real = tf.raw_ops.Real(input=pad)
imag = tf.raw_ops.Imag(input=pad)
tf.raw_ops.Pack(values=[real, imag], axis=-1)
tf.compat.v1.global_variables_initializer()
tf_net = sess.graph_def

return tf_net, None

test_data_basic = [
dict(input_shape=[1, 50], pads_values=[[0, 1], [2, 3]], const_value=(1.0, 0.0)),
dict(input_shape=[2, 20, 10], pads_values=[[0, 1], [2, 3], [4, 0]], const_value=(0.0, 1.0)),
dict(input_shape=[1, 5, 10, 3], pads_values=[[1, 1], [0, 0], [4, 0], [1, 1]], const_value=(1.0, 2.0)),
]

@pytest.mark.parametrize("params", test_data_basic)
@pytest.mark.precommit_tf_fe
@pytest.mark.nightly
def test_pad_v2_complex(self, params, ie_device, precision, ir_version, temp_dir, use_legacy_frontend):
self._test(*self.create_pad_complex_net(**params),
ie_device, precision, ir_version, temp_dir=temp_dir,
use_legacy_frontend=use_legacy_frontend)
2 changes: 2 additions & 0 deletions tests/lsan/suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ leak:site-packages/google/protobuf
leak:thirdparty/protobuf
leak:thirdparty/protobuf/protobuf
leak:thirdparty/gtest
leak:thirdparty/tbb
leak:libtbb.so

0 comments on commit 5e89584

Please sign in to comment.