[CPU] Deformable Convolution minor fixes (#19415)

This commit is contained in:
Yury Gaydaychuk 2023-08-31 16:13:39 +02:00 committed by GitHub
parent 2d2977ff4a
commit 2d3aab33b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 6 deletions

View File

@ -825,6 +825,9 @@ void DeformableConvolution::initSupportedPrimitiveDescriptors() {
auto &weiDims = getInputShapeAtPort(WEI_ID).getDims();
if (weiDims[1] == Shape::UNDEFINED_DIM || weiDims[0] == Shape::UNDEFINED_DIM ||
// 1. strict fallback, until devising of multigroup handling in common case
defConvAttr.group != 1 ||
// 2. common fallback, except specific n_group / n_channel combinations
(defConvAttr.group != 1 && ((weiDims[1] % simd_w != 0) // in_channels_per_gr !% simd_w
|| ((weiDims[0] / defConvAttr.group) % simd_w != 0)))) { // out_channels_per_gr !% simd_w
enforceRef = true;
@ -1140,10 +1143,24 @@ void DeformableConvolution::DefConvRefExecutor::exec(const float* src, const flo
const int v12 = pSampledCoordsVector[sampledCoordIndex + 1];
const int v21 = pSampledCoordsVector[sampledCoordIndex + 2];
const int v22 = pSampledCoordsVector[sampledCoordIndex + 3];
float val = pInterpWeightsVector[sampledCoordIndex++] * data_im_ptr[v11]; // v11
val += pInterpWeightsVector[sampledCoordIndex++] * data_im_ptr[v12]; // v12
val += pInterpWeightsVector[sampledCoordIndex++] * data_im_ptr[v21]; // v21
val += pInterpWeightsVector[sampledCoordIndex++] * data_im_ptr[v22]; // v22
float val = 0;
float w11 = pInterpWeightsVector[sampledCoordIndex++];
float w12 = pInterpWeightsVector[sampledCoordIndex++];
float w21 = pInterpWeightsVector[sampledCoordIndex++];
float w22 = pInterpWeightsVector[sampledCoordIndex++];
// Prevent access to invalid memory in the case, when
// data_im_ptr[v_i1_i2] is out of the input memory.
// Logic of skipping of such points realized by nullifying
// of corresponding weight, but we must explicitly check it, because
// 0 * (*wrong_pointer) != 0 in common case, i.e.
// 0 * NaN == NaN or throws segfault
val += ((w11 == 0) ? 0 : w11 * data_im_ptr[v11]);
val += ((w12 == 0) ? 0 : w12 * data_im_ptr[v12]);
val += ((w21 == 0) ? 0 : w21 * data_im_ptr[v21]);
val += ((w22 == 0) ? 0 : w22 * data_im_ptr[v22]);
d += val * weights[weiIndex + kh_off + kw_off];
} else {
sampledCoordIndex += sampledPointsPerPixel;

View File

@ -181,8 +181,6 @@ std::vector<std::string> disabledTestPatterns() {
R"(.*smoke_Proposal_(Static|Dynamic)_Test_Case1/ProposalLayerCPUTest.*)",
// Issue: 111418
R"(.*smoke_Snippets_ConvertStub/ConvertStub\.CompareWithRefImpl/IS.*_OT=\(bf16\)_#N=2_#S=2_targetDevice=CPU.*)",
// Issue: 111944
R"(.*smoke_DefConvLayoutTest6.*)",
// Issue: 106939
R"(.*ScatterNDUpdateLayerCPUTest.*-1.-1.-1.-2.-2.-2.*)",
// New plugin API doesn't support changes of pre-processing

View File

@ -632,5 +632,39 @@ INSTANTIATE_TEST_SUITE_P(DefConvLayoutTest8, DefConvLayerCPUTest, params8, DefCo
INSTANTIATE_TEST_SUITE_P(DefConvLayoutTest9, DefConvLayerCPUTest, params9, DefConvLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(DefConvLayoutTest10, DefConvLayerCPUTest, params10, DefConvLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(DefConvLayoutTest11, DefConvLayerCPUTest, params11, DefConvLayerCPUTest::getTestCaseName);
const std::vector<std::vector<size_t>> blockMultigroupChParam = {
{2}, // gr.
{1}, // def. gr.
{16}, // in. ch. per gr.
{16} // out. ch. per gr.
};
const std::vector<std::vector<size_t>> blockMultigroupSpatParam = {
{1}, // batch
{2, 2}, // in. spat. shape
{2, 2}, // off. spat. shape
{1, 1} // ker. spat. shape
};
const auto blockMultigroupAddParam = ::testing::Combine(
::testing::Values(true), // with_bilinear_interpolation_pad
::testing::Values(false), // with_modulation
::testing::Values(OffsetType::ZERO) // offset type
);
const auto blockMultigroupKernelParam = ::testing::Combine(
::testing::Values(ngraph::op::PadType::EXPLICIT), // pad. type
::testing::Values(std::vector<ptrdiff_t>({0, 0})), // pad. begin
::testing::Values(std::vector<ptrdiff_t>({0, 0})), // pad. end
::testing::Values(std::vector<size_t> {1, 1}), // strides
::testing::Values(std::vector<size_t> {1, 1}) // dilations
);
const auto blockMultigroupParam = ::testing::Combine(
::testing::Combine(
blockMultigroupKernelParam,
::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(blockMultigroupSpatParam, blockMultigroupChParam))),
blockMultigroupAddParam,
::testing::ValuesIn(netPrecisions),
::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::ValuesIn(filterCPUInfoForDevice(true)));
INSTANTIATE_TEST_SUITE_P(blockMultigroupDefConvTest, DefConvLayerCPUTest, blockMultigroupParam, DefConvLayerCPUTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions