Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[CPU] SliceScatter-15 CPU implementation (#26285)

Mateusz Mikolajczyk82c45660b300
diff --git a/src/plugins/intel_cpu/src/cpu_types.cpp b/src/plugins/intel_cpu/src/cpu_types.cpp
index f42d0f81a20..8b4ffaefcab 100644
--- a/src/plugins/intel_cpu/src/cpu_types.cpp
+++ b/src/plugins/intel_cpu/src/cpu_types.cpp
@@ -116,6 +116,7 @@ static const TypeToNameMap& get_type_to_name_tbl() {
{"GroupConvolutionBackpropData", Type::Deconvolution},
{"StridedSlice", Type::StridedSlice},
{"Slice", Type::StridedSlice},
+ {"SliceScatter", Type::StridedSlice},
{"Tile", Type::Tile},
{"ROIAlign", Type::ROIAlign},
{"ROIAlignRotated", Type::ROIAlignRotated},
diff --git a/src/plugins/intel_cpu/src/nodes/strided_slice.cpp b/src/plugins/intel_cpu/src/nodes/strided_slice.cpp
index 8cd8c7a6ae1..4f974cfe5e9 100644
--- a/src/plugins/intel_cpu/src/nodes/strided_slice.cpp
+++ b/src/plugins/intel_cpu/src/nodes/strided_slice.cpp
@@ -23,8 +23,9 @@ namespace node {
bool StridedSlice::isSupportedOperation(const std::shared_ptr<const ov::Node>& op, std::string& errorMessage) noexcept {
try {
if (!ov::is_type<ov::op::v1::StridedSlice>(op) &&
- !ov::is_type<ov::op::v8::Slice>(op)) {
- errorMessage = "Only StridedSlice from opset1 and Slice from opset8 operations are supported.";
+ !ov::is_type<ov::op::v8::Slice>(op) &&
+ !ov::is_type<ov::op::v15::SliceScatter>(op)) {
+ errorMessage = "Only StridedSlice from opset1, Slice from opset8 and SliceScatter from opset15 operations are supported.";
return false;
}
} catch (...) {
@@ -42,35 +43,46 @@ StridedSlice::StridedSlice(const std::shared_ptr<ov::Node>& op, const GraphConte
errorPrefix = NameFromType(getType()) + " node with name '" + getName() + "' ";
attrs.isStridedSliceOp = ov::is_type<ov::op::v1::StridedSlice>(op);
+ attrs.isSliceScatterOp = ov::is_type<ov::op::v15::SliceScatter>(op);
+ if (!attrs.isSliceScatterOp) {
+ attrs.BEGIN_ID = 1;
+ attrs.END_ID = 2;
+ attrs.STRIDE_ID = 3;
+ attrs.AXES_ID = 4;
+ } else {
+ attrs.BEGIN_ID = 2;
+ attrs.END_ID = 3;
+ attrs.STRIDE_ID = 4;
+ attrs.AXES_ID = 5;
+ }
if ((attrs.isStridedSliceOp && (inputShapes.size() < 3 || inputShapes.size() > 4)) ||
- (!attrs.isStridedSliceOp && (inputShapes.size() < 4 || inputShapes.size() > 5))) {
+ (!attrs.isStridedSliceOp && (inputShapes.size() < (attrs.STRIDE_ID + 1) || inputShapes.size() > (attrs.AXES_ID + 1)))) {
OPENVINO_THROW(errorPrefix, "has incorrect number of input edges");
}
if (outputShapes.size() != 1) {
OPENVINO_THROW(errorPrefix, "has incorrect number of output edges");
}
- if (inputShapes.size() > STRIDE_ID) {
+ if (inputShapes.size() > attrs.STRIDE_ID) {
isStrideSpecified = true;
}
- if (inputShapes.size() > AXES_ID) {
+ if (inputShapes.size() > attrs.AXES_ID) {
isAxesSpecified = true;
}
for (size_t i = 0lu; i < op->get_input_size(); i++) {
isConstantInput[i] = ov::is_type<ov::op::v0::Constant>(op->get_input_node_shared_ptr(i));
-
- if (!isConstantInput[i] && one_of(i, 1u, 2u, 3u)) {
+ if (!isConstantInput[i] && one_of(i, attrs.BEGIN_ID, attrs.END_ID, attrs.STRIDE_ID) && !attrs.isSliceScatterOp) {
shapeHasDataDependency = true;
}
}
hasConstAttrInputs = !shapeHasDataDependency;
if (isAxesSpecified)
- hasConstAttrInputs &= isConstantInput[AXES_ID];
+ hasConstAttrInputs &= isConstantInput[attrs.AXES_ID];
- const size_t inputRank = getInputShapeAtPort(DATA_ID).getRank();
+ const size_t inputRank = getInputShapeAtPort(attrs.DATA_ID).getRank();
const size_t outputRank = getOutputShapeAtPort(0).getRank();
const size_t nDims = std::max(inputRank, outputRank);
@@ -96,7 +108,7 @@ StridedSlice::StridedSlice(const std::shared_ptr<ov::Node>& op, const GraphConte
attrs.ellipsisMask = createMask(ss->get_ellipsis_mask());
} else {
const size_t length = outputShapes[0].getRank();
- if (inputShapes.size() > AXES_ID) {
+ if (inputShapes.size() > attrs.AXES_ID) {
attrs.beginMask = std::vector<int>(length, 0);
attrs.endMask = std::vector<int>(length, 0);
} else {
@@ -131,17 +143,17 @@ StridedSlice::StridedSlice(const std::shared_ptr<ov::Node>& op, const GraphConte
parameter = constNode->cast_vector<int>();
auto size = constNode->get_shape()[0];
- if (type != AXES_ID && attrs.ellipsisMaskCounter == 0 && size < nDims) {
+ if (type != attrs.AXES_ID && attrs.ellipsisMaskCounter == 0 && size < nDims) {
for (size_t i = size; i < nDims; i++) parameter.push_back(value);
}
};
- fillingInParameters(attrs.begin, BEGIN_ID, 0);
- fillingInParameters(attrs.end, END_ID, 0);
- if (inputShapes.size() > STRIDE_ID)
- fillingInParameters(attrs.stride, STRIDE_ID, 1);
- if (inputShapes.size() > AXES_ID)
- fillingInParameters(attrs.axes, AXES_ID, 0);
+ fillingInParameters(attrs.begin, attrs.BEGIN_ID, 0);
+ fillingInParameters(attrs.end, attrs.END_ID, 0);
+ if (inputShapes.size() > attrs.STRIDE_ID)
+ fillingInParameters(attrs.stride, attrs.STRIDE_ID, 1);
+ if (inputShapes.size() > attrs.AXES_ID)
+ fillingInParameters(attrs.axes, attrs.AXES_ID, 0);
}
void StridedSlice::getSupportedDescriptors() {
@@ -199,36 +211,42 @@ void StridedSlice::initSupportedPrimitiveDescriptors() {
if (!supportedPrimitiveDescriptors.empty())
return;
- const ov::element::Type dataPrecision = getOriginalInputPrecisionAtPort(DATA_ID);
+ const ov::element::Type dataPrecision = getOriginalInputPrecisionAtPort(attrs.DATA_ID);
const ov::element::Type iPrecision = ov::element::i32;
attrs.dataSize = dataPrecision.size();
- const size_t nDims = getInputShapeAtPort(DATA_ID).getRank();
+ const size_t nDims = getInputShapeAtPort(attrs.DATA_ID).getRank();
NodeConfig config;
config.inConfs.resize(getParentEdges().size());
- config.inConfs[DATA_ID].inPlace(-1);
- config.inConfs[BEGIN_ID].inPlace(-1);
- config.inConfs[END_ID].inPlace(-1);
- config.inConfs[DATA_ID].constant(isConstantInput[DATA_ID]);
- config.inConfs[BEGIN_ID].constant(isConstantInput[BEGIN_ID]);
- config.inConfs[END_ID].constant(isConstantInput[END_ID]);
+ config.inConfs[attrs.DATA_ID].inPlace(-1);
+ config.inConfs[attrs.BEGIN_ID].inPlace(-1);
+ config.inConfs[attrs.END_ID].inPlace(-1);
+ config.inConfs[attrs.DATA_ID].constant(isConstantInput[attrs.DATA_ID]);
+ config.inConfs[attrs.BEGIN_ID].constant(isConstantInput[attrs.BEGIN_ID]);
+ config.inConfs[attrs.END_ID].constant(isConstantInput[attrs.END_ID]);
if (isStrideSpecified) {
- config.inConfs[STRIDE_ID].inPlace(-1);
- config.inConfs[STRIDE_ID].constant(isConstantInput[STRIDE_ID]);
+ config.inConfs[attrs.STRIDE_ID].inPlace(-1);
+ config.inConfs[attrs.STRIDE_ID].constant(isConstantInput[attrs.STRIDE_ID]);
}
if (isAxesSpecified) {
- config.inConfs[AXES_ID].inPlace(-1);
- config.inConfs[AXES_ID].constant(isConstantInput[AXES_ID]);
+ config.inConfs[attrs.AXES_ID].inPlace(-1);
+ config.inConfs[attrs.AXES_ID].constant(isConstantInput[attrs.AXES_ID]);
+ }
+ if (attrs.isSliceScatterOp) {
+ config.inConfs[attrs.UPDATES_ID].inPlace(-1);
+ config.inConfs[attrs.UPDATES_ID].constant(isConstantInput[attrs.UPDATES_ID]);
}
config.outConfs.resize(1);
std::vector<LayoutType> supportedTypes;
if (nDims > 2 && attrs.equalDims) {
auto canUseBlocked = [&](StridedSliceAttributes& tmpAttrs, const size_t blockSize) {
- if (!isConstantInput[BEGIN_ID])
+ if (attrs.isSliceScatterOp)
+ return false;
+ if (!isConstantInput[attrs.BEGIN_ID])
return false;
- const auto& srcDims = getInputShapeAtPort(DATA_ID).getDims();
+ const auto& srcDims = getInputShapeAtPort(attrs.DATA_ID).getDims();
if (srcDims[1] == Shape::UNDEFINED_DIM)
return false;
auto channelBeginNormalized = tmpAttrs.begin[1] > 0 ? tmpAttrs.begin[1] : tmpAttrs.begin[1] + static_cast<std::int64_t>(srcDims[1]);
@@ -241,7 +259,7 @@ void StridedSlice::initSupportedPrimitiveDescriptors() {
if (hasConstAttrInputs) {
auto tmpAttrs = attrs;
- addHiddenDims(tmpAttrs, getInputShapeAtPort(DATA_ID).getRank(), getOutputShapeAtPort(0).getRank(), isAxesSpecified);
+ addHiddenDims(tmpAttrs, getInputShapeAtPort(attrs.DATA_ID).getRank(), getOutputShapeAtPort(0).getRank(), isAxesSpecified);
if (canUseBlocked(tmpAttrs, 8lu))
supportedTypes.push_back(LayoutType::nCsp8c);
if (canUseBlocked(tmpAttrs, 16lu))
@@ -253,15 +271,18 @@ void StridedSlice::initSupportedPrimitiveDescriptors() {
auto range = BlockedDescCreator::makeFilteredRange(creators, nDims, supportedTypes);
for (auto itr = range.first; itr != range.second; ++itr) {
- config.inConfs[DATA_ID].setMemDesc(itr->second->createSharedDesc(dataPrecision, getInputShapeAtPort(DATA_ID)));
- config.inConfs[BEGIN_ID].setMemDesc(creators.at(LayoutType::ncsp)->createSharedDesc(iPrecision, getInputShapeAtPort(BEGIN_ID)));
- config.inConfs[END_ID].setMemDesc(creators.at(LayoutType::ncsp)->createSharedDesc(iPrecision, getInputShapeAtPort(END_ID)));
+ config.inConfs[attrs.DATA_ID].setMemDesc(itr->second->createSharedDesc(dataPrecision, getInputShapeAtPort(attrs.DATA_ID)));
+ config.inConfs[attrs.BEGIN_ID].setMemDesc(creators.at(LayoutType::ncsp)->createSharedDesc(iPrecision, getInputShapeAtPort(attrs.BEGIN_ID)));
+ config.inConfs[attrs.END_ID].setMemDesc(creators.at(LayoutType::ncsp)->createSharedDesc(iPrecision, getInputShapeAtPort(attrs.END_ID)));
if (isStrideSpecified)
- config.inConfs[STRIDE_ID].setMemDesc(creators.at(LayoutType::ncsp)->createSharedDesc(iPrecision, getInputShapeAtPort(STRIDE_ID)));
+ config.inConfs[attrs.STRIDE_ID].setMemDesc(creators.at(LayoutType::ncsp)->createSharedDesc(iPrecision, getInputShapeAtPort(attrs.STRIDE_ID)));
if (isAxesSpecified)
- config.inConfs[AXES_ID].setMemDesc(creators.at(LayoutType::ncsp)->createSharedDesc(iPrecision, getInputShapeAtPort(AXES_ID)));
+ config.inConfs[attrs.AXES_ID].setMemDesc(creators.at(LayoutType::ncsp)->createSharedDesc(iPrecision, getInputShapeAtPort(attrs.AXES_ID)));
+ if (attrs.isSliceScatterOp) {
+ config.inConfs[attrs.UPDATES_ID].setMemDesc(itr->second->createSharedDesc(dataPrecision, getInputShapeAtPort(attrs.UPDATES_ID)));
+ }
- config.outConfs[0].setMemDesc(itr->second->createSharedDesc(dataPrecision, getOutputShapeAtPort(DATA_ID)));
+ config.outConfs[0].setMemDesc(itr->second->createSharedDesc(dataPrecision, getOutputShapeAtPort(attrs.DATA_ID)));
supportedPrimitiveDescriptors.emplace_back(config, impl_desc_type::ref);
}
}
@@ -393,13 +414,13 @@ void StridedSlice::StridedSliceCommonExecutor::paramsInitialization(const Stride
const int *ptr = srcMemory[type]->getDataAs<const int32_t>();
parameter.assign(ptr, ptr + size);
- if (type != AXES_ID && params.attrs.ellipsisMaskCounter == 0 && size < nDims) {
+ if (type != attrs.AXES_ID && params.attrs.ellipsisMaskCounter == 0 && size < nDims) {
for (size_t i = size; i < nDims; i++) parameter.push_back(value);
}
};
- params.attrs.beginDims = srcMemory[BEGIN_ID]->getShape().getStaticDims();
- params.attrs.endDims = srcMemory[END_ID]->getShape().getStaticDims();
+ params.attrs.beginDims = srcMemory[attrs.BEGIN_ID]->getShape().getStaticDims();
+ params.attrs.endDims = srcMemory[attrs.END_ID]->getShape().getStaticDims();
if (params.attrs.beginDims.size() != 1)
OPENVINO_THROW(errorPrefix, "should have begin vector with 1 dimension");
if (params.attrs.endDims.size() != 1)
@@ -408,33 +429,33 @@ void StridedSlice::StridedSliceCommonExecutor::paramsInitialization(const Stride
OPENVINO_THROW(errorPrefix, "should have begin vector with size equal to end vector size");
if (params.attrs.begin.empty())
- fillingInParameters(params.attrs.begin, BEGIN_ID, params.attrs.beginDims[0], 0);
+ fillingInParameters(params.attrs.begin, attrs.BEGIN_ID, params.attrs.beginDims[0], 0);
if (params.attrs.end.empty())
- fillingInParameters(params.attrs.end, END_ID, params.attrs.endDims[0], 0);
+ fillingInParameters(params.attrs.end, attrs.END_ID, params.attrs.endDims[0], 0);
- if (srcMemory.size() > STRIDE_ID) {
- params.attrs.strideDims = srcMemory[STRIDE_ID]->getShape().getStaticDims();
+ if (srcMemory.size() > attrs.STRIDE_ID) {
+ params.attrs.strideDims = srcMemory[attrs.STRIDE_ID]->getShape().getStaticDims();
if (params.attrs.strideDims.size() > 1)
OPENVINO_THROW(errorPrefix, "should have stride vector with 1 dimension");
if (params.attrs.beginDims[0] != params.attrs.strideDims[0])
OPENVINO_THROW(errorPrefix, "should have stride vector with size equal to begin vector size");
if (params.attrs.stride.empty())
- fillingInParameters(params.attrs.stride, STRIDE_ID, params.attrs.strideDims[0], 1);
+ fillingInParameters(params.attrs.stride, attrs.STRIDE_ID, params.attrs.strideDims[0], 1);
}
- if (srcMemory.size() > AXES_ID) {
- params.attrs.axesDims = srcMemory[AXES_ID]->getShape().getStaticDims();
+ if (srcMemory.size() > attrs.AXES_ID) {
+ params.attrs.axesDims = srcMemory[attrs.AXES_ID]->getShape().getStaticDims();
if (params.attrs.axesDims.size() != 1)
OPENVINO_THROW(errorPrefix, "should have axes vector with 1 dimension.");
if (params.attrs.beginDims[0] != params.attrs.axesDims[0])
OPENVINO_THROW(errorPrefix, "should have axes vector with size equal to begin vector size.");
if (params.attrs.axes.empty())
- fillingInParameters(params.attrs.axes, AXES_ID, params.attrs.axesDims[0], 0);
+ fillingInParameters(params.attrs.axes, attrs.AXES_ID, params.attrs.axesDims[0], 0);
}
- addHiddenDims(params.attrs, inputRank, outputRank, srcMemory.size() > AXES_ID);
+ addHiddenDims(params.attrs, inputRank, outputRank, srcMemory.size() > attrs.AXES_ID);
if (!srcBlockedMemoryDesc->hasLayoutType(LayoutType::ncsp))
orderParametersByLayouts(srcBlockedMemoryDesc);
@@ -724,7 +745,7 @@ void StridedSlice::StridedSliceCommonExecutor::indicesCalculationForOptimized()
}
}
-void StridedSlice::StridedSliceCommonExecutor::exec(const std::vector<MemoryCPtr>& srcMemory, const std::vector<MemoryCPtr>& dstMemory) {
+void StridedSlice::StridedSliceCommonExecutor::execStridedSlice(const std::vector<MemoryCPtr>& srcMemory, const std::vector<MemoryCPtr>& dstMemory) {
const uint8_t* srcData = srcMemory[0]->getDataAs<const uint8_t>();
uint8_t* dstData = dstMemory[0]->getDataAs<uint8_t>();
const uint8_t* srcShiftedData = srcData + srcShift;
@@ -737,6 +758,33 @@ void StridedSlice::StridedSliceCommonExecutor::exec(const std::vector<MemoryCPtr
});
}
+void StridedSlice::StridedSliceCommonExecutor::execSliceScatter(const std::vector<MemoryCPtr>& srcMemory, const std::vector<MemoryCPtr>& dstMemory) {
+ const uint8_t* srcData = srcMemory[0]->getDataAs<const uint8_t>();
+ const uint8_t* srcUpdates = srcMemory[1]->getDataAs<const uint8_t>();
+ uint8_t* dstData = dstMemory[0]->getDataAs<uint8_t>();
+ cpu_parallel_memcpy(dstData, srcData, srcMemory[0]->getSize());
+ if (srcMemory[1]->getSize() == 0) {
+ // Updates are empty - do not apply
+ return;
+ }
+ uint8_t* dstShiftedData = dstData + srcShift;
+ parallel_nt(nThreads, [&](const int ithr, const int nthr) {
+ size_t start = 0, end = 0;
+ splitter(workAmount, nthr, ithr, start, end);
+
+ for (size_t iwork = start; iwork < end; ++iwork)
+ cpu_memcpy(&dstShiftedData[srcIndices[iwork]], &srcUpdates[dstIndices[iwork]], lastDstDim);
+ });
+}
+
+void StridedSlice::StridedSliceCommonExecutor::exec(const std::vector<MemoryCPtr>& srcMemory, const std::vector<MemoryCPtr>& dstMemory) {
+ if (params.attrs.isSliceScatterOp) {
+ execSliceScatter(srcMemory, dstMemory);
+ } else {
+ execStridedSlice(srcMemory, dstMemory);
+ }
+}
+
} // namespace node
} // namespace intel_cpu
} // namespace ov
diff --git a/src/plugins/intel_cpu/src/nodes/strided_slice.h b/src/plugins/intel_cpu/src/nodes/strided_slice.h
index 51f339e1867..5c5950520bd 100644
--- a/src/plugins/intel_cpu/src/nodes/strided_slice.h
+++ b/src/plugins/intel_cpu/src/nodes/strided_slice.h
@@ -50,8 +50,15 @@ public:
size_t dataSize = 1lu;
int ellipsisMaskCounter = 0;
bool isStridedSliceOp = true;
+ bool isSliceScatterOp = false;
int ellipsisPos1 = -1;
bool hasConstInputs = false;
+ size_t DATA_ID = 0;
+ size_t BEGIN_ID = 1;
+ size_t END_ID = 2;
+ size_t STRIDE_ID = 3;
+ size_t AXES_ID = 4;
+ size_t UPDATES_ID = 1;
} attrs;
protected:
@@ -82,6 +89,10 @@ private:
const std::string& errorPrefix);
void exec(const std::vector<MemoryCPtr>& srcMemory,
const std::vector<MemoryCPtr>& dstMemory) override;
+ void execSliceScatter(const std::vector<MemoryCPtr>& srcMemory,
+ const std::vector<MemoryCPtr>& dstMemory);
+ void execStridedSlice(const std::vector<MemoryCPtr>& srcMemory,
+ const std::vector<MemoryCPtr>& dstMemory);
private:
struct StridedSliceParams {
@@ -118,13 +129,7 @@ private:
bool isStrideSpecified = false;
bool isAxesSpecified = false;
- static constexpr size_t DATA_ID = 0;
- static constexpr size_t BEGIN_ID = 1;
- static constexpr size_t END_ID = 2;
- static constexpr size_t STRIDE_ID = 3;
- static constexpr size_t AXES_ID = 4;
-
- bool isConstantInput[AXES_ID + 1] = {false};
+ bool isConstantInput[6] = {false};
bool shapeHasDataDependency = false;
bool hasConstAttrInputs = true;
diff --git a/src/plugins/intel_cpu/src/shape_inference/custom/strided_slice.cpp b/src/plugins/intel_cpu/src/shape_inference/custom/strided_slice.cpp
index aa99abfa453..46ae7e2b959 100644
--- a/src/plugins/intel_cpu/src/shape_inference/custom/strided_slice.cpp
+++ b/src/plugins/intel_cpu/src/shape_inference/custom/strided_slice.cpp
@@ -69,6 +69,8 @@ Result StridedSliceShapeInfer::infer(
ShapeInferPtr StridedSliceShapeInferFactory::makeShapeInfer() const {
if (const auto Slice_op = ov::as_type_ptr<const ov::op::v8::Slice>(m_op)) {
return std::make_shared<NgraphShapeInfer>(make_shape_inference(m_op), port_mask);
+ } else if (const auto SliceScatter_op = ov::as_type_ptr<const ov::op::v15::SliceScatter>(m_op)) {
+ return std::make_shared<NgraphShapeInfer>(make_shape_inference(m_op), PortMask(2, 3, 4, 5));
} else if (const auto StridedSlice_op = ov::as_type_ptr<const ov::op::v1::StridedSlice>(m_op)) {
const auto& ellipsis_mask = StridedSlice_op->get_ellipsis_mask();
if (std::any_of(ellipsis_mask.begin(), ellipsis_mask.end(), [](int64_t x){ return x == 1; })) {
diff --git a/src/plugins/intel_cpu/src/shape_inference/shape_inference.cpp b/src/plugins/intel_cpu/src/shape_inference/shape_inference.cpp
index 947d7552321..e5d87c57871 100644
--- a/src/plugins/intel_cpu/src/shape_inference/shape_inference.cpp
+++ b/src/plugins/intel_cpu/src/shape_inference/shape_inference.cpp
@@ -104,6 +104,7 @@
#include "select_shape_inference.hpp"
#include "shape_nodes.hpp"
#include "shuffle_channels_shape_inference.hpp"
+#include "slice_scatter_shape_inference.hpp"
#include "slice_shape_inference.hpp"
#include "space_to_batch_shape_inference.hpp"
#include "space_to_depth_shape_inference.hpp"
@@ -410,6 +411,7 @@ const IStaticShapeInferFactory::TRegistry IStaticShapeInferFactory::registry{
_OV_OP_SHAPE_INFER_MASK_REG(opset15::EmbeddingBagPacked, ShapeInferTA, util::bit::mask()),
_OV_OP_SHAPE_INFER_MASK_REG(op::v15::Col2Im, ShapeInferTA, util::bit::mask(1, 2)),
_OV_OP_SHAPE_INFER_MASK_REG(op::v15::ScatterNDUpdate, ShapeInferTA, util::bit::mask()),
+ _OV_OP_SHAPE_INFER_MASK_REG(opset15::SliceScatter, ShapeInferTA, util::bit::mask(2, 3, 4, 5)),
// opset14
_OV_OP_SHAPE_INFER_MASK_REG(opset14::Inverse, ShapeInferTA, util::bit::mask()),
_OV_OP_SHAPE_INFER_MASK_REG(opset14::MaxPool, ShapeInferPaddingTA, util::bit::mask()),
diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice_scatter.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice_scatter.cpp
new file mode 100644
index 00000000000..eba515d3c66
--- /dev/null
+++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice_scatter.cpp
@@ -0,0 +1,448 @@
+// Copyright (C) 2018-2024 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "common_test_utils/ov_tensor_utils.hpp"
+#include "common_test_utils/test_enums.hpp"
+#include "shared_test_classes/base/ov_subgraph.hpp"
+#include "utils/cpu_test_utils.hpp"
+#include "utils/filter_cpu_info.hpp"
+
+using namespace CPUTestUtils;
+using namespace ov::test;
+
+struct SliceScatterSpecificParams {
+ std::vector<InputShape> updates;
+ std::vector<int64_t> start;
+ std::vector<int64_t> stop;
+ std::vector<int64_t> step;
+ std::vector<int64_t> axes;
+};
+
+typedef std::tuple<std::vector<InputShape>, // Parameters shapes
+ SliceScatterSpecificParams, // SliceScatter specific parameters
+ ov::test::utils::InputLayerType, // Secondary input types
+ ElementType, // Network precision
+ CPUSpecificParams // CPU specific parameters
+ >
+ SliceScatterLayerTestCPUParam;
+
+class SliceScatterLayerCPUTest : public testing::WithParamInterface<SliceScatterLayerTestCPUParam>,
+ virtual public SubgraphBaseTest,
+ public CPUTestsBase {
+public:
+ static std::string getTestCaseName(testing::TestParamInfo<SliceScatterLayerTestCPUParam> obj) {
+ std::vector<InputShape> shapes;
+ SliceScatterSpecificParams params;
+ ov::test::utils::InputLayerType secondaryInputType;
+ ElementType netPrecision;
+ CPUSpecificParams cpuParams;
+ std::tie(shapes, params, secondaryInputType, netPrecision, cpuParams) = obj.param;
+
+ std::ostringstream result;
+ result << "IS=(";
+ for (const auto& shape : shapes) {
+ result << ov::test::utils::partialShape2str({shape.first}) << "_";
+ }
+ result << ")_TS=(";
+ for (const auto& shape : shapes) {
+ for (const auto& item : shape.second) {
+ result << ov::test::utils::vec2str(item) << "_";
+ }
+ }
+ result << "start=" << ov::test::utils::vec2str(params.start) << "_";
+ result << "stop=" << ov::test::utils::vec2str(params.stop) << "_";
+ result << "step=" << ov::test::utils::vec2str(params.step) << "_";
+ result << "axes=" << ov::test::utils::vec2str(params.axes) << "_";
+ result << "netPRC=" << netPrecision << "_";
+ result << "secondaryInputType=" << secondaryInputType << "_";
+ result << CPUTestsBase::getTestCaseName(cpuParams);
+
+ return result.str();
+ }
+
+protected:
+ void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override {
+ std::vector<void*> inputValues = {sliceParams.start.data(),
+ sliceParams.stop.data(),
+ sliceParams.step.data(),
+ sliceParams.axes.data()};
+
+ inputs.clear();
+ const auto& funcInputs = function->inputs();
+ for (size_t i = 0; i < funcInputs.size(); ++i) {
+ const auto& funcInput = funcInputs[i];
+ ov::Tensor tensor;
+ if (i <= 1u) {
+ ov::test::utils::InputGenerateData in_data;
+ in_data.start_from = 1;
+ in_data.range = 10;
+ // Fill the slice input0 and input1 tensor with random data.
+ tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(),
+ targetInputStaticShapes[i],
+ in_data);
+ } else {
+ // Fill the slice input2~input5 with specified data.
+ tensor = ov::Tensor{ov::element::i64, targetInputStaticShapes[i], inputValues[i - 2]};
+ }
+ inputs.insert({funcInput.get_node_shared_ptr(), tensor});
+ }
+ }
+ void SetUp() override {
+ std::vector<InputShape> shapes;
+ ov::test::utils::InputLayerType secondaryInputType;
+ ElementType netPrecision;
+ CPUSpecificParams cpuParams;
+ std::tie(shapes, sliceParams, secondaryInputType, netPrecision, cpuParams) = this->GetParam();
+ std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
+
+ selectedType = makeSelectedTypeStr(selectedType, netPrecision);
+ targetDevice = ov::test::utils::DEVICE_CPU;
+ std::vector<InputShape> input_shapes = {shapes};
+ input_shapes.push_back(sliceParams.updates[0]);
+ init_input_shapes({input_shapes});
+ for (auto& targetShapes : targetStaticShapes) {
+ targetShapes.push_back({sliceParams.start.size()});
+ targetShapes.push_back({sliceParams.stop.size()});
+ targetShapes.push_back({sliceParams.step.size()});
+ if (!sliceParams.axes.empty())
+ targetShapes.push_back({sliceParams.axes.size()});
+ }
+
+ ov::ParameterVector params;
+ for (auto&& shape : inputDynamicShapes) {
+ params.push_back(std::make_shared<ov::op::v0::Parameter>(netPrecision, shape));
+ }
+ std::shared_ptr<ov::Node> sliceNode;
+ if (secondaryInputType == ov::test::utils::InputLayerType::PARAMETER) {
+ // Slice start, stop, step, axes are parameters.
+ auto startNode =
+ std::make_shared<ov::op::v0::Parameter>(ov::element::i64, ov::Shape{sliceParams.start.size()});
+ auto stopdNode =
+ std::make_shared<ov::op::v0::Parameter>(ov::element::i64, ov::Shape{sliceParams.stop.size()});
+ auto stepNode =
+ std::make_shared<ov::op::v0::Parameter>(ov::element::i64, ov::Shape{sliceParams.step.size()});
+
+ params.push_back(std::dynamic_pointer_cast<ov::op::v0::Parameter>(startNode));
+ params.push_back(std::dynamic_pointer_cast<ov::op::v0::Parameter>(stopdNode));
+ params.push_back(std::dynamic_pointer_cast<ov::op::v0::Parameter>(stepNode));
+ if (!sliceParams.axes.empty()) {
+ // With axes parameter
+ auto axesNode =
+ std::make_shared<ov::op::v0::Parameter>(ov::element::i64, ov::Shape{sliceParams.axes.size()});
+ params.push_back(std::dynamic_pointer_cast<ov::op::v0::Parameter>(axesNode));
+ sliceNode = std::make_shared<ov::op::v15::SliceScatter>(params[0],
+ params[1],
+ startNode,
+ stopdNode,
+ stepNode,
+ axesNode);
+ } else {
+ // without axes parameter
+ sliceNode =
+ std::make_shared<ov::op::v15::SliceScatter>(params[0], params[1], startNode, stopdNode, stepNode);
+ }
+ } else if (secondaryInputType == ov::test::utils::InputLayerType::CONSTANT) {
+ // Slice start, stop, step, axes are const.
+ ov::Shape constShape = {sliceParams.start.size()};
+ auto beginNode =
+ std::make_shared<ov::op::v0::Constant>(ov::element::i64, constShape, sliceParams.start.data());
+ auto endNode =
+ std::make_shared<ov::op::v0::Constant>(ov::element::i64, constShape, sliceParams.stop.data());
+ auto strideNode =
+ std::make_shared<ov::op::v0::Constant>(ov::element::i64, constShape, sliceParams.step.data());
+ if (!sliceParams.axes.empty()) {
+ // With axes parameter
+ auto axesNode =
+ std::make_shared<ov::op::v0::Constant>(ov::element::i64, constShape, sliceParams.axes.data());
+ sliceNode = std::make_shared<ov::op::v15::SliceScatter>(params[0],
+ params[1],
+ beginNode,
+ endNode,
+ strideNode,
+ axesNode);
+ } else {
+ // without axes parameter
+ sliceNode =
+ std::make_shared<ov::op::v15::SliceScatter>(params[0], params[1], beginNode, endNode, strideNode);
+ }
+ } else {
+ // Not supported others.
+ OPENVINO_THROW("SliceScatterLayerCPUTest: Unsupported ov::test::utils::InputLayerType , value: ",
+ secondaryInputType);
+ }
+
+ function = makeNgraphFunction(netPrecision, params, sliceNode, "SliceScatter");
+ }
+ SliceScatterSpecificParams sliceParams;
+};
+
+TEST_P(SliceScatterLayerCPUTest, CompareWithRefs) {
+ run();
+ CheckPluginRelatedResults(compiledModel, "SliceScatter");
+}
+
+namespace {
+
+const std::vector<ov::test::utils::InputLayerType> inputLayerTypes = {ov::test::utils::InputLayerType::CONSTANT,
+ ov::test::utils::InputLayerType::PARAMETER};
+
+const auto cpuParams_nhwc = CPUSpecificParams{{nhwc}, {nhwc}, {}, {}};
+const auto cpuParams_ndhwc = CPUSpecificParams{{ndhwc}, {ndhwc}, {}, {}};
+
+const auto cpuParams_nchw = CPUSpecificParams{{nchw}, {nchw}, {}, {}};
+const auto cpuParams_ncdhw = CPUSpecificParams{{ncdhw}, {ncdhw}, {}, {}};
+
+const std::vector<ElementType> inputPrecisions = {ElementType::f32, ElementType::bf16, ElementType::i8};
+
+const std::vector<std::vector<InputShape>> inputShapesDynamic2D = {
+ {{// Origin dynamic shape
+ {-1, -1},
+ {// Dynamic shapes instances
+ {32, 16},
+ {16, 16},
+ {24, 16}}}},
+ {{// Origin dynamic shape
+ {-1, 16},
+ {// Dynamic shapes instances
+ {16, 16},
+ {20, 16},
+ {32, 16}}}},
+ {{// Origin dynamic shape
+ {{16, 32}, {16, 32}},
+ {// Dynamic shapes instances
+ {16, 32},
+ {32, 16},
+ {24, 24}}}},
+};
+
+const std::vector<SliceScatterSpecificParams> paramsPlain2D = {
+ SliceScatterSpecificParams{{{{-1, -1}, {{16, 6}}}}, {0, 10}, {16, 16}, {1, 1}, {0, 1}},
+ SliceScatterSpecificParams{{{{-1, 3}, {{14, 3}}}}, {2, 5}, {16, 8}, {1, 1}, {}},
+ SliceScatterSpecificParams{{{{{{14, 32}, {3, 8}}}, {{14, 6}}}}, {2, 5}, {16, 16}, {1, 2}, {0, 1}},
+ SliceScatterSpecificParams{{{{-1, -1}, {{8, 16}}}}, {0, 0}, {16, 16}, {1, 2}, {1, 0}},
+ SliceScatterSpecificParams{{{{8, -1}, {{8, 8}}}}, {0, 8}, {16, 16}, {2, 1}, {1, 0}},
+};
+
+INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Static_2D,
+ SliceScatterLayerCPUTest,
+ ::testing::Combine(::testing::Values(static_shapes_to_test_representation({{32, 16}})),
+ ::testing::ValuesIn(paramsPlain2D),
+ ::testing::Values(ov::test::utils::InputLayerType::CONSTANT),
+ ::testing::ValuesIn(inputPrecisions),
+ ::testing::Values(emptyCPUSpec)),
+ SliceScatterLayerCPUTest::getTestCaseName);
+
+INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Dynamic_2D,
+ SliceScatterLayerCPUTest,
+ ::testing::Combine(::testing::ValuesIn(inputShapesDynamic2D),
+ ::testing::ValuesIn(paramsPlain2D),
+ ::testing::ValuesIn(inputLayerTypes),
+ ::testing::ValuesIn(inputPrecisions),
+ ::testing::Values(emptyCPUSpec)),
+ SliceScatterLayerCPUTest::getTestCaseName);
+
+const std::vector<SliceScatterSpecificParams> testCasesCommon4D = {
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1}, {{1, 2, 23, 23}}}}, {0, 2, 5, 4}, {1, 4, 28, 27}, {1, 1, 1, 1}, {}},
+ SliceScatterSpecificParams{{{{1, 2, 32, 20}, {{1, 2, 32, 20}}}},
+ {0, 1, 0, 0},
+ {20, 3, 32, 1},
+ {1, 1, 1, 1},
+ {3, 1, 2, 0}},
+ SliceScatterSpecificParams{{{{-1, {1, 4}, -1, {-1, 20}}, {{1, 3, 10, 20}}}},
+ {0, 0, 10, 0},
+ {1, 3, 20, 20},
+ {1, 1, 1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{-1, 5, {4, 6}, {-1, 3}}, {{1, 5, 5, 3}}}},
+ {0, 0, 20, 20},
+ {1, 5, 26, 25},
+ {1, 1, 2, 1},
+ {0, 1, 3, 2}},
+ SliceScatterSpecificParams{{{{{1, 3}, {1, 2}, {15, -1}, {9, 11}}, {{1, 2, 15, 10}}}},
+ {0, 0, 0, 20},
+ {1, 2, 30, 30},
+ {1, 1, 2, 1},
+ {}},
+ SliceScatterSpecificParams{{{{-1, 3, 30, 10}, {{1, 3, 30, 10}}}},
+ {0, 0, 2, 10},
+ {1, 3, 32, 20},
+ {1, 1, 1, 1},
+ {0, 1, 2, 3}},
+ SliceScatterSpecificParams{{{{{0, 64}, 4, 32, 20}, {{1, 4, 32, 20}}}},
+ {0, 1, 0, 10},
+ {1, 5, 32, 30},
+ {1, 1, 1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1}, {{1, 4, 30, 4}}}},
+ {0, 1, 2, 10},
+ {1, 5, 32, 18},
+ {1, 1, 1, 2},
+ {0, 1, 2, 3}},
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1}, {{1, 3, 30, 4}}}}, {0, 0, 2, 10}, {1, 8, 32, 18}, {1, 2, 1, 2}, {}},
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1}, {{1, 5, 32, 8}}}}, {0, 0, 10}, {25, 32, 18}, {5, 1, 1}, {0, 2, 3}},
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1}, {{1, 5, 8, 32}}}}, {15, 0, 0}, {30, 32, 32}, {2, 15, 1}, {2, 0, 3}},
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1}, {{0, 5, 8, 0}}}},
+ {15, 32, 64},
+ {30, 32, 128},
+ {2, 15, 1},
+ {2, 0, 3}}};
+
+const std::vector<std::vector<ov::Shape>> inputShapesStatic4D = {{{1, 5, 32, 32}}, {{2, 5, 32, 48}}};
+
+const std::vector<std::vector<InputShape>> inputShapesDynamic4D = {{{// Origin dynamic shape
+ {-1, -1, -1, -1},
+ {// Dynamic shapes instances
+ {1, 5, 32, 32},
+ {2, 5, 32, 32},
+ {1, 5, 64, 32}}}},
+ {{// Origin dynamic shape
+ {-1, 5, -1, -1},
+ {// Dynamic shapes instances
+ {1, 5, 32, 32},
+ {2, 5, 32, 32},
+ {3, 5, 32, 32}}}},
+ {{// Origin dynamic shape
+ {{1, 5}, 5, {32, 64}, {32, 64}},
+ {// Dynamic shapes instances
+ {2, 5, 32, 32},
+ {1, 5, 48, 32},
+ {5, 5, 32, 32}}}}};
+
+const std::vector<CPUSpecificParams> CPUParamsCommon4D = {
+ cpuParams_nchw,
+ cpuParams_nhwc,
+};
+
+INSTANTIATE_TEST_SUITE_P(
+ smoke_CompareWithRefs_Common_Static_4D,
+ SliceScatterLayerCPUTest,
+ ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesStatic4D)),
+ ::testing::ValuesIn(testCasesCommon4D),
+ ::testing::Values(ov::test::utils::InputLayerType::CONSTANT),
+ ::testing::ValuesIn(inputPrecisions),
+ ::testing::ValuesIn(CPUParamsCommon4D)),
+ SliceScatterLayerCPUTest::getTestCaseName);
+
+INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D,
+ SliceScatterLayerCPUTest,
+ ::testing::Combine(::testing::ValuesIn(inputShapesDynamic4D),
+ ::testing::ValuesIn(testCasesCommon4D),
+ ::testing::ValuesIn(inputLayerTypes),
+ ::testing::ValuesIn(inputPrecisions),
+ ::testing::ValuesIn(CPUParamsCommon4D)),
+ SliceScatterLayerCPUTest::getTestCaseName);
+
+const std::vector<SliceScatterSpecificParams> testCasesCommon5D = {
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1, -1}, {{1, 2, 5, 23, 23}}}},
+ {0, 2, 0, 5, 4},
+ {1, 4, 5, 28, 27},
+ {1, 1, 1, 1, 1},
+ {0, 1, 2, 3, 4}},
+ SliceScatterSpecificParams{{{{1, 5, 10, 32, 20}, {{1, 5, 10, 32, 20}}}},
+ {0, 0, 10, 0, 0},
+ {1, 5, 20, 32, 20},
+ {1, 1, 1, 1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{{0, 1}, {1, 3}, {5, 15}, {30, -1}, {-1, 20}}, {{1, 2, 10, 32, 20}}}},
+ {0, 1, 10, 0, 0},
+ {20, 3, 20, 32, 1},
+ {1, 1, 1, 1, 1},
+ {4, 1, 2, 3, 0}},
+ SliceScatterSpecificParams{{{{-1, -1, 20, 10, 3}, {{1, 3, 20, 10, 3}}}},
+ {0, 20, 0, 0, 20},
+ {1, 30, 20, 5, 26},
+ {1, 1, 1, 2, 2},
+ {0, 3, 2, 1, 4}},
+ SliceScatterSpecificParams{{{{{0, 128}, 2, 5, 30, 10}, {{1, 2, 5, 30, 10}}}},
+ {0, 0, 10, 0, 20},
+ {1, 2, 20, 30, 30},
+ {1, 1, 2, 1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1, -1}, {{1, 5, 8, 22, 20}}}},
+ {0, 0, 2, 10, 0},
+ {1, 5, 10, 32, 20},
+ {1, 1, 1, 1, 1},
+ {0, 1, 2, 3, 4}},
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1, -1}, {{1, 4, 20, 22, 32}}}},
+ {0, 1, 0, 10, 0},
+ {1, 5, 20, 32, 32},
+ {1, 1, 1, 1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1, -1}, {{1, 5, 5, 16, 16}}}},
+ {0, 0, 0, 0, 0},
+ {1, 5, 10, 16, 16},
+ {1, 1, 2, 1, 1},
+ {0, 1, 2, 3, 4}}};
+
+const std::vector<std::vector<ov::Shape>> inputShapesStatic5D = {{{1, 5, 20, 32, 32}}, {{2, 5, 32, 32, 32}}};
+
+const std::vector<std::vector<InputShape>> inputShapesDynamic5D = {{{// Origin dynamic shape
+ {-1, -1, -1, -1, -1},
+ {// Dynamic shapes instances
+ {1, 5, 32, 32, 32},
+ {1, 5, 32, 32, 48},
+ {1, 5, 64, 64, 64},
+ {1, 10, 32, 32, 32}}}},
+ {{// Origin dynamic shape
+ {-1, 5, -1, -1, -1},
+ {// Dynamic shapes instances
+ {1, 5, 32, 32, 48},
+ {1, 5, 32, 48, 32},
+ {1, 5, 48, 32, 32}}}},
+ {{// Origin dynamic shape
+ {{1, 5}, 5, {32, 64}, {32, 64}, {32, 64}},
+ {// Dynamic shapes instances
+ {2, 5, 32, 32, 32},
+ {1, 5, 48, 32, 32},
+ {5, 5, 32, 32, 48}}}}};
+
+const std::vector<CPUSpecificParams> CPUParamsCommon5D = {
+ cpuParams_ncdhw,
+ cpuParams_ndhwc,
+};
+
+INSTANTIATE_TEST_SUITE_P(
+ smoke_CompareWithRefs_Common_Static_5D,
+ SliceScatterLayerCPUTest,
+ ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesStatic5D)),
+ ::testing::ValuesIn(testCasesCommon5D),
+ ::testing::Values(ov::test::utils::InputLayerType::CONSTANT),
+ ::testing::ValuesIn(inputPrecisions),
+ ::testing::ValuesIn(CPUParamsCommon5D)),
+ SliceScatterLayerCPUTest::getTestCaseName);
+
+INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D,
+ SliceScatterLayerCPUTest,
+ ::testing::Combine(::testing::ValuesIn(inputShapesDynamic5D),
+ ::testing::ValuesIn(testCasesCommon5D),
+ ::testing::ValuesIn(inputLayerTypes),
+ ::testing::ValuesIn(inputPrecisions),
+ ::testing::ValuesIn(CPUParamsCommon5D)),
+ SliceScatterLayerCPUTest::getTestCaseName);
+
+const std::vector<SliceScatterSpecificParams> testCasesFullSlice5D = {
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1, -1}, {{1, 5, 32, 32, 32}}}}, {}, {}, {}, {}},
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1, -1}, {{1, 5, 32, 32, 32}}}}, {-64}, {64}, {1}, {-1}},
+ SliceScatterSpecificParams{{{{1, 5, 32, 32, 32}, {{1, 5, 32, 32, 32}}}},
+ {-64, 0, -32, 32},
+ {64, 33, 32, -33},
+ {1, 1, 1, -1},
+ {4, -2, 2, 1}},
+};
+
+const std::vector<std::vector<InputShape>> inputShapesFullSlice5D = {
+ {{{1, 5, 32, 32, 32}, {{1, 5, 32, 32, 32}}}},
+ {{{-1, -1, -1, -1, -1}, {{1, 5, 32, 32, 32}}}},
+ {{{-1, 5, -1, -1, -1}, {{1, 5, 32, 32, 32}}}},
+ {{{-1, 5, 32, {31, 64}, 32}, {{1, 5, 32, 32, 32}}}}};
+
+INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Full_Slice_5D,
+ SliceScatterLayerCPUTest,
+ ::testing::Combine(::testing::ValuesIn(inputShapesFullSlice5D),
+ ::testing::ValuesIn(testCasesFullSlice5D),
+ ::testing::Values(ov::test::utils::InputLayerType::CONSTANT),
+ ::testing::ValuesIn(inputPrecisions),
+ ::testing::ValuesIn(CPUParamsCommon5D)),
+ SliceScatterLayerCPUTest::getTestCaseName);
+} // namespace
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/slice_scatter.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/slice_scatter.cpp
new file mode 100644
index 00000000000..ef6dfa1af86
--- /dev/null
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/slice_scatter.cpp
@@ -0,0 +1,239 @@
+// Copyright (C) 2018-2024 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "single_op_tests/slice_scatter.hpp"
+
+#include <vector>
+
+#include "common_test_utils/test_constants.hpp"
+
+using ov::test::SliceScatterLayerTest;
+using ov::test::SliceScatterSpecificParams;
+
+namespace {
+
+const std::vector<ov::element::Type> model_types = {ov::element::f32, ov::element::bf16, ov::element::i8};
+
+const std::vector<ov::element::Type> model_types_extra = {ov::element::i64,
+ ov::element::i32,
+ ov::element::i16,
+ ov::element::u8};
+
+std::vector<SliceScatterSpecificParams> static_params = {
+ SliceScatterSpecificParams{{{{}, {{16}}}, {{}, {{8}}}}, {4}, {12}, {1}, {0}},
+ SliceScatterSpecificParams{{{{}, {{16}}}, {{}, {{4}}}}, {0}, {8}, {2}, {0}},
+ SliceScatterSpecificParams{{{{}, {{20, 10, 5}}}, {{}, {{20, 10, 5}}}}, {0, 0}, {10, 20}, {1, 1}, {1, 0}},
+ SliceScatterSpecificParams{{{{}, {{1, 2, 12, 100}}}, {{}, {{1, 1, 5, 10}}}},
+ {0, 1, 0, 1},
+ {1, 2, 5, 100},
+ {1, 1, 1, 10},
+ {}},
+ SliceScatterSpecificParams{{{{}, {{1, 12, 100}}}, {{}, {{1, 2, 1}}}}, {0, 9, 0}, {1, 11, 1}, {1, 1, 1}, {0, 1, -1}},
+ SliceScatterSpecificParams{{{{}, {{1, 12, 100}}}, {{}, {{1, 10, 10}}}},
+ {0, 1, 0},
+ {10, -1, 10},
+ {1, 1, 1},
+ {-3, -2, -1}},
+ SliceScatterSpecificParams{{{{}, {{2, 12, 100}}}, {{}, {{1, 4, 99}}}}, {1, 12, 100}, {0, 7, 0}, {-1, -1, -1}, {}},
+ SliceScatterSpecificParams{{{{}, {{2, 12, 100}}}, {{}, {{1, 3, 99}}}}, {1, 4, 99}, {0, 9, 0}, {-1, 2, -1}, {}},
+ SliceScatterSpecificParams{{{{}, {{2, 12, 100}}}, {{}, {{1, 4, 99}}}}, {-1, -1, -1}, {0, 4, 0}, {-1, -2, -1}, {}},
+ SliceScatterSpecificParams{{{{}, {{2, 12, 100}}}, {{}, {{1, 7, 99}}}},
+ {-1, -1, -1},
+ {0, 0, 4},
+ {-1, -1, -1},
+ {2, 0, 1}},
+ SliceScatterSpecificParams{{{{}, {{2, 12, 100}}}, {{}, {{1, 7, 95}}}},
+ {0, 0, 4},
+ {-5, -1, -1},
+ {1, 2, 1},
+ {2, 0, 1}},
+ SliceScatterSpecificParams{{{{}, {{2, 2, 2, 2}}}, {{}, {{2, 2, 2, 2}}}},
+ {0, 0, 0, 0},
+ {2, 2, 2, 2},
+ {1, 1, 1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{}, {{2, 2, 2, 2}}}, {{}, {{1, 1, 1, 1}}}},
+ {1, 1, 1, 1},
+ {2, 2, 2, 2},
+ {1, 1, 1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{}, {{2, 2, 4, 3}}}, {{}, {{2, 2, 2, 3}}}},
+ {0, 0, 0, 0},
+ {2, 2, 4, 3},
+ {1, 1, 2, 1},
+ {-4, 1, -2, 3}},
+ SliceScatterSpecificParams{{{{}, {{2, 2, 4, 2}}}, {{}, {{1, 2, 2, 1}}}},
+ {1, 0, 0, 1},
+ {2, 2, 4, 2},
+ {1, 1, 2, 1},
+ {}},
+ SliceScatterSpecificParams{{{{}, {{1, 2, 4, 2}}}, {{}, {{1, 1, 2, 1}}}},
+ {0, 1, 0, 1},
+ {10, 2, 4, 2},
+ {1, 1, 2, 1},
+ {}},
+ SliceScatterSpecificParams{{{{}, {{1, 2, 4, 2}}}, {{}, {{1, 1, 2, 1}}}},
+ {1, 0, 1, 0},
+ {2, 4, 2, 10},
+ {1, 2, 1, 1},
+ {-1, -2, -3, -4}},
+ SliceScatterSpecificParams{{{{}, {{10, 2, 4, 2}}}, {{}, {{9, 1, 3, 1}}}},
+ {9, 1, 3, 0},
+ {0, 0, 0, 1},
+ {-1, -1, -1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{}, {{10, 2, 4, 2}}}, {{}, {{9, 1, 3, 1}}}},
+ {19, 1, -1, 0},
+ {-10, 0, 0, -1},
+ {-1, -1, -1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{}, {{3, 2, 4, 200}}}, {{}, {{3, 1, 2, 199}}}},
+ {0, 1, -1, -1},
+ {3, 2, 0, 0},
+ {1, 1, -2, -1},
+ {}},
+ SliceScatterSpecificParams{{{{}, {{2, 4, 5, 5, 68}}}, {{}, {{2, 3, 5, 5, 5}}}},
+ {0, 1, 0, 0, 0},
+ {std::numeric_limits<std::int64_t>::max(),
+ std::numeric_limits<std::int64_t>::max(),
+ std::numeric_limits<std::int64_t>::max(),
+ std::numeric_limits<std::int64_t>::max(),
+ std::numeric_limits<std::int64_t>::max()},
+ {1, 1, 1, 1, 16},
+ {}},
+ SliceScatterSpecificParams{{{{}, {{10, 12}}}, {{}, {{10, 9}}}}, {-1, 1}, {-9999, 10}, {-1, 1}, {}},
+ SliceScatterSpecificParams{{{{}, {{5, 5, 5, 5}}}, {{}, {{5, 4, 5, 4}}}},
+ {-1, 0, -1, 0},
+ {-50, -1, -60, -1},
+ {-1, 1, -1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{}, {{1, 5, 32, 32}}}, {{}, {{1, 2, 23, 23}}}},
+ {0, 2, 5, 4},
+ {1, 4, 28, 27},
+ {1, 1, 1, 1},
+ {0, 1, 2, 3}},
+ SliceScatterSpecificParams{{{{}, {{1, 5, 32, 20}}}, {{}, {{1, 2, 32, 20}}}},
+ {0, 1, 0, 0},
+ {1, 3, 32, 20},
+ {1, 1, 1, 1},
+ {0, 1, 2, 3}},
+ SliceScatterSpecificParams{{{{}, {{2, 5, 32, 20}}}, {{}, {{1, 3, 10, 20}}}},
+ {0, 0, 10, 0},
+ {1, 3, 20, 20},
+ {1, 1, 1, 1},
+ {0, 1, 2, 3}},
+ SliceScatterSpecificParams{{{{}, {{1, 5, 32, 32}}}, {{}, {{1, 5, 5, 3}}}},
+ {0, 0, 20, 20},
+ {1, 5, 25, 26},
+ {1, 1, 1, 2},
+ {0, 1, 2, 3}},
+ SliceScatterSpecificParams{{{{}, {{2, 5, 32, 32}}}, {{}, {{1, 2, 15, 10}}}},
+ {0, 0, 0, 20},
+ {1, 2, 30, 30},
+ {1, 1, 2, 1},
+ {0, 1, 2, 3}},
+ SliceScatterSpecificParams{{{{}, {{1, 5, 32, 20}}}, {{}, {{1, 3, 30, 10}}}},
+ {0, 0, 2, 10},
+ {1, 3, 32, 20},
+ {1, 1, 1, 1},
+ {0, 1, 2, 3}},
+ SliceScatterSpecificParams{{{{}, {{2, 5, 32, 32}}}, {{}, {{1, 4, 32, 20}}}},
+ {0, 1, 0, 10},
+ {1, 5, 32, 30},
+ {1, 1, 1, 1},
+ {0, 1, 2, 3}},
+ SliceScatterSpecificParams{{{{}, {{1, 5, 32, 20}}}, {{}, {{1, 4, 30, 4}}}},
+ {0, 1, 2, 10},
+ {1, 5, 32, 18},
+ {1, 1, 1, 2},
+ {0, 1, 2, 3}},
+ SliceScatterSpecificParams{{{{}, {{2, 8, 32, 20}}}, {{}, {{1, 4, 30, 4}}}},
+ {0, 0, 2, 10},
+ {1, 8, 32, 18},
+ {1, 2, 1, 2},
+ {0, 1, 2, 3}},
+ SliceScatterSpecificParams{{{{}, {{2, 8, 32, 20}}}, {{}, {{2, 3, 15, 20}}}},
+ {0, -20, -15},
+ {2, -5, 3},
+ {1, 1, 1},
+ {0, 2, 1}}};
+
+INSTANTIATE_TEST_SUITE_P(smoke_Static,
+ SliceScatterLayerTest,
+ ::testing::Combine(::testing::ValuesIn(static_params),
+ ::testing::ValuesIn(model_types),
+ ::testing::Values(ov::test::utils::DEVICE_CPU)),
+ SliceScatterLayerTest::getTestCaseName);
+
+INSTANTIATE_TEST_SUITE_P(smoke_PrecisionTransformation,
+ SliceScatterLayerTest,
+ ::testing::Combine(::testing::Values(static_params[0]),
+ ::testing::ValuesIn(model_types_extra),
+ ::testing::Values(ov::test::utils::DEVICE_CPU)),
+ SliceScatterLayerTest::getTestCaseName);
+
+std::vector<SliceScatterSpecificParams> dynamic_params = {
+ SliceScatterSpecificParams{{{{-1}, {{8}, {16}}}, {{-1}, {{4}, {8}}}}, {4}, {12}, {1}, {0}},
+ SliceScatterSpecificParams{{{{ov::Dimension(2, 20)}, {{5}, {15}}}, {{ov::Dimension(2, 20)}, {{3}, {4}}}},
+ {0},
+ {8},
+ {2},
+ {0}},
+ SliceScatterSpecificParams{{{{-1, -1, -1}, {{20, 10, 5}, {5, 10, 20}}}, {{-1, -1, -1}, {{20, 10, 5}, {5, 10, 20}}}},
+ {0, 0},
+ {10, 20},
+ {1, 1},
+ {1, 0}},
+ SliceScatterSpecificParams{{{{-1, -1, -1, -1}, {{1, 2, 12, 100}}}, {{-1, -1, -1, -1}, {{1, 1, 5, 10}}}},
+ {0, 1, 0, 1},
+ {1, 2, 5, 100},
+ {1, 1, 1, 10},
+ {}},
+ SliceScatterSpecificParams{{{{-1, ov::Dimension(2, 20), -1}, {{2, 12, 100}, {2, 3, 100}}},
+ {{-1, ov::Dimension(0, 5), -1}, {{1, 2, 1}, {1, 0, 1}}}},
+ {0, 9, 0},
+ {1, 11, 1},
+ {1, 1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{ov::Dimension(1, 5), ov::Dimension(1, 5), ov::Dimension(1, 5), ov::Dimension(1, 5)},
+ {{2, 2, 2, 2}, {2, 2, 4, 3}, {2, 2, 4, 2}, {1, 2, 4, 2}}},
+ {{ov::Dimension(1, 5), ov::Dimension(1, 5), ov::Dimension(1, 5), ov::Dimension(1, 5)},
+ {{2, 2, 2, 2}, {2, 2, 2, 2}, {2, 2, 2, 2}, {1, 2, 2, 2}}}},
+ {0, 0, 0, 0},
+ {2, 2, 2, 2},
+ {1, 1, 1, 1},
+ {}},
+ SliceScatterSpecificParams{{{{-1, ov::Dimension(1, 5), ov::Dimension(1, 5), -1}, {{10, 2, 4, 2}, {10, 4, 2, 2}}},
+ {{-1, ov::Dimension(1, 5), ov::Dimension(1, 5), -1}, {{9, 1, 3, 1}, {9, 1, 1, 1}}}},
+ {9, 1, 3, 0},
+ {0, 0, 0, 1},
+ {-1, -1, -1, 1},
+ {}},
+ SliceScatterSpecificParams{
+ {{{-1, ov::Dimension(1, 5), -1, -1, ov::Dimension(30, 70)}, {{2, 4, 5, 5, 68}, {2, 3, 7, 7, 33}}},
+ {{-1, ov::Dimension(1, 5), -1, -1, ov::Dimension(1, 7)}, {{2, 3, 5, 5, 5}, {2, 2, 7, 7, 3}}}},
+ {0, 1, 0, 0, 0},
+ {std::numeric_limits<std::int64_t>::max(),
+ std::numeric_limits<std::int64_t>::max(),
+ std::numeric_limits<std::int64_t>::max(),
+ std::numeric_limits<std::int64_t>::max(),
+ std::numeric_limits<std::int64_t>::max()},
+ {1, 1, 1, 1, 16},
+ {}},
+ SliceScatterSpecificParams{{{{ov::Dimension(1, 5), ov::Dimension(1, 7), ov::Dimension(1, 35), ov::Dimension(1, 35)},
+ {{1, 5, 16, 32}, {2, 5, 32, 20}, {2, 5, 32, 32}}},
+ {{ov::Dimension(1, 5), ov::Dimension(1, 7), ov::Dimension(1, 35), ov::Dimension(1, 35)},
+ {{1, 2, 11, 23}, {1, 2, 23, 16}, {1, 2, 23, 23}}}},
+ {0, 2, 5, 4},
+ {1, 4, 28, 27},
+ {1, 1, 1, 1},
+ {0, 1, 2, 3}}};
+
+INSTANTIATE_TEST_SUITE_P(smoke_Dynamic,
+ SliceScatterLayerTest,
+ ::testing::Combine(::testing::ValuesIn(dynamic_params),
+ ::testing::ValuesIn(model_types),
+ ::testing::Values(ov::test::utils::DEVICE_CPU)),
+ SliceScatterLayerTest::getTestCaseName);
+} // namespace
diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/slice_scatter.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/slice_scatter.hpp
new file mode 100644
index 00000000000..1039fc31574
--- /dev/null
+++ b/src/tests/functional/plugin/shared/include/single_op_tests/slice_scatter.hpp
@@ -0,0 +1,15 @@
+// Copyright (C) 2018-2024 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "shared_test_classes/single_op/slice_scatter.hpp"
+
+namespace ov {
+namespace test {
+TEST_P(SliceScatterLayerTest, Inference) {
+ run();
+}
+} // namespace test
+} // namespace ov
diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/slice_scatter.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/slice_scatter.hpp
new file mode 100644
index 00000000000..9887b9ddfb8
--- /dev/null
+++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/slice_scatter.hpp
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright (C) 2018-2024 Intel Corporation
+//
+
+#pragma once
+
+#include <memory>
+#include <string>
+#include <tuple>
+#include <vector>
+
+#include "shared_test_classes/base/ov_subgraph.hpp"
+
+namespace ov {
+namespace test {
+struct SliceScatterSpecificParams {
+ std::vector<InputShape> shapes;
+ std::vector<int64_t> start;
+ std::vector<int64_t> stop;
+ std::vector<int64_t> step;
+ std::vector<int64_t> axes;
+};
+
+using SliceScatterParams = std::tuple<
+ SliceScatterSpecificParams, // SliceScatter specific parameters
+ ov::element::Type, // Model type
+ ov::test::TargetDevice // Device name
+>;
+
+class SliceScatterLayerTest : public testing::WithParamInterface<SliceScatterParams>,
+ virtual public ov::test::SubgraphBaseTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<SliceScatterParams> &obj);
+
+protected:
+ void SetUp() override;
+};
+} // namespace test
+} // namespace ov
diff --git a/src/tests/functional/shared_test_classes/src/single_op/slice_scatter.cpp b/src/tests/functional/shared_test_classes/src/single_op/slice_scatter.cpp
new file mode 100644
index 00000000000..27538e11a50
--- /dev/null
+++ b/src/tests/functional/shared_test_classes/src/single_op/slice_scatter.cpp
@@ -0,0 +1,65 @@
+// Copyright (C) 2018-2024 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "shared_test_classes/single_op/slice_scatter.hpp"
+
+namespace ov {
+namespace test {
+std::string SliceScatterLayerTest::getTestCaseName(const testing::TestParamInfo<SliceScatterParams> &obj) {
+ SliceScatterSpecificParams params;
+ ov::element::Type model_type;
+ std::string target_device;
+ std::tie(params, model_type, target_device) = obj.param;
+ std::ostringstream result;
+ result << "IS=(";
+ for (size_t i = 0lu; i < params.shapes.size(); i++) {
+ result << ov::test::utils::partialShape2str({params.shapes[i].first})
+ << (i < params.shapes.size() - 1lu ? "_" : "");
+ }
+ result << ")_TS=";
+ for (size_t i = 0lu; i < params.shapes.front().second.size(); i++) {
+ result << "{";
+ for (size_t j = 0lu; j < params.shapes.size(); j++) {
+ result << ov::test::utils::vec2str(params.shapes[j].second[i]) << (j < params.shapes.size() - 1lu ? "_" : "");
+ }
+ result << "}_";
+ }
+ result << "start=" << ov::test::utils::vec2str(params.start) << "_";
+ result << "stop=" << ov::test::utils::vec2str(params.stop) << "_";
+ result << "step=" << ov::test::utils::vec2str(params.step) << "_";
+ result << "axes=" << ov::test::utils::vec2str(params.axes) << "_";
+ result << "modelType=" << model_type.to_string() << "_";
+ result << "trgDev=" << target_device;
+ return result.str();
+}
+
+void SliceScatterLayerTest::SetUp() {
+ SliceScatterSpecificParams test_params;
+ ov::element::Type model_type;
+ std::tie(test_params, model_type, targetDevice) = this->GetParam();
+
+ init_input_shapes(test_params.shapes);
+
+ auto data = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes[0]);
+ auto updates = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes[1]);
+ ov::Shape const_shape = {test_params.start.size()};
+
+ ASSERT_EQ(shape_size(const_shape), test_params.stop.size());
+ ASSERT_EQ(shape_size(const_shape), test_params.step.size());
+
+ auto begin_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, test_params.start.data());
+ auto end_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, test_params.stop.data());
+ auto stride_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, test_params.step.data());
+ std::shared_ptr<ov::op::v15::SliceScatter> slice_scatter;
+ if (!test_params.axes.empty()) {
+ ASSERT_EQ(shape_size(const_shape), test_params.axes.size());
+ auto axesNode = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, test_params.axes.data());
+ slice_scatter = std::make_shared<ov::op::v15::SliceScatter>(data, updates, begin_node, end_node, stride_node, axesNode);
+ } else {
+ slice_scatter = std::make_shared<ov::op::v15::SliceScatter>(data, updates, begin_node, end_node, stride_node);
+ }
+ function = std::make_shared<ov::Model>(slice_scatter->outputs(), ov::ParameterVector{data, updates}, "SliceScatter-15");
+}
+} // namespace test
+} // namespace ov