diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp index 733d785d5940b1..35dd779d6f11d9 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp @@ -293,6 +293,7 @@ static void Transformation(CNNNetwork& clonedNetwork, const Config& conf) { pass_config->disable(); pass_config->disable(); pass_config->disable(); + pass_config->disable(); pass_config->enable(); pass_config->enable(); diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_convolution.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_convolution.cpp index 09107a33cd576d..55b5cea7d72ae5 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_convolution.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/deformable_convolution.cpp @@ -25,6 +25,8 @@ const std::vector> dilations = {{1, 1}}; const std::vector groups = {1}; const std::vector defor_groups = {1}; const std::vector numOutChannels = {1}; +const std::vector with_bilinear_interpolation_pad = { false, true }; +const std::vector with_modulated_scalar = { false, true }; const auto conv2DParams_ExplicitPadding = ::testing::Combine( ::testing::ValuesIn(offsets), ::testing::ValuesIn(filters), @@ -32,7 +34,9 @@ const auto conv2DParams_ExplicitPadding = ::testing::Combine( ::testing::ValuesIn(padEnds), ::testing::ValuesIn(dilations), ::testing::ValuesIn(groups), ::testing::ValuesIn(defor_groups), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT)); + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(with_bilinear_interpolation_pad), + ::testing::ValuesIn(with_modulated_scalar)); const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(offsets), ::testing::ValuesIn(filters), ::testing::ValuesIn(strides), @@ -40,7 +44,9 @@ const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::Values(std::vector({0, 0})), ::testing::ValuesIn(dilations), ::testing::ValuesIn(groups), ::testing::ValuesIn(defor_groups), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::VALID)); + ::testing::Values(ngraph::op::PadType::VALID), + ::testing::ValuesIn(with_bilinear_interpolation_pad), + ::testing::ValuesIn(with_modulated_scalar)); INSTANTIATE_TEST_SUITE_P( smoke_DeformableConvolution2D_Serialization_ExplicitPadding, DeformableConvolutionLayerTest, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp index f83225145daa4c..437d8737d65bf7 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp @@ -1,14 +1,10 @@ // Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // - #include - #include "common_test_utils/test_constants.hpp" #include "single_layer_tests/deformable_convolution.hpp" - using namespace LayerTestsDefinitions; - namespace { const std::vector netPrecisions = { @@ -16,18 +12,21 @@ const std::vector netPrecisions = { InferenceEngine::Precision::I32, InferenceEngine::Precision::I16}; /* ============= 2D DeformableConvolution ============= */ -const std::vector> deformable_vals = {{1, 18, 28, 28}}; -const std::vector> kernels = {{1, 1, 3, 3}}; +const std::vector> deformable_vals = {{1, 16, 2, 2}}; +const std::vector> kernels = {{2, 2, 2, 2}}; const std::vector> strides = {{1, 1}}; const std::vector> padBegins = {{0, 0}}; const std::vector> padEnds ={{0, 0}}; const std::vector> dilations = {{1, 1}}; const std::vector groups = {1}; -const std::vector defor_groups = {1}; +const std::vector defor_groups = {2}; const std::vector numOutChannels = {1, 5}; const std::vector multiple_defor_groups = {4}; const std::vector> deform_vals = {{1, 200, 220, 220}}; -const std::vector> kernel = {{64, 4, 5, 5}}; +const std::vector> kernel = {{64, 16, 5, 5}}; + +const std::vector with_bilinear_interpolation_pad = { false, true }; +const std::vector with_modulated_scalar = { false, true }; const auto deformableConv2DParams_ExplicitPadding = ::testing::Combine( ::testing::ValuesIn(deformable_vals), @@ -35,7 +34,9 @@ const auto deformableConv2DParams_ExplicitPadding = ::testing::Combine( ::testing::ValuesIn(padBegins), ::testing::ValuesIn(padEnds), ::testing::ValuesIn(dilations), ::testing::ValuesIn(groups), ::testing::ValuesIn(defor_groups), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT)); + ::testing::Values(ngraph::op::PadType::EXPLICIT), ::testing::ValuesIn(with_bilinear_interpolation_pad), + ::testing::ValuesIn(with_modulated_scalar)); + const auto deformableConv2DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(deformable_vals), ::testing::ValuesIn(kernels), ::testing::ValuesIn(strides), @@ -43,7 +44,9 @@ const auto deformableConv2DParams_AutoPadValid = ::testing::Combine( ::testing::Values(std::vector({0, 0})), ::testing::ValuesIn(dilations), ::testing::ValuesIn(groups), ::testing::ValuesIn(defor_groups), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::VALID)); + ::testing::Values(ngraph::op::PadType::VALID), + ::testing::ValuesIn(with_bilinear_interpolation_pad), + ::testing::ValuesIn(with_modulated_scalar)); const auto deformableConv2DParams_DeformableGroups_AutoPadExplicit = ::testing::Combine( ::testing::ValuesIn(deform_vals), @@ -52,7 +55,9 @@ const auto deformableConv2DParams_DeformableGroups_AutoPadExplicit = ::testing:: ::testing::Values(std::vector({0, 0})), ::testing::ValuesIn(dilations), ::testing::ValuesIn(groups), ::testing::ValuesIn(multiple_defor_groups), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT)); + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(with_bilinear_interpolation_pad), + ::testing::ValuesIn(with_modulated_scalar)); INSTANTIATE_TEST_SUITE_P( smoke_DeformableConvolution2D_ExplicitPadding, DeformableConvolutionLayerTest, @@ -62,7 +67,7 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({1, 1, 30, 30})), + ::testing::Values(std::vector({1, 2, 3, 3})), ::testing::Values(CommonTestUtils::DEVICE_CPU)), DeformableConvolutionLayerTest::getTestCaseName); @@ -74,19 +79,20 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({1, 1, 30, 30})), + ::testing::Values(std::vector({1, 2, 3, 3})), ::testing::Values(CommonTestUtils::DEVICE_CPU)), DeformableConvolutionLayerTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P( smoke_DeformableConvolution2D_DeformableGroups_ExplicitPadding, DeformableConvolutionLayerTest, ::testing::Combine( - deformableConv2DParams_DeformableGroups_AutoPadExplicit, ::testing::ValuesIn(netPrecisions), + deformableConv2DParams_DeformableGroups_AutoPadExplicit, + ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({1, 4, 224, 224})), + ::testing::Values(std::vector({1, 16, 224, 224})), ::testing::Values(CommonTestUtils::DEVICE_CPU)), DeformableConvolutionLayerTest::getTestCaseName); @@ -101,12 +107,15 @@ const auto deformableConv2DParams_SingleTestCase = ::testing::Combine( ::testing::ValuesIn(padBegins), ::testing::ValuesIn(padEnds), ::testing::ValuesIn(dilations), ::testing::ValuesIn(groups), ::testing::ValuesIn(single_deform_groups), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT)); + ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::ValuesIn(with_bilinear_interpolation_pad), + ::testing::ValuesIn(with_modulated_scalar)); INSTANTIATE_TEST_SUITE_P( smoke_DeformableConvolution2D_SingleTestCase, DeformableConvolutionLayerTest, ::testing::Combine( - deformableConv2DParams_SingleTestCase, ::testing::ValuesIn(netPrecisions), + deformableConv2DParams_SingleTestCase, + ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), ::testing::Values(InferenceEngine::Layout::ANY), diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/deformable_convolution.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/deformable_convolution.hpp index bc7a614a106d45..40cf7db1f5a42a 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/deformable_convolution.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/deformable_convolution.hpp @@ -26,7 +26,9 @@ typedef std::tuple< size_t, // Groups size_t, // Deformable groups size_t, // Num out channels - ngraph::op::PadType // Padding type + ngraph::op::PadType, // Padding type + bool, // Bilinear interpolation pad + bool // Modulation > deformableConvSpecificParams; typedef std::tuple< deformableConvSpecificParams, diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/deformable_convolution.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/deformable_convolution.cpp index c902e5a9ba14fa..d8014598cbabc2 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/single_layer/deformable_convolution.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/deformable_convolution.cpp @@ -1,11 +1,9 @@ // Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // - #include "shared_test_classes/single_layer/deformable_convolution.hpp" namespace LayerTestsDefinitions { - std::string DeformableConvolutionLayerTest::getTestCaseName(testing::TestParamInfo obj) { deformableConvSpecificParams convParams; InferenceEngine::Precision netPrecision; @@ -14,12 +12,14 @@ std::string DeformableConvolutionLayerTest::getTestCaseName(testing::TestParamIn InferenceEngine::SizeVector inputShapes; std::string targetDevice; std::tie(convParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = - obj.param; + obj.param; ngraph::op::PadType padType; InferenceEngine::SizeVector offsets, filter, stride, dilation; std::vector padBegin, padEnd; size_t groups, deformable_groups, convOutChannels; - std::tie(offsets, filter, stride, padBegin, padEnd, dilation, groups, deformable_groups, convOutChannels, padType) = convParams; + bool with_bilinear_interpolation_pad, with_modulation; + std::tie(offsets, filter, stride, padBegin, padEnd, dilation, groups, deformable_groups, convOutChannels, padType, + with_bilinear_interpolation_pad, with_modulation) = convParams; std::ostringstream result; result << "IS=" << CommonTestUtils::vec2str(inputShapes) << "_"; @@ -33,6 +33,8 @@ std::string DeformableConvolutionLayerTest::getTestCaseName(testing::TestParamIn result << "DG=" << deformable_groups << "_"; result << "O=" << convOutChannels << "_"; result << "AP=" << padType << "_"; + result << "BI_PAD=" << with_bilinear_interpolation_pad << "_"; + result << "MODULATION=" << with_modulation << "_"; result << "netPRC=" << netPrecision.name() << "_"; result << "inPRC=" << inPrc.name() << "_"; result << "outPRC=" << outPrc.name() << "_"; @@ -43,29 +45,32 @@ std::string DeformableConvolutionLayerTest::getTestCaseName(testing::TestParamIn } InferenceEngine::Blob::Ptr DeformableConvolutionLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - InferenceEngine::Blob::Ptr blobPtr; - const std::string& name = info.name(); - if (name == "a_data") { - blobPtr = LayerTestsUtils::LayerTestsCommon::GenerateInput(info); - } else if (name == "b_offset_vals") { - blobPtr = FuncTestUtils::createAndFillBlobFloat(info.getTensorDesc(), 2, 0, 10); - } else if (name == "c_filter_vals") { - blobPtr = LayerTestsUtils::LayerTestsCommon::GenerateInput(info); - } - return blobPtr; + InferenceEngine::Blob::Ptr blobPtr; + const std::string& name = info.name(); + if (name == "a_data") { + blobPtr = LayerTestsUtils::LayerTestsCommon::GenerateInput(info); + } else if (name == "b_offset_vals") { + blobPtr = FuncTestUtils::createAndFillBlobFloat(info.getTensorDesc(), 2, 0, 10); + } else if (name == "c_filter_vals") { + blobPtr = LayerTestsUtils::LayerTestsCommon::GenerateInput(info); + } else if (name == "c_modulation_scalars") { + blobPtr = FuncTestUtils::createAndFillBlobFloat(info.getTensorDesc(), 1, 0, 20); + } + return blobPtr; } - void DeformableConvolutionLayerTest::SetUp() { deformableConvSpecificParams convParams; std::vector inputShape; InferenceEngine::Precision netPrecision; std::tie(convParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = - this->GetParam(); + this->GetParam(); ngraph::op::PadType padType; InferenceEngine::SizeVector offsets, filter, stride, dilation; std::vector padBegin, padEnd; size_t groups, deformable_groups, convOutChannels; - std::tie(offsets, filter, stride, padBegin, padEnd, dilation, groups, deformable_groups, convOutChannels, padType) = convParams; + bool with_bilinear_interpolation_pad, with_modulation; + std::tie(offsets, filter, stride, padBegin, padEnd, dilation, groups, deformable_groups, convOutChannels, padType, + with_bilinear_interpolation_pad, with_modulation) = convParams; auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); auto params = ngraph::builder::makeParams(ngPrc, {inputShape, offsets, filter}); auto paramOuts = ngraph::helpers::convert2OutputVector( @@ -76,9 +81,24 @@ void DeformableConvolutionLayerTest::SetUp() { offset_vals->set_friendly_name("b_offset_vals"); auto filter_vals = std::make_shared(ngPrc, ngraph::Shape(filter)); filter_vals->set_friendly_name("c_filter_vals"); - auto deformable_conv = std::make_shared(data, offset_vals, filter_vals, - stride, padBegin, padEnd, dilation, padType, groups, deformable_groups); + ngraph::ParameterVector parameters{data, offset_vals, filter_vals}; + std::shared_ptr deformable_conv; + if (with_modulation) { + auto modulation_shape = ngraph::Shape(offsets); + modulation_shape[1] = offsets[1] / 2; + auto modulation_scalars = std::make_shared(ngPrc, modulation_shape); + modulation_scalars->set_friendly_name("c_modulation_scalars"); + + deformable_conv = std::make_shared(data, offset_vals, filter_vals, modulation_scalars, stride, padBegin, + padEnd, dilation, padType, groups, deformable_groups, + with_bilinear_interpolation_pad); + parameters.push_back(modulation_scalars); + } else { + deformable_conv = std::make_shared(data, offset_vals, filter_vals, stride, padBegin, padEnd, dilation, + padType, groups, deformable_groups, with_bilinear_interpolation_pad); + } + ngraph::ResultVector results{std::make_shared(deformable_conv)}; - function = std::make_shared(results, ngraph::ParameterVector{data, offset_vals, filter_vals}, "deformable_convolution"); + function = std::make_shared(results, parameters, "deformable_convolution"); } -} // namespace LayerTestsDefinitions +} // namespace LayerTestsDefinitions \ No newline at end of file diff --git a/ngraph/core/include/ngraph/op/deformable_convolution.hpp b/ngraph/core/include/ngraph/op/deformable_convolution.hpp index da6b18c22b5530..f54243389c2371 100644 --- a/ngraph/core/include/ngraph/op/deformable_convolution.hpp +++ b/ngraph/core/include/ngraph/op/deformable_convolution.hpp @@ -160,6 +160,11 @@ namespace ngraph void validate_and_infer_types() override; + bool evaluate(const HostTensorVector& outputs, + const HostTensorVector& inputs) const override; + + bool has_evaluate() const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/deformable_convolution.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/deformable_convolution.hpp index 28f7ddc841e234..712e3724158066 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/deformable_convolution.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/deformable_convolution.hpp @@ -17,6 +17,7 @@ namespace ngraph inline void validate_deformable_convolution_params(const Shape& in_shape, const Shape& o_shape, const Shape& f_shape, + const Shape& m_shape, const Shape& out_shape, const Strides& strides, const Strides& dilations, @@ -29,6 +30,7 @@ namespace ngraph NGRAPH_CHECK(in_shape.size() == 4, "Unsupported input rank: ", in_shape); NGRAPH_CHECK(o_shape.size() == 4, "Unsupported offset rank: ", o_shape); NGRAPH_CHECK(f_shape.size() == 4, "Unsupported kernel rank: ", f_shape); + NGRAPH_CHECK(m_shape.size() == 4, "Unsupported mask rank: ", m_shape); NGRAPH_CHECK(in_shape[1] % groups == 0, "Input channels of data batch input must be evenly divisible by " @@ -53,14 +55,20 @@ namespace ngraph const Shape f_spatial_shape{std::next(f_shape.begin(), 2), std::end(f_shape)}; const Shape o_spatial_shape{std::next(o_shape.begin(), 2), std::end(o_shape)}; + const Shape m_spatial_shape{std::next(m_shape.begin(), 2), std::end(m_shape)}; const Shape out_spatial_shape{std::next(out_shape.begin(), 2), std::end(out_shape)}; NGRAPH_CHECK(o_shape[1] == deformable_groups * shape_size(f_spatial_shape) * 2, "The channels dimension of offsets input is not " "compatible with filters and 'deformable group' attribute"); + NGRAPH_CHECK(m_shape[1] == deformable_groups * shape_size(f_spatial_shape), + "The channels dimension of mask input is not " + "compatible with filters and 'deformable group' attribute"); NGRAPH_CHECK(out_spatial_shape == o_spatial_shape, "Spatial dimensions of output and offsets values must be equal"); + NGRAPH_CHECK(out_spatial_shape == m_spatial_shape, + "Spatial dimensions of output and mask values must be equal"); } inline Shape shape_reduce(const Shape& s) { return Shape(++s.begin(), s.end()); } @@ -76,20 +84,37 @@ namespace ngraph const float x_idx, const float y_idx, const int x_size, - const int y_size) + const int y_size, + const bool use_pad) { - const int x1 = std::max(static_cast(std::floor(x_idx)), 0); - const int x2 = std::min(static_cast(std::ceil(x_idx)), x_size - 1); - const int y1 = std::max(static_cast(std::floor(y_idx)), 0); - const int y2 = std::min(static_cast(std::ceil(y_idx)), y_size - 1); + const int y1 = use_pad ? static_cast(std::floor(y_idx)) + : std::max(static_cast(std::floor(y_idx)), 0); + const int x1 = use_pad ? static_cast(std::floor(x_idx)) + : std::max(static_cast(std::floor(x_idx)), 0); + + const int y2 = + use_pad ? y1 + 1 : std::min(static_cast(std::ceil(y_idx)), y_size - 1); + const int x2 = + use_pad ? x1 + 1 : std::min(static_cast(std::ceil(x_idx)), x_size - 1); const float distX = x_idx - x1; const float distY = y_idx - y1; - const float value11 = data[y1 * x_size + x1]; - const float value12 = data[y2 * x_size + x1]; - const float value21 = data[y1 * x_size + x2]; - const float value22 = data[y2 * x_size + x2]; + float value11 = 0; + if (y1 >= 0 && x1 >= 0) + value11 = data[y1 * x_size + x1]; + + float value21 = 0; + if (y1 >= 0 && x2 < x_size) + value21 = data[y1 * x_size + x2]; + + float value12 = 0; + if (y2 < y_size && x1 >= 0) + value12 = data[y2 * x_size + x1]; + + float value22 = 0; + if (y2 < y_size && x2 < x_size) + value22 = data[y2 * x_size + x2]; const float value = (1 - distX) * (1 - distY) * value11 + (1 - distX) * distY * value12 + @@ -105,10 +130,13 @@ namespace ngraph const Shape& offset_shape, const T* filter, const Shape& filter_shape, + const T* mask, + const Shape& mask_shape, T* out, size_t group_idx, int64_t groups, - int64_t deformable_groups) + int64_t deformable_groups, + bool bilinear_interpolation_pad) { const int input_size_y = batch_shape[1]; const int input_size_x = batch_shape[2]; @@ -124,6 +152,8 @@ namespace ngraph const int offsets_size = shape_size(offset_shape); const int offsets_spatial_size = shape_size(shape_reduce(offset_shape)); const int filter_channels_count = filter_shape[0]; + const int mask_size = shape_size(mask_shape); + const int mask_spatial_size = shape_size(shape_reduce(mask_shape)); int out_idx = 0; for (int i_y = -p.pads_begin[0]; @@ -146,29 +176,45 @@ namespace ngraph { for (int f_x = 0; f_x < filter_size_x; ++f_x) { - T y_offset = offsets[deformable_group_idx * offsets_size + - (f_y * filter_size_x + f_x) * 2 * - offsets_spatial_size + - out_idx]; - T x_offset = offsets[deformable_group_idx * offsets_size + - ((f_y * filter_size_x + f_x) * 2 + 1) * - offsets_spatial_size + - out_idx]; + int f_buf_idx = (f_y * filter_size_x) + f_x; + T y_offset = + offsets[deformable_group_idx * offsets_size + + f_buf_idx * 2 * offsets_spatial_size + out_idx]; + T x_offset = + offsets[deformable_group_idx * offsets_size + + (f_buf_idx * 2 + 1) * offsets_spatial_size + + out_idx]; T rel_i_y = i_y + (f_y * p.dilation[0]) + y_offset; T rel_i_x = i_x + (f_x * p.dilation[1]) + x_offset; - bool padding = !(in_range(rel_i_x, {0, input_size_x}) && - in_range(rel_i_y, {0, input_size_y})); + bool padding; + if (bilinear_interpolation_pad) + { + padding = + !((static_cast(rel_i_x) > -1 && + static_cast(rel_i_x) < input_size_x) && + (static_cast(rel_i_y) > -1 && + static_cast(rel_i_y) < input_size_y)); + } + else + { + padding = !(in_range(rel_i_x, {0, input_size_x}) && + in_range(rel_i_y, {0, input_size_y})); + } + if (padding) continue; - int f_buf_idx = (f_y * filter_size_x) + f_x; + T mask_scalar = + mask[deformable_group_idx * mask_size + + f_buf_idx * mask_spatial_size + out_idx]; sum += bilinear_interpolation(input_channel, rel_i_x, rel_i_y, input_size_x, - input_size_y) * - filter_channel[f_buf_idx]; + input_size_y, + bilinear_interpolation_pad) * + filter_channel[f_buf_idx] * mask_scalar; } } input_channel += input_channel_size; @@ -180,21 +226,25 @@ namespace ngraph } } // namespace def_conv_impl + template void deformable_convolution(const T* in, const T* offsets, const T* filters, + const T* mask, T* out, const Shape& in_shape, const Shape& o_shape, const Shape& f_shape, + const Shape& m_shape, const Shape& out_shape, const Strides& strides, const Strides& dilation, const CoordinateDiff& pads_begin, const CoordinateDiff& pads_end, const int64_t groups, - const int64_t deformable_groups) + const int64_t deformable_groups, + const bool bilinear_interpolation_pad) { using namespace def_conv_impl; @@ -202,6 +252,7 @@ namespace ngraph validate_deformable_convolution_params(in_shape, o_shape, f_shape, + m_shape, out_shape, strides, dilation, @@ -227,12 +278,17 @@ namespace ngraph const Shape group_filter_shape = shape_reduce(f_shape); const size_t group_filter_size = shape_size(group_filter_shape); + const Shape group_mask_shape = + shape_scale(shape_reduce(m_shape), deformable_groups); + const size_t group_mask_batch_size = shape_size(shape_reduce(m_shape)); + const size_t out_ch_size = shape_size(shape_reduce(shape_reduce(out_shape))); for (size_t batch_idx = 0; batch_idx < batches_count; ++batch_idx) { const T* group_filters = filters; const T* group_offsets = offsets; + const T* group_mask = mask; for (size_t group_idx = 0; group_idx < groups_count; ++group_idx) { for (size_t f_idx = 0; f_idx < group_filters_count; ++f_idx) @@ -244,18 +300,60 @@ namespace ngraph group_offset_shape, group_filters, group_filter_shape, + group_mask, + group_mask_shape, out, group_idx, groups, - deformable_groups); + deformable_groups, + bilinear_interpolation_pad); group_filters += group_filter_size; out += out_ch_size; } in += group_in_size; } offsets += group_offset_batch_size; + mask += group_mask_batch_size; } } + + template + void deformable_convolution(const T* in, + const T* offsets, + const T* filters, + T* out, + const Shape& in_shape, + const Shape& o_shape, + const Shape& f_shape, + const Shape& out_shape, + const Strides& strides, + const Strides& dilation, + const CoordinateDiff& pads_begin, + const CoordinateDiff& pads_end, + const int64_t groups, + const int64_t deformable_groups, + const bool bilinear_interpolation_pad = false) + { + Shape m_shape = {o_shape[0], o_shape[1] / 2, o_shape[2], o_shape[3]}; + std::vector mask(ngraph::shape_size(m_shape), 1); + deformable_convolution(in, + offsets, + filters, + mask.data(), + out, + in_shape, + o_shape, + f_shape, + m_shape, + out_shape, + strides, + dilation, + pads_begin, + pads_end, + groups, + deformable_groups, + bilinear_interpolation_pad); + } } // namespace reference } // namespace runtime } // namespace ngraph diff --git a/ngraph/core/src/op/deformable_convolution.cpp b/ngraph/core/src/op/deformable_convolution.cpp index 0c33971ce508dd..845005622d710d 100644 --- a/ngraph/core/src/op/deformable_convolution.cpp +++ b/ngraph/core/src/op/deformable_convolution.cpp @@ -6,6 +6,7 @@ #include "itt.hpp" #include "ngraph/axis_vector.hpp" #include "ngraph/coordinate_diff.hpp" +#include "ngraph/runtime/reference/deformable_convolution.hpp" #include "ngraph/util.hpp" #include "ngraph/validation_util.hpp" @@ -195,6 +196,162 @@ std::shared_ptr } } +namespace deformable_convolution +{ + template + inline bool evaluate(const HostTensorVector& inputs, + const HostTensorPtr& out, + const Strides& strides, + const CoordinateDiff& pads_begin, + const CoordinateDiff& pads_end, + const Strides& dilations, + const ngraph::op::PadType& auto_pad, + const int64_t group, + const int64_t deformable_group, + const bool use_bilinear_interpolation_padding) + { + using T = typename element_type_traits::value_type; + if (inputs.size() == 3) + { + runtime::reference::deformable_convolution(inputs[0]->get_data_ptr(), + inputs[1]->get_data_ptr(), + inputs[2]->get_data_ptr(), + out->get_data_ptr(), + inputs[0]->get_shape(), + inputs[1]->get_shape(), + inputs[2]->get_shape(), + out->get_shape(), + strides, + dilations, + pads_begin, + pads_end, + group, + deformable_group, + use_bilinear_interpolation_padding); + } + else if (inputs.size() == 4) + { + runtime::reference::deformable_convolution(inputs[0]->get_data_ptr(), + inputs[1]->get_data_ptr(), + inputs[2]->get_data_ptr(), + inputs[3]->get_data_ptr(), + out->get_data_ptr(), + inputs[0]->get_shape(), + inputs[1]->get_shape(), + inputs[2]->get_shape(), + inputs[3]->get_shape(), + out->get_shape(), + strides, + dilations, + pads_begin, + pads_end, + group, + deformable_group, + use_bilinear_interpolation_padding); + } + + return true; + } + + bool evaluate_deformable_convolution(const HostTensorVector& inputs, + const HostTensorPtr& out, + const Strides& strides, + const Strides& dilations, + const CoordinateDiff& pads_begin, + const CoordinateDiff& pads_end, + const ngraph::op::PadType& auto_pad, + const int64_t group, + const int64_t deformable_group, + const bool use_bilinear_interpolation_padding) + { + bool rc = true; + switch (inputs[0]->get_element_type()) + { + NGRAPH_TYPE_CASE(evaluate_deformable_convolution, + f32, + inputs, + out, + strides, + pads_begin, + pads_end, + dilations, + auto_pad, + group, + deformable_group, + use_bilinear_interpolation_padding); + NGRAPH_TYPE_CASE(evaluate_deformable_convolution, + f16, + inputs, + out, + strides, + pads_begin, + pads_end, + dilations, + auto_pad, + group, + deformable_group, + use_bilinear_interpolation_padding); + NGRAPH_TYPE_CASE(evaluate_deformable_convolution, + i32, + inputs, + out, + strides, + pads_begin, + pads_end, + dilations, + auto_pad, + group, + deformable_group, + use_bilinear_interpolation_padding); + NGRAPH_TYPE_CASE(evaluate_deformable_convolution, + i16, + inputs, + out, + strides, + pads_begin, + pads_end, + dilations, + auto_pad, + group, + deformable_group, + use_bilinear_interpolation_padding); + default: rc = false; break; + } + return rc; + } +} // namespace deformable_convolution + +bool op::v8::DeformableConvolution::evaluate(const HostTensorVector& outputs, + const HostTensorVector& inputs) const +{ + NGRAPH_OP_SCOPE(DeformableConvolution_v8_evaluate); + deformable_convolution::evaluate_deformable_convolution(inputs, + outputs[0], + get_strides(), + get_dilations(), + get_pads_begin(), + get_pads_end(), + get_auto_pad(), + get_group(), + get_deformable_group(), + get_bilinear_interpolation_pad()); + return true; +} + +bool op::v8::DeformableConvolution::has_evaluate() const +{ + NGRAPH_OP_SCOPE(DeformableConvolution_v8_has_evaluate); + switch (get_input_element_type(0)) + { + case ngraph::element::f16: + case ngraph::element::i16: + case ngraph::element::i32: + case ngraph::element::f32: return true; + default: break; + } + return false; +} + op::v1::DeformableConvolution::DeformableConvolution(const Output& arg, const Output& offsets, const Output& filters, diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 63fa6d2fb0a9d9..19414c0059fb9a 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -404,6 +404,7 @@ set(MULTI_TEST_SRC backend/dft.in.cpp backend/divide.in.cpp backend/deformable_convolution.in.cpp + backend/deformable_convolution_opset8.in.cpp backend/depth_to_space.in.cpp backend/dyn_reshape.in.cpp backend/experimental_detectron_generate_proposals.in.cpp diff --git a/ngraph/test/backend/deformable_convolution_opset8.in.cpp b/ngraph/test/backend/deformable_convolution_opset8.in.cpp new file mode 100644 index 00000000000000..15f8d0370fe6f2 --- /dev/null +++ b/ngraph/test/backend/deformable_convolution_opset8.in.cpp @@ -0,0 +1,2940 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "ngraph/runtime/tensor.hpp" +#include "runtime/backend.hpp" +#include "util/all_close.hpp" +#include "util/all_close_f.hpp" +#include "util/engine/test_engines.hpp" +#include "util/known_element_types.hpp" +#include "util/ndarray.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" +#include "util/test_tools.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +static void DeformableConvolutionOpset8Test(const std::vector& inputs, + const Shape inputs_shape, + const std::vector& offsets, + const Shape offsets_shape, + const std::vector& filter, + const Shape filter_shape, + const std::vector& outputs, + const Shape outputs_shape, + const Strides& strides, + const CoordinateDiff& padding, + const Strides& dilations, + const int64_t group = 1, + const int64_t deformable_group = 1, + const size_t tolerance_bits = 2, + const bool use_bilinear_interpolation_padding = false) +{ + const CoordinateDiff pads_begin{padding}; + const CoordinateDiff pads_end{padding}; + const op::PadType auto_pad{op::PadType::EXPLICIT}; + auto inputs_param = make_shared(element::f32, inputs_shape); + auto offsets_param = make_shared(element::f32, offsets_shape); + auto filter_param = make_shared(element::f32, filter_shape); + auto conv = make_shared(inputs_param, + offsets_param, + filter_param, + strides, + pads_begin, + pads_end, + dilations, + auto_pad, + group, + deformable_group, + use_bilinear_interpolation_padding); + auto f = + make_shared(conv, ParameterVector{inputs_param, offsets_param, filter_param}); + auto test_case = test::TestCase(f); + test_case.add_input(inputs); + test_case.add_input(offsets); + test_case.add_input(filter); + test_case.add_expected_output(outputs_shape, outputs); + test_case.run(tolerance_bits); +} + +static void DeformableConvolutionOpset8Test(const std::vector& inputs, + const Shape inputs_shape, + const std::vector& offsets, + const Shape offsets_shape, + const std::vector& filter, + const Shape filter_shape, + const std::vector& mask, + const Shape mask_shape, + const std::vector& outputs, + const Shape outputs_shape, + const Strides& strides, + const CoordinateDiff& padding, + const Strides& dilations, + const int64_t group = 1, + const int64_t deformable_group = 1, + const size_t tolerance_bits = 2, + const bool use_bilinear_interpolation_padding = false) +{ + const CoordinateDiff pads_begin{padding}; + const CoordinateDiff pads_end{padding}; + const op::PadType auto_pad{op::PadType::EXPLICIT}; + auto inputs_param = make_shared(element::f32, inputs_shape); + auto offsets_param = make_shared(element::f32, offsets_shape); + auto filter_param = make_shared(element::f32, filter_shape); + auto mask_param = make_shared(element::f32, mask_shape); + auto conv = make_shared(inputs_param, + offsets_param, + filter_param, + mask_param, + strides, + pads_begin, + pads_end, + dilations, + auto_pad, + group, + deformable_group, + use_bilinear_interpolation_padding); + auto f = + make_shared(conv, ParameterVector{inputs_param, offsets_param, filter_param, mask_param}); + auto test_case = test::TestCase(f); + test_case.add_input(inputs); + test_case.add_input(offsets); + test_case.add_input(filter); + test_case.add_input(mask); + test_case.add_expected_output(outputs_shape, outputs); + test_case.run(tolerance_bits); +} +// clang-format off + +// regular convolution attributes (zeroed offsets) +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_default) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{1, 1, 4, 4}; + const std::vector inputs{1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f}; + + const Shape filter_shape{1, 1, 2, 2}; + const std::vector filter{1.0f, 2.0f, + -1.0f, -2.0f}; + + const Shape offsets_shape{1, 8, 3, 3}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 1, 3, 3}; + const std::vector outputs{-12.0f, -12.0f, -12.0f, + -12.0f, -12.0f, -12.0f, + -12.0f, -12.0f, -12.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_padding) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{1, 1}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{1, 1, 3, 3}; + const std::vector inputs{1.0f, 3.0f, 5.0f, + 7.0f, 5.0f, 3.0f, + 1.0f, 3.0f, 5.0f}; + + const Shape filter_shape{1, 1, 2, 2}; + const std::vector filter{1.0f, 2.0f, + 0.0f, 1.0f}; + + const Shape offsets_shape{1, 8, 4, 4}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 1, 4, 4}; + const std::vector outputs{1.0f, 3.0f, 5.0f, 0.0f, + 9.0f, 12.0f, 16.0f, 5.0f, + 15.0f, 20.0f, 16.0f, 3.0f, + 2.0f, 7.0f, 13.0f, 5.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_stride) +{ + const Strides strides{2, 2}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{1, 1, 5, 5}; + const std::vector inputs{1.0f, 3.0f, 5.0f, 7.0f, 9.0f, + 7.0f, 5.0f, 3.0f, 1.0f, 0.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filter{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 1.0f, + 3.0f, 2.0f, 1.0f}; + + const Shape offsets_shape{1, 18, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 1, 2, 2}; + const std::vector outputs{57.0f, 94.0f, + 66.0f, 102.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_dilation) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{2, 2}; + + const Shape inputs_shape{1, 1, 7, 7}; + const std::vector inputs{1.0f, 3.0f, 5.0f, 7.0f, 9.0f, 11.0f, 13.0f, + 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, + 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filter{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 0.0f, + 3.0f, 1.0f, 2.0f}; + + const Shape offsets_shape{1, 18, 3, 3}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 1, 3, 3}; + const std::vector outputs{78.0f, 106.0f, 134.0f, + 44.0f, 16.0f, -12.0f, + 80.0f, 84.0f, 88.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_padding_strides_dilation) +{ + const Strides strides{2, 2}; + const CoordinateDiff padding{2, 2}; + const Strides dilations{2, 2}; + + const Shape inputs_shape{1, 1, 7, 7}; + const std::vector inputs{1.0f, 3.0f, 5.0f, 7.0f, 9.0f, 11.0f, 13.0f, + 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, + 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filter{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 0.0f, + 3.0f, 1.0f, 2.0f}; + + const Shape offsets_shape{1, 18, 4, 4}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 1, 4, 4}; + const std::vector outputs{15.0f, 38.0f, 70.0f, 66.0f, + 33.0f, 78.0f, 134.0f, 103.0f, + 40.0f, 80.0f, 88.0f, 58.0f, + 30.0f, 56.0f, 72.0f, 34.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_input_channels) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{1, 2, 4, 4}; + const std::vector inputs{ + // channel 1 + 1.0f, 3.0f, 5.0f, 7.0f, + 7.0f, 5.0f, 3.0f, 1.0f, + 2.0f, 4.0f, 6.0f, 8.0f, + 8.0f, 6.0f, 4.0f, 2.0f, + // channel 2 + -1.0f, 3.0f, -5.0f, 7.0f, + 7.0f, -5.0f, 3.0f, -1.0f, + -2.0f, 4.0f, -6.0f, 8.0f, + 8.0f, -6.0f, 4.0f, -2.0f}; + + const Shape filter_shape{1, 2, 3, 3}; + const std::vector filter{ + // channel 1 + 5.0f, 3.0f, 5.0f, + 1.0f, 3.0f, 1.0f, + 4.0f, 2.0f, 4.0f, + // channel 2 + -5.0f, 3.0f, 5.0f, + 1.0f, -3.0f, 1.0f, + 4.0f, 2.0f, -4.0f}; + + const Shape offsets_shape{1, 18, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 1, 2, 2}; + const std::vector outputs{142.0f, 102.0f, + 94.0f, 160.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_output_channels) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{1, 1, 4, 4}; + const std::vector inputs{ + 1.0f, 3.0f, 5.0f, 7.0f, + 7.0f, 5.0f, 3.0f, 1.0f, + 2.0f, 4.0f, 6.0f, 8.0f, + 8.0f, 6.0f, 4.0f, 2.0f}; + + const Shape filter_shape{2, 1, 3, 3}; + const std::vector filter{ + // channel 1 + 5.0f, 3.0f, 5.0f, + 1.0f, 3.0f, 1.0f, + 4.0f, 2.0f, 4.0f, + // channel 2 + -5.0f, 3.0f, 5.0f, + 1.0f, -3.0f, 1.0f, + 4.0f, 2.0f, -4.0f}; + + const Shape offsets_shape{1, 18, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 2, 2, 2}; + const std::vector outputs{ + // channel 1 + 104.0f, 140.0f, + 145.0f, 109.0f, + // channel 2 + 16.0f, 28.0f, + 19.0f, 7.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_batch) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{2, 1, 4, 4}; + const std::vector inputs{ + // batch 1 + 1.0f, 3.0f, 2.0f, 1.0f, + 1.0f, 3.0f, 3.0f, 1.0f, + 2.0f, 1.0f, 1.0f, 3.0f, + 3.0f, 2.0f, 3.0f, 3.0f, + // batch 2 + -1.0f, 3.0f, 2.0f, -1.0f, + 1.0f, 3.0f, -3.0f, 1.0f, + -2.0f, -1.0f, 1.0f, 3.0f, + 3.0f, 2.0f, 3.0f, -3.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filter{-5.0f, 3.0f, 5.0f, + 1.0f, -3.0f, 1.0f, + 4.0f, 2.0f, -4.0f}; + + const Shape offsets_shape{2, 18, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{2, 1, 2, 2}; + const std::vector outputs{ + // batch 1 + 15.0f, -15.0f, + 23.0f, 2.0f, + // batch 2 + -1.0f, -15.0f, + -5.0f, 6.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +// group & deformable_group attributes (zeroed offsets) +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_groups_basic) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 2; + + const Shape inputs_shape{1, 4, 3, 3}; + const std::vector inputs{ // channel 1 + 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + // channel 2 + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f, + // channel 3 + 19.0f, 20.0f, 21.0f, + 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, + // channel 4 + 28.0f, 29.0f, 30.0f, + 31.0f, 32.0f, 33.0f, + 34.0f, 35.0f, 36.0f}; + + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filter{ // filter 1 channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // filter 1 channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // filter 2 channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // filter 2 channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f}; + + const Shape offsets_shape{1, 8, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 2, 2, 2}; + const std::vector outputs{ // channel 1 + 356.0f, 392.0f, + 464.0f, 500.0f, + // channel 2 + -1004.0f, -1040.0f, + -1112.0f, -1148.0f}; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape, strides, padding, dilations, group); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_groups_complex) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 4; + + const Shape inputs_shape{1, 8, 3, 3}; + const std::vector inputs{ // channel 1 + 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + // channel 2 + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f, + // channel 3 + 19.0f, 20.0f, 21.0f, + 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, + // channel 4 + 28.0f, 29.0f, 30.0f, + 31.0f, 32.0f, 33.0f, + 34.0f, 35.0f, 36.0f, + // channel 5 + 37.0f, 38.0f, 39.0f, + 40.0f, 41.0f, 42.0f, + 43.0f, 44.0f, 45.0f, + // channel 6 + 46.0f, 47.0f, 48.0f, + 49.0f, 50.0f, 51.0f, + 52.0f, 53.0f, 54.0f, + // channel 7 + 55.0f, 56.0f, 57.0f, + 58.0f, 59.0f, 60.0f, + 61.0f, 62.0f, 63.0f, + // channel 8 + 64.0f, 65.0f, 66.0f, + 67.0f, 68.0f, 69.0f, + 70.0f, 71.0f, 72.0f,}; + + const Shape filter_shape{4, 2, 2, 2}; + const std::vector filter{ // filter 1 channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // filter 1 channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // filter 2 channel 1 + 9.0f, 10.0f, + 11.0f, 12.0f, + // filter 2 channel 2 + 13.0f, 14.0f, + 15.0f, 16.0f, + // filter 3 channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // filter 3 channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f, + // filter 4 channel 1 + -9.0f, -10.0f, + -11.0f, -12.0f, + // filter 4 channel 2 + -13.0f, -14.0f, + -15.0f, -16.0f}; + + const Shape offsets_shape{1, 8, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 4, 2, 2}; + const std::vector outputs{ // channel 1 + 356.0f, 392.0f, + 464.0f, 500.0f, + // channel 2 + 2636.0f, 2736.0f, + 2936.0f, 3036.0f, + // channel 3 + -1652.0f, -1688.0f, + -1760.0f, -1796.0f, + // channel 4 + -6236.0f, -6336.0f, + -6536.0f, -6636.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape, strides, padding, dilations, group); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_deforgroup) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 1; + + const Shape inputs_shape{1, 2, 4, 4}; + const std::vector inputs{// channel 1 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + // channel 2 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f}; + + const Shape filter_shape{1, 2, 2, 2}; + const std::vector filter{// channel 1 + 1.0f, 2.0f, + -1.0f, -2.0f, + // channel 2 + 3.0f, 4.0f, + -3.0f, -4.0f}; + + const Shape offsets_shape{1, 8, 3, 3}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 1, 3, 3}; + const std::vector outputs{-40.0f, -40.0f, -40.0f, + -40.0f, -40.0f, -40.0f, + -40.0f, -40.0f, -40.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_zeroed_offsets_groups_and_deforgroups) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 2; + const int64_t deformable_group = 2; + + const Shape inputs_shape{1, 4, 3, 3}; + const std::vector inputs{1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f, + 19.0f, 20.0f, 21.0f, + 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, + 28.0f, 29.0f, 30.0f, + 31.0f, 32.0f, 33.0f, + 34.0f, 35.0f, 36.0f}; + + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filter{1.0f, 2.0f, + 3.0f, 4.0f, + 5.0f, 6.0f, + 7.0f, 8.0f, + -1.0f, -2.0f, + -3.0f, -4.0f, + -5.0f, -6.0f, + -7.0f, -8.0f, + }; + + const Shape offsets_shape{1, 16, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 2, 2, 2}; + const std::vector outputs{356.0f, 392.0f, + 464.0f, 500.0f, + -1004.0f, -1040.0f, + -1112.0f, -1148.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape, strides, padding, + dilations, group, deformable_group); +} + +// deformable convolution atrributes (integral offsets) +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_default) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{1, 1, 4, 4}; + const std::vector inputs{1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f}; + + const Shape filter_shape{1, 1, 2, 2}; + const std::vector filter{1.0f, 2.0f, + -1.0f, -2.0f}; + + const Shape offsets_shape{1, 8, 3, 3}; + const std::vector offsets{// window 1 (Y=0, X=0) -> Y coordinate + 1.0f, 1.0f, 1.0f, // out1 .. out 3 + 1.0f, 1.0f, 1.0f, // out4 .. out 6 + 1.0f, 1.0f, 1.0f, // out7 .. out 9 + // window 1 (Y=0, X=0) -> X coordinate + 1.0f, 1.0f, 1.0f, // out1 .. out 3 + 1.0f, 1.0f, 1.0f, // out4 .. out 6 + 1.0f, 1.0f, 1.0f, // out7 .. out 9 + // window 2 + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + // window 2 + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + // window 3 + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + // window 3 + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + // window 4 + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + // window 4 + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + }; + + const Shape outputs_shape{1, 1, 3, 3}; + const std::vector outputs{-12.0f, -12.0f, -4.0f, + -12.0f, -12.0f, -4.0f, + 44.0f, 47.0f, 16.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_padding) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{1, 1}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{1, 1, 4, 4}; + const std::vector inputs{1.0f, 3.0f, 7.0f, 7.0f, + 7.0f, 6.0f, 3.0f, 1.0f, + 4.0f, 4.0f, 2.0f, 8.0f, + 1.0f, 1.0f, 1.0f, 2.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filter{1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 3.0f, 2.0f, 1.0f}; + + const Shape offsets_shape{1, 18, 4, 4}; + const std::vector offsets{1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f}; + + const Shape outputs_shape{1, 1, 4, 4}; + const std::vector outputs{56.0f, 39.0f, 44.0f, 18.0f, + 38.0f, 56.0f, 65.0f, 0.0f, + 19.0f, 38.0f, 20.0f, 20.0f, + 6.0f, 19.0f, 33.0f, 0.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_stride) +{ + const Strides strides{2, 2}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{1, 1, 5, 5}; + const std::vector inputs{1.0f, 3.0f, 5.0f, 7.0f, 9.0f, + 7.0f, 5.0f, 3.0f, 1.0f, 0.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filter{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 1.0f, + 3.0f, 2.0f, 1.0f}; + + const Shape offsets_shape{1, 18, 2, 2}; + const std::vector offsets{0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f, + 0.0f, 2.0f, + 1.0f, 0.0f}; + + const Shape outputs_shape{1, 1, 2, 2}; + const std::vector outputs{57.0f, 40.0f, + 38.0f, 102.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_dilation) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{2, 2}; + + const Shape inputs_shape{1, 1, 7, 7}; + const std::vector inputs{1.0f, 3.0f, 5.0f, 7.0f, 9.0f, 11.0f, 13.0f, + 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, + 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filter{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 0.0f, + 3.0f, 1.0f, 2.0f}; + + const Shape offsets_shape{1, 18, 3, 3}; + const std::vector offsets{1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f, + 1.0f, 2.0f, 0.0f, + 0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 1.0f}; + + const Shape outputs_shape{1, 1, 3, 3}; + const std::vector outputs{16.0f, -2.0f, 134.0f, + 44.0f, -4.0f, -12.0f, + 10.0f, 84.0f, -4.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_padding_stride_dilation) +{ + const Strides strides{2, 2}; + const CoordinateDiff padding{2, 2}; + const Strides dilations{2, 2}; + + const Shape inputs_shape{1, 1, 7, 7}; + const std::vector inputs{1.0f, 3.0f, 5.0f, 7.0f, 9.0f, 11.0f, 13.0f, + 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, + 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filter{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 0.0f, + 3.0f, 1.0f, 2.0f}; + + const Shape offsets_shape{1, 18, 4, 4}; + const std::vector offsets{1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 2.0f}; + + const Shape outputs_shape{1, 1, 4, 4}; + const std::vector outputs{15.0f, 38.0f, 2.0f, 66.0f, + 26.0f, 78.0f, 134.0f, 16.0f, + 23.0f, 80.0f, -4.0f, 58.0f, + 13.0f, 56.0f, 72.0f, -4.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_input_channels) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{1, 2, 4, 4}; + const std::vector inputs{ + // channel 1 + 1.0f, 3.0f, 5.0f, 7.0f, + 7.0f, 5.0f, 3.0f, 1.0f, + 2.0f, 4.0f, 6.0f, 8.0f, + 8.0f, 6.0f, 4.0f, 2.0f, + // channel 2 + -1.0f, 3.0f, -5.0f, 7.0f, + 7.0f, -5.0f, 3.0f, -1.0f, + -2.0f, 4.0f, -6.0f, 8.0f, + 8.0f, -6.0f, 4.0f, -2.0f}; + + const Shape filter_shape{1, 2, 3, 3}; + const std::vector filter{ + // channel 1 + 5.0f, 3.0f, 5.0f, + 1.0f, 3.0f, 1.0f, + 4.0f, 2.0f, 4.0f, + // channel 2 + -5.0f, 3.0f, 5.0f, + 1.0f, -3.0f, 1.0f, + 4.0f, 2.0f, -4.0f}; + + const Shape offsets_shape{1, 18, 2, 2}; + const std::vector offsets{1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f, + 1.0f, 1.0f, + 0.0f, 2.0f}; + + const Shape outputs_shape{1, 1, 2, 2}; + const std::vector outputs{160.0f, 32.0f, + 94.0f, 20.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_output_channels) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{1, 1, 4, 4}; + const std::vector inputs{1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f}; + + const Shape filter_shape{2, 1, 2, 2}; + const std::vector filter{ // filter 1 + 1.0f, 2.0f, + -1.0f, -2.0f, + // filter 2 + 3.0f, 4.0f, + -3.0f, -4.0f}; + + const Shape offsets_shape{1, 8, 3, 3}; + const std::vector offsets{//channel 1: Y offsets + 1.0f, 1.0f, 1.0f, // out1 .. out 3 + 1.0f, 1.0f, 1.0f, // out4 .. out 6 + 1.0f, 1.0f, 1.0f, // out7 .. out 9 + //channel 1: X offsets + 1.0f, 1.0f, 1.0f, // out1 .. out 3 + 1.0f, 1.0f, 1.0f, // out4 .. out 6 + 1.0f, 1.0f, 1.0f, // out7 .. out 9 + //channel 2: Y offsets + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + //channel 2: X offsets + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + //channel 3: Y offsets + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + //channel 3: X offsets + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + //channel 4: Y offsets + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + //channel 4: X offsets + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + }; + + const Shape outputs_shape{1, 2, 3, 3}; + const std::vector outputs{ + // output 1 + -12.0f, -12.0f, -4.0f, + -12.0f, -12.0f, -4.0f, + 44.0f, 47.0f, 16.0f, + // output 2 + -28.0f, -28.0f, -12.0f, + -28.0f, -28.0f, -12.0f, + 102.0f, 109.0f, 48.0f, }; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_batch) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{2, 1, 4, 4}; + const std::vector inputs{//batch 1 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + //batch 2 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f}; + + const Shape filter_shape{1, 1, 2, 2}; + const std::vector filter{1.0f, 2.0f, + -1.0f, -2.0f}; + + const Shape offsets_shape{2, 8, 3, 3}; + const std::vector offsets{// batch1 + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + // batch2 + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + }; + + const Shape outputs_shape{2, 1, 3, 3}; + const std::vector outputs{// batch 1 + -12.0f, -12.0f, -4.0f, + -12.0f, -12.0f, -4.0f, + 44.0f, 47.0f, 16.0f, + // batch 2 + -12.0f, -12.0f, -12.0f, + -12.0f, -12.0f, -12.0f, + -12.0f, -12.0f, -12.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, dilations); +} +// group & deformable_group attributes (integral offsets) +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_groups_basic) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 2; + + const Shape inputs_shape{1, 4, 3, 3}; + const std::vector inputs{ // channel 1 + 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + // channel 2 + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f, + // channel 3 + 19.0f, 20.0f, 21.0f, + 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, + // channel 4 + 28.0f, 29.0f, 30.0f, + 31.0f, 32.0f, 33.0f, + 34.0f, 35.0f, 36.0f}; + + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filter{ // filter 1 channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // filter 1 channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // filter 2 channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // filter 2 channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f}; + + const Shape offsets_shape{1, 8, 2, 2}; + const std::vector offsets { + // window 1 (F_Y=0, F_X=0) -> I_Y coordinate + 1.0f, 0.0f, 2.0f, 1.0f, // out1 .. out 4 + // window 1 (F_Y=0, F_X=0) -> I_X coordinate + 0.0f, 1.0f, 1.0f, 2.0f, // out1 .. out 4 + // window 2 (F_Y=0, F_X=1) -> I_Y coordinate + 1.0f, 1.0f, 1.0f, 1.0f, // out1 .. out 4 + // window 2 (F_Y=0, F_X=1) -> I_X coordinate + 1.0f, 1.0f, 1.0f, 1.0f, // out1 .. out 4 + // window 3 (F_Y=1, F_X=0) -> I_Y coordinate + 2.0f, 2.0f, 2.0f, 2.0f, // out1 .. out 4 + // window 3 (F_Y=1, F_X=0) -> I_X coordinate + 2.0f, 2.0f, 2.0f, 2.0f, // out1 .. out 4 + // window 4 (F_Y=1, F_X=1) -> I_Y coordinate + 2.0f, 2.0f, 2.0f, 2.0f, // out1 .. out 4 + // window 4 (F_Y=1, F_X=1) -> I_X coordinate + 2.0f, 2.0f, 2.0f, 2.0f}; // out1 .. out 4 + + const Shape outputs_shape{1, 2, 2, 2}; + const std::vector outputs{ // channel 1 + 171.0f, 63.0f, + 126.0f, 0.0f, + // channel 2 + -423.0f, -171.0f, + -270.0f, 0.0f}; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape, strides, padding, dilations, group); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_groups_complex) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 4; + + const Shape inputs_shape{1, 8, 3, 3}; + const std::vector inputs{ // channel 1 + 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + // channel 2 + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f, + // channel 3 + 19.0f, 20.0f, 21.0f, + 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, + // channel 4 + 28.0f, 29.0f, 30.0f, + 31.0f, 32.0f, 33.0f, + 34.0f, 35.0f, 36.0f, + // channel 5 + 37.0f, 38.0f, 39.0f, + 40.0f, 41.0f, 42.0f, + 43.0f, 44.0f, 45.0f, + // channel 6 + 46.0f, 47.0f, 48.0f, + 49.0f, 50.0f, 51.0f, + 52.0f, 53.0f, 54.0f, + // channel 7 + 55.0f, 56.0f, 57.0f, + 58.0f, 59.0f, 60.0f, + 61.0f, 62.0f, 63.0f, + // channel 8 + 64.0f, 65.0f, 66.0f, + 67.0f, 68.0f, 69.0f, + 70.0f, 71.0f, 72.0f,}; + + const Shape filter_shape{4, 2, 2, 2}; + const std::vector filter{ // filter 1 channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // filter 1 channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // filter 2 channel 1 + 9.0f, 10.0f, + 11.0f, 12.0f, + // filter 2 channel 2 + 13.0f, 14.0f, + 15.0f, 16.0f, + // filter 3 channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // filter 3 channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f, + // filter 4 channel 1 + -9.0f, -10.0f, + -11.0f, -12.0f, + // filter 4 channel 2 + -13.0f, -14.0f, + -15.0f, -16.0f}; + + const Shape offsets_shape{1, 8, 2, 2}; + const std::vector offsets {1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f}; + + const Shape outputs_shape{1, 4, 2, 2}; + const std::vector outputs{ // channel 1 + 500.0f, 234.0f, + 219.0f, 99.0f, + // channel 2 + 3036.0f, 1482.0f, + 1463.0f, 711.0f, + // channel 3 + -1796.0f, -810.0f, + -723.0f, -315.0f, + // channel 4 + -6636.0f, -3210.0f, + -3119.0f, -1503.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape, strides, padding, dilations, group); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_deforgroup_basic) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 2; + + const Shape inputs_shape{1, 2, 4, 4}; + const std::vector inputs{// channel 1 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + // channel 2 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f}; + + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filter{// f1: channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // f1: channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // f2: channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // f2: channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f}; + + const Shape offsets_shape{1, 16, 3, 3}; + const std::vector offsets{// defgroup 1 + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + // defgroup 2 + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + }; + + const Shape outputs_shape{1, 2, 3, 3}; + const std::vector outputs{// output 1 + 610.0f, 646.0f, 612.0f, + 754.0f, 790.0f, 732.0f, + 768.0f, 797.0f, 792.0f, + // output 2 + -610.0f, -646.0f, -612.0f, + -754.0f, -790.0f, -732.0f, + -768.0f, -797.0f, -792.0f, + }; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_deforgroup_complex1) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 4; + + const Shape inputs_shape{1, 4, 4, 4}; + const std::vector inputs{// channel 1 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + // channel 2 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f, + // channel 3 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + // channel 4 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f}; + + const Shape filter_shape{2, 4, 2, 2}; + const std::vector filter{// f1: channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // f1: channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // f1: channel 3 + 1.0f, 2.0f, + 3.0f, 4.0f, + // f1: channel 4 + 5.0f, 6.0f, + 7.0f, 8.0f, + // f2: channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // f2: channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f, + // f2: channel 3 + -1.0f, -2.0f, + -3.0f, -4.0f, + // f2: channel 4 + -5.0f, -6.0f, + -7.0f, -8.0f}; + + const Shape offsets_shape{1, 32, 3, 3}; + const std::vector offsets{// defgroup 1 + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + // defgroup 2 + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + // defgroup 3 + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + // defgroup 4 + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + }; + + const Shape outputs_shape{1, 2, 3, 3}; + const std::vector outputs{// output 1 + 1220.0f, 1292.0f, 1224.0f, + 1508.0f, 1580.0f, 1464.0f, + 1536.0f, 1594.0f, 1584.0f, + // output 2 + -1220.0f, -1292.0f, -1224.0f, + -1508.0f, -1580.0f, -1464.0f, + -1536.0f, -1594.0f, -1584.0f, + }; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_deforgroup_complex2) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 2; + + const Shape inputs_shape{1, 4, 4, 4}; + const std::vector inputs{// channel 1 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + // channel 2 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f, + // channel 3 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + // channel 4 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f}; + + const Shape filter_shape{2, 4, 2, 2}; + const std::vector filter{// f1: channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // f1: channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // f1: channel 3 + 1.0f, 2.0f, + 3.0f, 4.0f, + // f1: channel 4 + 5.0f, 6.0f, + 7.0f, 8.0f, + // f2: channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // f2: channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f, + // f2: channel 3 + -1.0f, -2.0f, + -3.0f, -4.0f, + // f2: channel 4 + -5.0f, -6.0f, + -7.0f, -8.0f}; + + const Shape offsets_shape{1, 16, 3, 3}; + const std::vector offsets{// defgroup 1 + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, + // defgroup 2 + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + }; + + const Shape outputs_shape{1, 2, 3, 3}; + const std::vector outputs{// output 1 + 1300.0f, 1372.0f, 992.0f, + 1588.0f, 1660.0f, 1200.0f, + 1228.0f, 1278.0f, 1096.0f, + // output 2 + -1300.0f, -1372.0f, -992.0f, + -1588.0f, -1660.0f, -1200.0f, + -1228.0f, -1278.0f, -1096.0f, + }; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_integral_offsets_groups_and_deforgroups) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 2; + const int64_t deformable_group = 2; + + const Shape inputs_shape{1, 4, 3, 3}; + const std::vector inputs{1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f, + 19.0f, 20.0f, 21.0f, + 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, + 28.0f, 29.0f, 30.0f, + 31.0f, 32.0f, 33.0f, + 34.0f, 35.0f, 36.0f}; + + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filter{1.0f, 2.0f, + 3.0f, 4.0f, + 5.0f, 6.0f, + 7.0f, 8.0f, + -1.0f, -2.0f, + -3.0f, -4.0f, + -5.0f, -6.0f, + -7.0f, -8.0f, + }; + + const Shape offsets_shape{1, 16, 2, 2}; + const std::vector offsets{// defgroup 1 + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + // defgroup 2 + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + }; + + const Shape outputs_shape{1, 2, 2, 2}; + const std::vector outputs{500.0f, 234.0f, + 219.0f, 99.0f, + -1004.0f, -1040.0f, + -1112.0f, -1148.0f}; + + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape, strides, padding, + dilations, group, deformable_group); +} + +// deformable convolution atrributes (real offsets) +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_default) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 1; + + const Shape inputs_shape{1, 1, 4, 4}; + const std::vector inputs{1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f}; + + const Shape filter_shape{1, 1, 2, 2}; + const std::vector filter{1.0f, 2.0f, + -1.0f, -2.0f}; + + const Shape offsets_shape{1, 8, 3, 3}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 1, 3, 3}; + const std::vector outputs{-11.999998f, -11.999999f, -4.000000f, + -10.799999f, -10.800001f, -3.600004f, + 44.300000f, 47.100000f, 16.000000f}; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape, strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_padding) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{1, 1}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 1; + + const Shape inputs_shape{1, 1, 4, 4}; + const std::vector inputs{1.0f, 3.0f, 7.0f, 7.0f, + 7.0f, 6.0f, 3.0f, 1.0f, + 4.0f, 4.0f, 2.0f, 8.0f, + 1.0f, 1.0f, 1.0f, 2.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filter{1.0f, 2.0f, 3.0f, + 0.0f, 1.0f, 0.0f, + 3.0f, 2.0f, 1.0f}; + + const Shape offsets_shape{1, 18, 4, 4}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 1, 4, 4}; + const std::vector outputs{54.870006f, 61.630001f, 43.230003f, 28.600002f, + 35.590000f, 25.819999f, 20.880001f, 7.700000f, + 19.089998f, 31.719999f, 19.250000f, 7.399999f, + 6.299999f, 9.199999f, 5.099999f, 2.000000f}; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_stride) +{ + const Strides strides{2, 2}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 1; + + const Shape inputs_shape{1, 1, 5, 5}; + const std::vector inputs{1.0f, 3.0f, 5.0f, 7.0f, 9.0f, + 7.0f, 5.0f, 3.0f, 1.0f, 0.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filter{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 1.0f, + 3.0f, 2.0f, 1.0f}; + + const Shape offsets_shape{1, 18, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 1, 2, 2}; + const std::vector outputs{61.229999f, 29.509998f, + 39.640003f, 22.640003f}; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_padding_stride_dilation) +{ + const Strides strides{2, 2}; + const CoordinateDiff padding{2, 2}; + const Strides dilations{2, 2}; + const int64_t group = 1; + const int64_t deformable_group = 1; + + const Shape inputs_shape{1, 1, 7, 7}; + const std::vector inputs{1.0f, 3.0f, 5.0f, 7.0f, 9.0f, 11.0f, 13.0f, + 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f, + 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, + 7.0f, 5.0f, 3.0f, 1.0f, -1.0f, -3.0f, -5.0f, + 8.0f, 6.0f, 4.0f, 2.0f, 0.0f, -2.0f, -4.0f}; + + const Shape filter_shape{1, 1, 3, 3}; + const std::vector filter{1.0f, 2.0f, 3.0f, + 1.0f, 1.0f, 0.0f, + 3.0f, 1.0f, 2.0f}; + + const Shape offsets_shape{1, 18, 4, 4}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 1, 4, 4}; + const std::vector outputs{15.260000f, 24.119997f, 6.439994f, -3.940005f, + 26.440002f, 20.319999f, -0.500001f, -11.720002f, + 23.500003f, 14.040000f, -1.279998f, -3.860000f, + 12.500000f, -2.599999f, -5.299999f, -3.099999f}; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_input_channels) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 1; + + const Shape inputs_shape{1, 2, 4, 4}; + const std::vector inputs{ + // channel 1 + 1.0f, 3.0f, 5.0f, 7.0f, + 7.0f, 5.0f, 3.0f, 1.0f, + 2.0f, 4.0f, 6.0f, 8.0f, + 8.0f, 6.0f, 4.0f, 2.0f, + // channel 2 + -1.0f, 3.0f, -5.0f, 7.0f, + 7.0f, -5.0f, 3.0f, -1.0f, + -2.0f, 4.0f, -6.0f, 8.0f, + 8.0f, -6.0f, 4.0f, -2.0f}; + + const Shape filter_shape{1, 2, 3, 3}; + const std::vector filter{ + // channel 1 + 5.0f, 3.0f, 5.0f, + 1.0f, 3.0f, 1.0f, + 4.0f, 2.0f, 4.0f, + // channel 2 + -5.0f, 3.0f, 5.0f, + 1.0f, -3.0f, 1.0f, + 4.0f, 2.0f, -4.0f}; + + const Shape offsets_shape{1, 18, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 1, 2, 2}; + const std::vector outputs{148.000000f, 43.259998f, + 91.279998f, 111.199996f}; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_output_channels) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 1; + + const Shape inputs_shape{1, 1, 4, 4}; + const std::vector inputs{1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f}; + + const Shape filter_shape{2, 1, 2, 2}; + const std::vector filter{ // filter 1 + 1.0f, 2.0f, + -1.0f, -2.0f, + // filter 2 + 3.0f, 4.0f, + -3.0f, -4.0f}; + + const Shape offsets_shape{1, 8, 3, 3}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 2, 3, 3}; + const std::vector outputs{ + // output 1 + -12.000000f, -12.000000f, -4.000000f, + -10.799999f, -10.799995f, -3.600000f, + 44.299999f, 47.099998f, 16.000000f, + // output 2 + -28.000000f, -28.000000f, -12.000000f, + -25.200000f, -25.199993f, -10.800003f, + 102.699996f, 109.300003f, 48.000000f, }; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_batch) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 1; + + const Shape inputs_shape{2, 1, 4, 4}; + const std::vector inputs{//batch 1 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + //batch 2 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f}; + + const Shape filter_shape{1, 1, 2, 2}; + const std::vector filter{1.0f, 2.0f, + -1.0f, -2.0f}; + + const Shape offsets_shape{2, 8, 3, 3}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{2, 1, 3, 3}; + const std::vector outputs{// batch 1 + -12.000000f, -12.000000f, -4.000000f, + -10.799999f, -10.799995f, -3.600000f, + 44.299999f, 47.099998f, 16.000000f, + // batch 2 + -12.000000f, -12.000000f, -4.000000f, + -10.799999f, -10.799995f, -3.600000f, + 92.300003f, 95.099998f, 32.000000f}; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +// group & deformable_group attributes (real offsets) +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_groups_basic) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 2; + const int64_t deformable_group = 1; + + const Shape inputs_shape{1, 4, 3, 3}; + const std::vector inputs{ // channel 1 + 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + // channel 2 + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f, + // channel 3 + 19.0f, 20.0f, 21.0f, + 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, + // channel 4 + 28.0f, 29.0f, 30.0f, + 31.0f, 32.0f, 33.0f, + 34.0f, 35.0f, 36.0f}; + + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filter{ // filter 1 channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // filter 1 channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // filter 2 channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // filter 2 channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f}; + + const Shape offsets_shape{1, 8, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 2, 2, 2}; + const std::vector outputs{ // channel 1 + 505.800020f, 235.800000f, + 219.600000f, 99.000000f, + // channel 2 + -1153.800000f, -523.800000f, + -471.600000f, -207.0000000f}; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape, strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_groups_complex) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 4; + const int64_t deformable_group = 1; + + const Shape inputs_shape{1, 8, 3, 3}; + const std::vector inputs{ // channel 1 + 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + // channel 2 + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f, + // channel 3 + 19.0f, 20.0f, 21.0f, + 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, + // channel 4 + 28.0f, 29.0f, 30.0f, + 31.0f, 32.0f, 33.0f, + 34.0f, 35.0f, 36.0f, + // channel 5 + 37.0f, 38.0f, 39.0f, + 40.0f, 41.0f, 42.0f, + 43.0f, 44.0f, 45.0f, + // channel 6 + 46.0f, 47.0f, 48.0f, + 49.0f, 50.0f, 51.0f, + 52.0f, 53.0f, 54.0f, + // channel 7 + 55.0f, 56.0f, 57.0f, + 58.0f, 59.0f, 60.0f, + 61.0f, 62.0f, 63.0f, + // channel 8 + 64.0f, 65.0f, 66.0f, + 67.0f, 68.0f, 69.0f, + 70.0f, 71.0f, 72.0f,}; + + const Shape filter_shape{4, 2, 2, 2}; + const std::vector filter{ // filter 1 channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // filter 1 channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // filter 2 channel 1 + 9.0f, 10.0f, + 11.0f, 12.0f, + // filter 2 channel 2 + 13.0f, 14.0f, + 15.0f, 16.0f, + // filter 3 channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // filter 3 channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f, + // filter 4 channel 1 + -9.0f, -10.0f, + -11.0f, -12.0f, + // filter 4 channel 2 + -13.0f, -14.0f, + -15.0f, -16.0f}; + + const Shape offsets_shape{1, 8, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 4, 2, 2}; + const std::vector outputs{ // channel 1 + 505.800020f, 235.800000f, + 219.600000f, 99.000000f, + // channel 2 + 3054.600000f, 1488.600000f, + 1465.200100f, 711.000000f, + // channel 3 + -1801.799900f, -811.80000f, + -723.600000f, -315.000000f, + // channel 4 + -6654.600000f, -3216.600000f, + -3121.200000f, -1503.000000f}; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape, strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_deforgroup_basic) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 2; + + const Shape inputs_shape{1, 2, 4, 4}; + const std::vector inputs{// channel 1 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + // channel 2 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f}; + + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filter{// f1: channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // f1: channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // f2: channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // f2: channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f}; + + const Shape offsets_shape{1, 16, 3, 3}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 2, 3, 3}; + const std::vector outputs{// output 1 + 758.000000f, 792.000000f, 366.399993f, + 893.200012f, 927.200012f, 426.399993f, + 381.399993f, 394.600006f, 176.000000f, + // output 2 + -758.000000f, -792.000000f, -366.399993f, + -893.200012f, -927.200012f, -426.399993f, + -381.399993f, -394.600006f, -176.000000f, + }; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_deforgroup_complex1) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 4; + + const Shape inputs_shape{1, 4, 4, 4}; + const std::vector inputs{// channel 1 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + // channel 2 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f, + // channel 3 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + // channel 4 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f}; + + const Shape filter_shape{2, 4, 2, 2}; + const std::vector filter{// f1: channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // f1: channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // f1: channel 3 + 1.0f, 2.0f, + 3.0f, 4.0f, + // f1: channel 4 + 5.0f, 6.0f, + 7.0f, 8.0f, + // f2: channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // f2: channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f, + // f2: channel 3 + -1.0f, -2.0f, + -3.0f, -4.0f, + // f2: channel 4 + -5.0f, -6.0f, + -7.0f, -8.0f}; + + const Shape offsets_shape{1, 32, 3, 3}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 2, 3, 3}; + const std::vector outputs{// output 1 + 1516.000000f, 1583.999877f, 732.799987f, + 1786.400146f, 1854.400024f, 852.799987f, + 762.799987f, 789.200012f, 352.000000f, + // output 2 + -1516.000000f, -1583.999877f, -732.799987f, + -1786.400146f, -1854.400024f, -852.799987f, + -762.799987f, -789.200012f, -352.000000f}; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_deforgroup_complex2) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 2; + + const Shape inputs_shape{1, 4, 4, 4}; + const std::vector inputs{// channel 1 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + // channel 2 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f, + // channel 3 + 1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f, + // channel 4 + 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, 28.0f, + 29.0f, 30.0f, 31.0f, 32.0f}; + + const Shape filter_shape{2, 4, 2, 2}; + const std::vector filter{// f1: channel 1 + 1.0f, 2.0f, + 3.0f, 4.0f, + // f1: channel 2 + 5.0f, 6.0f, + 7.0f, 8.0f, + // f1: channel 3 + 1.0f, 2.0f, + 3.0f, 4.0f, + // f1: channel 4 + 5.0f, 6.0f, + 7.0f, 8.0f, + // f2: channel 1 + -1.0f, -2.0f, + -3.0f, -4.0f, + // f2: channel 2 + -5.0f, -6.0f, + -7.0f, -8.0f, + // f2: channel 3 + -1.0f, -2.0f, + -3.0f, -4.0f, + // f2: channel 4 + -5.0f, -6.0f, + -7.0f, -8.0f}; + + const Shape offsets_shape{1, 16, 3, 3}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 2, 3, 3}; + const std::vector outputs{// output 1 + 1516.000000f, 1583.999877f, 732.799987f, + 1786.400146f, 1854.400024f, 852.799987f, + 762.799987f, 789.200012f, 352.000000f, + // output 2 + -1516.000000f, -1583.999877f, -732.799987f, + -1786.400146f, -1854.400024f, -852.799987f, + -762.799987f, -789.200012f, -352.000000f, + }; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape,strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_groups_and_deforgroups) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 2; + const int64_t deformable_group = 2; + + const Shape inputs_shape{1, 4, 3, 3}; + const std::vector inputs{1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f, + 19.0f, 20.0f, 21.0f, + 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, + 28.0f, 29.0f, 30.0f, + 31.0f, 32.0f, 33.0f, + 34.0f, 35.0f, 36.0f}; + + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filter{1.0f, 2.0f, + 3.0f, 4.0f, + 5.0f, 6.0f, + 7.0f, 8.0f, + -1.0f, -2.0f, + -3.0f, -4.0f, + -5.0f, -6.0f, + -7.0f, -8.0f, + }; + + const Shape offsets_shape{1, 16, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1f); + + const Shape outputs_shape{1, 2, 2, 2}; + const std::vector outputs{505.800020f, 235.800000f, + 219.600000f, 99.000000f, + -1153.800000f, -523.800000f, + -471.600000f, -207.000000f}; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, outputs, outputs_shape, strides, padding, + dilations, group, deformable_group, tolerance_bits); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_v8_zeroed_offsets_default_mask) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape inputs_shape{1, 1, 4, 4}; + const std::vector inputs{1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f}; + + const Shape filter_shape{1, 1, 2, 2}; + const std::vector filter{1.0f, 2.0f, + -1.0f, -2.0f}; + + const Shape offsets_shape{1, 8, 3, 3}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 0); + + const Shape outputs_shape{1, 1, 3, 3}; + const std::vector outputs{-6.0f, -6.0f, -6.0f, + -6.0f, -6.0f, -6.0f, + -6.0f, -6.0f, -6.0f}; + + const Shape mask_shape{1, 4, 3, 3}; + const std::vector mask{0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f}; + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, mask, mask_shape, outputs, outputs_shape,strides, padding, dilations, + 1, 1, tolerance_bits, true); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_groups_and_deforgroups_mask) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 2; + const int64_t deformable_group = 2; + + const Shape inputs_shape{1, 4, 3, 3}; + const std::vector inputs{1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f, + 19.0f, 20.0f, 21.0f, + 22.0f, 23.0f, 24.0f, + 25.0f, 26.0f, 27.0f, + 28.0f, 29.0f, 30.0f, + 31.0f, 32.0f, 33.0f, + 34.0f, 35.0f, 36.0f}; + + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filter{1.0f, 2.0f, + 3.0f, 4.0f, + 5.0f, 6.0f, + 7.0f, 8.0f, + -1.0f, -2.0f, + -3.0f, -4.0f, + -5.0f, -6.0f, + -7.0f, -8.0f, + }; + + const Shape offsets_shape{1, 16, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1); + + const Shape outputs_shape{1, 2, 2, 2}; + const std::vector outputs{220.15443f , 38.199608f, + 32.643005f, 59.340614f, + -419.0005f , -252.08015f, + -182.44444f , -165.99335f}; + + const Shape mask_shape{1, 8, 2, 2}; + const std::vector mask{0.64f, + 0.18f, + 0.23f, + 0.74f, + 0.89f, + 0.70f, + 0.13f, + 0.99f, + 0.48f, + 0.20f, + 0.67f, + 0.88f, + 0.17f, + 0.19f, + 0.53f, + 0.22f, + 0.50f, + 0.07f, + 0.21f, + 0.99f, + 0.09f, + 0.28f, + 0.66f, + 0.91f, + 0.28f, + 0.89f, + 0.91f, + 0.39f, + 0.70f, + 0.67f, + 0.26f, + 0.09f + }; + + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, mask, mask_shape, outputs, outputs_shape, strides, padding, + dilations, group, deformable_group, tolerance_bits, true); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_real_offsets_groups_and_deforgroups_mask_2) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 2; + const Shape inputs_shape{1, 2, 3, 3}; + const std::vector inputs{1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f,}; + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filter{1.0f, 2.0f, + 3.0f, 4.0f, + 5.0f, 6.0f, + 7.0f, 8.0f, + -1.0f, -2.0f, + -3.0f, -4.0f, + -5.0f, -6.0f, + -7.0f, -8.0f, + }; + const Shape offsets_shape{1, 16, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), 1.1); + const Shape outputs_shape{1, 2, 2, 2}; + const std::vector outputs{184.25163, 101.04752, + 77.46842, 77.56562, + -184.25163, -101.04752, + -77.46842, -77.56562}; + const Shape mask_shape{1, 8, 2, 2}; + const std::vector mask{0.64f, + 0.18f, + 0.23f, + 0.74f, + 0.89f, + 0.70f, + 0.13f, + 0.99f, + 0.48f, + 0.20f, + 0.67f, + 0.88f, + 0.17f, + 0.19f, + 0.53f, + 0.22f, + 0.50f, + 0.07f, + 0.21f, + 0.99f, + 0.09f, + 0.28f, + 0.66f, + 0.91f, + 0.28f, + 0.89f, + 0.91f, + 0.39f, + 0.70f, + 0.67f, + 0.26f, + 0.09f + }; + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, mask, mask_shape, outputs, outputs_shape, strides, padding, + dilations, group, deformable_group, tolerance_bits, true); +} + +NGRAPH_TEST(${BACKEND_NAME}, deformable_convolution_opset8_2D_neg_offsets_groups_and_deforgroups_mask) +{ + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + const int64_t group = 1; + const int64_t deformable_group = 2; + const Shape inputs_shape{1, 2, 3, 3}; + const std::vector inputs{1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f, + 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f,}; + const Shape filter_shape{2, 2, 2, 2}; + const std::vector filter{1.0f, 2.0f, + 3.0f, 4.0f, + 5.0f, 6.0f, + 7.0f, 8.0f, + -1.0f, -2.0f, + -3.0f, -4.0f, + -5.0f, -6.0f, + -7.0f, -8.0f, + }; + const Shape offsets_shape{1, 16, 2, 2}; + const std::vector offsets(ngraph::shape_size(offsets_shape), -1.1); + const Shape outputs_shape{1, 2, 2, 2}; + const std::vector outputs{45.910797, 104.8302, + 63.12059 , 151.47789, + -45.910797, -104.8302, + -63.12059 , -151.47789}; + const Shape mask_shape{1, 8, 2, 2}; + const std::vector mask{0.64f, + 0.18f, + 0.23f, + 0.74f, + 0.89f, + 0.70f, + 0.13f, + 0.99f, + 0.48f, + 0.20f, + 0.67f, + 0.88f, + 0.17f, + 0.19f, + 0.53f, + 0.22f, + 0.50f, + 0.07f, + 0.21f, + 0.99f, + 0.09f, + 0.28f, + 0.66f, + 0.91f, + 0.28f, + 0.89f, + 0.91f, + 0.39f, + 0.70f, + 0.67f, + 0.26f, + 0.09f + }; + const size_t tolerance_bits = 6; + DeformableConvolutionOpset8Test(inputs, inputs_shape, offsets, offsets_shape, filter, + filter_shape, mask, mask_shape, outputs, outputs_shape, strides, padding, + dilations, group, deformable_group, tolerance_bits, true); +} \ No newline at end of file diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index fd6a5df50ce1c9..ea38479783dc66 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -1609,6 +1609,14 @@ IE_CPU.deformable_convolution_2D_integral_offsets_groups_and_deforgroups IE_CPU.deformable_convolution_2D_real_offsets_groups_basic IE_CPU.deformable_convolution_2D_real_offsets_groups_complex IE_CPU.deformable_convolution_2D_real_offsets_groups_and_deforgroups +# No plugin support for DeformableConvolution v8 +IE_GPU.deformable_convolution_opset8_2D_v8_zeroed_offsets_default_mask +IE_GPU.deformable_convolution_opset8_2D_real_offsets_groups_and_deforgroups_mask +IE_GPU.deformable_convolution_opset8_2D_real_offsets_groups_and_deforgroups_mask_2 +IE_GPU.deformable_convolution_opset8_2D_neg_offsets_groups_and_deforgroups_mask +# results missmatch, ticket: 59600 +IE_GPU.deformable_convolution_2D_integral_offsets_groups_and_deforgroups +IE_GPU.deformable_convolution_opset8_2D_integral_offsets_groups_and_deforgroups # No plugin support for AdaptiveAvgPool and AdaptiveMaxPool adaptive_avg_pool_1d diff --git a/ngraph/test/runtime/interpreter/evaluates_map.cpp b/ngraph/test/runtime/interpreter/evaluates_map.cpp index 6bad2c31fa445b..c068f14c7defea 100644 --- a/ngraph/test/runtime/interpreter/evaluates_map.cpp +++ b/ngraph/test/runtime/interpreter/evaluates_map.cpp @@ -345,6 +345,60 @@ namespace return true; } + template + bool evaluate(const shared_ptr& op, + const HostTensorVector& outputs, + const HostTensorVector& inputs) { + const auto in_data_ptr = inputs[0]->get_data_ptr(); + const auto offset_data_ptr = inputs[1]->get_data_ptr(); + const auto filter_data_ptr = inputs[2]->get_data_ptr(); + auto out_data_ptr = outputs[0]->get_data_ptr(); + const auto& out_shape = outputs[0]->get_shape(); + const auto& in_shape = inputs[0]->get_shape(); + const auto& offset_shape = inputs[1]->get_shape(); + const auto& filter_shape = inputs[2]->get_shape(); + if (inputs.size() == 3) { + runtime::reference::deformable_convolution::value_type>( + in_data_ptr, + offset_data_ptr, + filter_data_ptr, + out_data_ptr, + in_shape, + offset_shape, + filter_shape, + out_shape, + op->get_strides(), + op->get_dilations(), + op->get_pads_begin(), + op->get_pads_end(), + op->get_group(), + op->get_deformable_group(), + op->get_bilinear_interpolation_pad()); + } else { + const auto mask_data_ptr = inputs[3]->get_data_ptr(); + const auto& mask_shape = inputs[3]->get_shape(); + runtime::reference::deformable_convolution::value_type>( + in_data_ptr, + offset_data_ptr, + filter_data_ptr, + mask_data_ptr, + out_data_ptr, + in_shape, + offset_shape, + filter_shape, + mask_shape, + out_shape, + op->get_strides(), + op->get_dilations(), + op->get_pads_begin(), + op->get_pads_end(), + op->get_group(), + op->get_deformable_group(), + op->get_bilinear_interpolation_pad()); + } + return true; + } + template bool evaluate(const shared_ptr& op, const HostTensorVector& outputs,