Skip to content

Commit

Permalink
[CPU] Enable concat nspc layout inplace for urlnet model cases (#23454)
Browse files Browse the repository at this point in the history
### Details:
- *enable concat nspc layout inplace for channel only cases, with these
concat node use inplace impl, urlnet model gain performance benefits,
and this(intermediate concat node is nspc layout but actually is one
dimension) could be common case especially for models with 1D input*


### Tickets:
 - *130282*
  • Loading branch information
liubo-intel authored Mar 21, 2024
1 parent 9072ea7 commit 12404fc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/plugins/intel_cpu/src/nodes/concat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ void Concat::initSupportedPrimitiveDescriptors() {
supportedPrimitiveDescriptors.emplace_back(config, impl_desc_type::ref);
if (itr->first != LayoutType::nspc) {
pdIndexesToReuse.push_back(supportedPrimitiveDescriptors.size() - 1);
} else if (canBeInPlace) {
// canBeInPlace means all dims before axis are 1, so for nspc layout we only need check sp dimensions in
// axis=1 cases here
const auto& childDims = outputShapes[0].getDims();
if (axis != 1 || std::all_of(childDims.crbegin(), childDims.crend() - 2, [](const Dim dim) {
return 1 == dim;
})) {
pdIndexesToReuse.push_back(supportedPrimitiveDescriptors.size() - 1);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ const auto planar_5D = CPUSpecificParams{{ncdhw}, {ncdhw}, {}, "unknown"};
const auto planarChannels_4D = CPUSpecificParams{{nhwc}, {nhwc}, {}, "ref"};
const auto planarChannels_5D = CPUSpecificParams{{ndhwc}, {ndhwc}, {}, "ref"};

const auto planarChannels_inplace_4D = CPUSpecificParams{{nhwc}, {nhwc}, {}, "unknown"};
const auto planarChannels_inplace_5D = CPUSpecificParams{{ndhwc}, {ndhwc}, {}, "unknown"};

const auto blocked8_4D = CPUSpecificParams{{nChw8c}, {nChw8c}, {}, "unknown"};
const auto blocked8_5D = CPUSpecificParams{{nCdhw8c}, {nCdhw8c}, {}, "unknown"};

Expand Down Expand Up @@ -810,6 +813,32 @@ INSTANTIATE_TEST_SUITE_P(smoke_Concat_inPlace,
::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})),
ConcatLayerCPUTest::getTestCaseName);

INSTANTIATE_TEST_SUITE_P(smoke_Concat_CPU_planarChannels_inplace_4D_static,
ConcatLayerCPUTest,
::testing::Combine(::testing::Values(1),
::testing::Values(static_shapes_to_test_representation({{1, 32, 1, 1},
{1, 32, 1, 1}})),
::testing::ValuesIn(netPrecisions),
::testing::Values(planarChannels_inplace_4D)),
ConcatLayerCPUTest::getTestCaseName);

INSTANTIATE_TEST_SUITE_P(smoke_Concat_CPU_planarChannels_inplace_4D_sp_w_static,
ConcatLayerCPUTest,
::testing::Combine(::testing::Values(2),
::testing::Values(static_shapes_to_test_representation({{1, 1, 32, 32},
{1, 1, 32, 32}})),
::testing::ValuesIn(netPrecisions),
::testing::Values(planarChannels_inplace_4D)),
ConcatLayerCPUTest::getTestCaseName);

INSTANTIATE_TEST_SUITE_P(smoke_Concat_CPU_planarChannels_inplace_5D_static,
ConcatLayerCPUTest,
::testing::Combine(::testing::Values(1),
::testing::Values(static_shapes_to_test_representation({{1, 32, 1, 1, 1},
{1, 32, 1, 1, 1}})),
::testing::ValuesIn(netPrecisions),
::testing::Values(planarChannels_inplace_5D)),
ConcatLayerCPUTest::getTestCaseName);
} // namespace

} // namespace test
Expand Down

0 comments on commit 12404fc

Please sign in to comment.