Skip to content

Commit f0e6f0d

Browse files
committed
Keep NCHWAsNHWC layout optimization for v4 Interpolate nodes with explicit axes [1,2] to extend interpolate support and disable node fusion for these cases to prevent compatibility issues.
1 parent 924bea6 commit f0e6f0d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/plugins/intel_cpu/src/nodes/interpolate.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2017,6 +2017,11 @@ Interpolate::Interpolate(const std::shared_ptr<ov::Node>& op, const GraphContext
20172017
if (isAxesSpecified) {
20182018
axes = ov::as_type_ptr<const ov::op::v0::Constant>(interp->get_input_node_shared_ptr(AXES_ID))
20192019
->cast_vector<int>();
2020+
if (dataRank == 4 && axes.size() == 2 && axes[0] == 1 && axes[1] == 2) {
2021+
interpAttrs.NCHWAsNHWC = true;
2022+
axes[0] = 2;
2023+
axes[1] = 3;
2024+
}
20202025
} else {
20212026
axes.resize(dataRank);
20222027
for (int i = 0; i < static_cast<int>(dataRank); i++) {
@@ -4526,7 +4531,10 @@ size_t Interpolate::getSpatialDimsNum(const std::vector<float>& scales) {
45264531
bool Interpolate::canFuse(const NodePtr& node) const {
45274532
if (!mayiuse(cpu::x64::sse41) || interpAttrs.mode == InterpolateMode::linear ||
45284533
interpAttrs.mode == InterpolateMode::bilinear_pillow || interpAttrs.mode == InterpolateMode::bicubic_pillow ||
4529-
(none_of(dataRank, 4U, 5U) && !mayiuse(cpu::x64::avx2))) {
4534+
(none_of(dataRank, 4U, 5U) && !mayiuse(cpu::x64::avx2)) ||
4535+
// NCHWAsNHWC cases: disable fusion for 4D tensors with specific axes pattern that may trigger layout
4536+
// optimization
4537+
(dataRank == 4 && axes.size() == 2 && axes[0] == 1 && axes[1] == 2)) {
45304538
return false;
45314539
}
45324540

0 commit comments

Comments
 (0)