OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] Add SliceScatter-15 op support (#34085)
Wilson Seoka435286a495c
diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/slice_scatter.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/slice_scatter.hppnew file mode 100644index 00000000000..00b0a5a7308--- /dev/null+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/slice_scatter.hpp@@ -0,0 +1,38 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once+#include "primitive.hpp"++namespace cldnn {++/// @brief SliceScatter operation.+/// @details Creates a copy of `data` tensor and updates it with `updates` at positions+/// specified by start/stop/step/axes slicing parameters.+struct slice_scatter : public primitive_base<slice_scatter> {+ CLDNN_DECLARE_PRIMITIVE(slice_scatter)++ slice_scatter() : primitive_base("", {}) {}++ /// @brief Constructs slice_scatter primitive.+ /// @param id This primitive id.+ /// @param inputs List of primitive ids: data, updates, start, stop, step, [axes].+ slice_scatter(const primitive_id& id,+ const std::vector<input_info>& inputs)+ : primitive_base{id, inputs}+ {}++ bool operator==(const primitive& rhs) const override {+ return compare_common_params(rhs);+ }++ void save(BinaryOutputBuffer& ob) const override {+ primitive_base<slice_scatter>::save(ob);+ }++ void load(BinaryInputBuffer& ib) override {+ primitive_base<slice_scatter>::load(ib);+ }+};+} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.cppnew file mode 100644index 00000000000..7835f538600--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.cpp@@ -0,0 +1,358 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#include "slice_scatter.hpp"++#include <numeric>++#include "common_utils/jitter.hpp"+#include "data_inst.h"+#include "intel_gpu/primitives/slice_scatter.hpp"+#include "ocl_v2/utils/jitter.hpp"+#include "primitive_inst.h"+#include "primitive_ocl_base.hpp"+#include "slice_scatter_inst.h"+#include "utils/kernel_generator.hpp"++namespace ov::intel_gpu::ocl {++namespace {++static constexpr size_t MAX_SUPPORTED_DIM = 5;+static constexpr size_t VEC_SIZE = 8;+static constexpr size_t SIMD_SIZE = 16;++// SliceScatter input port indices+static constexpr size_t kData = 0;+static constexpr size_t kUpdates = 1;+static constexpr size_t kStart = 2;+// kStop = 3 (not used by kernel)+static constexpr size_t kStep = 4;+static constexpr size_t kAxes = 5;++enum KernelsTypes {+ UPDATE_REF = 0,+ UPDATE_OPT,+};++// --- Helper to extract compile-time constant integer data ---++template <typename T, class = typename std::enable_if<std::is_integral<T>::value>::type>+std::vector<int64_t> extractTypedIntegerData(const data_node& node, const stream& stream) {+ mem_lock<T, mem_lock_type::read> lock{node.get_attached_memory_ptr(), stream};+ T* data_ptr = lock.data();+ std::vector<int64_t> result;+ result.reserve(node.get_output_layout().count());+ for (size_t i = 0; i < node.get_output_layout().count(); i++) {+ result.emplace_back(static_cast<int64_t>(data_ptr[i]));+ }+ return result;+}++std::vector<int64_t> extractIntegerData(const data_node& node, const stream& stream) {+ auto dt = node.get_output_layout().data_type;+ switch (dt) {+ case data_types::u8:+ return extractTypedIntegerData<uint8_t>(node, stream);+ case data_types::i8:+ return extractTypedIntegerData<int8_t>(node, stream);+ case data_types::i32:+ return extractTypedIntegerData<int32_t>(node, stream);+ case data_types::i64:+ return extractTypedIntegerData<int64_t>(node, stream);+ default:+ OPENVINO_THROW("[GPU] SliceScatter parameters should be of integral type, got ", dt);+ }+ return {};+}++// --- Configuration for compile-time vs runtime parameters ---++struct ParamConfig {+ std::vector<int64_t> compile_time_start; // empty => dynamic (buffer passed at runtime)+ std::vector<int64_t> compile_time_step;+ std::vector<int64_t> compile_time_axes;+ ov::element::Type start_data_type = ov::element::i64;+ ov::element::Type step_data_type = ov::element::i64;+ ov::element::Type axes_data_type = ov::element::i64;+ size_t input_rank = 4;+};++ParamConfig getParamConfig(const program_node& node, const RuntimeParams& params) {+ ParamConfig config;+ config.input_rank = params.get_input_layout(kData).get_partial_shape().size();+ const auto& deps = node.get_dependencies();+ const auto& strm = node.get_program().get_stream();++ // Start+ if (deps.size() > kStart && deps[kStart].first->is_constant()) {+ config.compile_time_start = extractIntegerData(deps[kStart].first->as<data>(), strm);+ } else if (deps.size() <= kStart) {+ config.compile_time_start.resize(config.input_rank, 0);+ } else {+ config.start_data_type = deps[kStart].first->get_output_layout(0).data_type;+ }++ // Step+ if (deps.size() > kStep && deps[kStep].first->is_constant()) {+ config.compile_time_step = extractIntegerData(deps[kStep].first->as<data>(), strm);+ } else if (deps.size() <= kStep) {+ config.compile_time_step.resize(config.input_rank, 1);+ } else {+ config.step_data_type = deps[kStep].first->get_output_layout(0).data_type;+ }++ // Axes+ if (deps.size() > kAxes && deps[kAxes].first->is_constant()) {+ config.compile_time_axes = extractIntegerData(deps[kAxes].first->as<data>(), strm);+ for (auto& axis : config.compile_time_axes) {+ if (axis < 0)+ axis += static_cast<int64_t>(config.input_rank);+ }+ } else if (deps.size() <= kAxes) {+ config.compile_time_axes.resize(config.input_rank);+ std::iota(config.compile_time_axes.begin(), config.compile_time_axes.end(), 0);+ } else {+ config.axes_data_type = deps[kAxes].first->get_output_layout(0).data_type;+ }++ return config;+}++// --- JIT generation for buffer parameters ---++void addJitConstantsForParam(JitConstants& jit,+ const std::string& name,+ const std::vector<int64_t>& compile_time_param,+ ov::element::Type data_type,+ bool is_axes) {+ const std::string BUFF_CONST_NAME = name + "_BUFFER";+ const std::string BUFF_PTR_NAME = name + "_buffer_ptr";++ if (compile_time_param.empty()) {+ // Dynamic: generate buffer pointer declaration for kernel signature+ const std::string type_str = to_ocl_type(data_type);+ jit.add(make_jit_constant(BUFF_CONST_NAME, "__global const " + type_str + "* restrict " + BUFF_PTR_NAME + ","));++ for (size_t i = 0; i < MAX_SUPPORTED_DIM; ++i) {+ const std::string i_str = std::to_string(i);+ const std::string jit_name = name + "_VAL" + i_str;+ std::string access_str;+ if (is_axes) {+ access_str = BUFF_PTR_NAME + "[" + i_str + "] < 0 ? INPUT0_DIMS + " + BUFF_PTR_NAME + "[" + i_str + "] : " + BUFF_PTR_NAME + "[" + i_str + "]";+ } else {+ access_str = BUFF_PTR_NAME + "[" + i_str + "]";+ }+ jit.add(make_jit_constant(jit_name, i_str + " < AXES_BUFFER_SIZE ? (" + access_str + ") : -1"));+ }+ } else {+ // Static: embed values directly as JIT constants+ jit.add(make_jit_constant(BUFF_CONST_NAME, ""));+ for (size_t i = 0; i < MAX_SUPPORTED_DIM; ++i) {+ const std::string jit_name = name + "_VAL" + std::to_string(i);+ const int64_t val = i < compile_time_param.size() ? compile_time_param[i] : -1;+ jit.add(make_jit_constant(jit_name, val));+ }+ }+}++// --- Kernel Generators ---++class SliceScatterBase : public KernelGenerator {+public:+ explicit SliceScatterBase(std::string_view name, const ParamConfig* config) : KernelGenerator(name), m_config(config) {}++protected:+ const ParamConfig* m_config;++ [[nodiscard]] JitConstants get_jit_constants(const RuntimeParams& params) const override {+ auto jit = KernelGenerator::get_jit_constants(params);++ // AXES_BUFFER_SIZE+ if (m_config->compile_time_axes.empty()) {+ // Dynamic axes: derive size from the axes tensor (INPUT5)+ // Axes is a 1D tensor, so batch dimension holds the element count in bfyx format+ jit.add(make_jit_constant("AXES_BUFFER_SIZE", "INPUT5_BATCH_NUM"));+ } else {+ jit.add(make_jit_constant("AXES_BUFFER_SIZE", static_cast<int64_t>(m_config->compile_time_axes.size())));+ }++ addJitConstantsForParam(jit, "START", m_config->compile_time_start, m_config->start_data_type, false);+ addJitConstantsForParam(jit, "STEP", m_config->compile_time_step, m_config->step_data_type, false);+ addJitConstantsForParam(jit, "AXES", m_config->compile_time_axes, m_config->axes_data_type, true);++ return jit;+ }++ [[nodiscard]] Arguments get_arguments_desc(const RuntimeParams& params) const override {+ Arguments args;++ if (params.is_dynamic()) {+ args.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ }++ // data (INPUT0) and updates (INPUT1) are always needed+ args.push_back({ArgumentDescriptor::Types::INPUT, 0});+ args.push_back({ArgumentDescriptor::Types::INPUT, 1});++ // start (INPUT2) - only if dynamic+ if (m_config->compile_time_start.empty()) {+ args.push_back({ArgumentDescriptor::Types::INPUT, static_cast<uint32_t>(kStart)});+ }++ // step (INPUT4) - only if dynamic (subclass may override for opt kernel)+ if (include_step_arg() && m_config->compile_time_step.empty()) {+ args.push_back({ArgumentDescriptor::Types::INPUT, static_cast<uint32_t>(kStep)});+ }++ // axes (INPUT5) - only if dynamic+ if (m_config->compile_time_axes.empty()) {+ args.push_back({ArgumentDescriptor::Types::INPUT, static_cast<uint32_t>(kAxes)});+ }++ args.push_back({ArgumentDescriptor::Types::OUTPUT, 0});++ return args;+ }++ virtual bool include_step_arg() const {+ return true;+ }+};++class SliceScatterRef : public SliceScatterBase {+public:+ explicit SliceScatterRef(const ParamConfig* config) : SliceScatterBase("slice_scatter_ref", config) {}++protected:+ [[nodiscard]] DispatchDataFunc get_dispatch_data_func() const override {+ return DispatchDataFunc{[](const RuntimeParams& params, KernelData& kd, ImplRuntimeParams*) {+ const auto& updates_l = params.get_input_layout(kUpdates);+ auto b = extract_channel(ChannelName::BATCH, updates_l);+ auto f = extract_channel(ChannelName::FEATURE, updates_l);+ auto z = extract_channel(ChannelName::Z, updates_l);+ auto y = extract_channel(ChannelName::Y, updates_l);+ auto x = extract_channel(ChannelName::X, updates_l);++ auto& wgs = kd.params.workGroups;+ wgs.global = {b, f, z * y * x};+ wgs.local = ov::intel_gpu::get_optimal_lws(wgs.global, params.get_device_info());+ }};+ }+};++class SliceScatterOpt : public SliceScatterBase {+public:+ explicit SliceScatterOpt(const ParamConfig* config) : SliceScatterBase("slice_scatter_opt", config) {}++protected:+ // Opt kernel has step=1 hardcoded, so step buffer is never a kernel argument+ bool include_step_arg() const override {+ return false;+ }++ [[nodiscard]] JitConstants get_jit_constants(const RuntimeParams& params) const override {+ auto jit = KernelGenerator::get_jit_constants(params);++ jit.add(make_jit_constant("SLICE_SCATTER_VEC_SIZE", static_cast<int64_t>(VEC_SIZE)));+ jit.add(make_jit_constant("SIMD_SIZE", static_cast<int64_t>(SIMD_SIZE)));++ // AXES_BUFFER_SIZE+ if (m_config->compile_time_axes.empty()) {+ jit.add(make_jit_constant("AXES_BUFFER_SIZE", "INPUT5_BATCH_NUM"));+ } else {+ jit.add(make_jit_constant("AXES_BUFFER_SIZE", static_cast<int64_t>(m_config->compile_time_axes.size())));+ }++ // START and AXES follow the config+ addJitConstantsForParam(jit, "START", m_config->compile_time_start, m_config->start_data_type, false);+ addJitConstantsForParam(jit, "AXES", m_config->compile_time_axes, m_config->axes_data_type, true);++ // STEP is always compile-time 1 for opt kernel+ jit.add(make_jit_constant("STEP_BUFFER", ""));+ for (size_t i = 0; i < MAX_SUPPORTED_DIM; ++i) {+ jit.add(make_jit_constant("STEP_VAL" + std::to_string(i), 1));+ }++ return jit;+ }++ [[nodiscard]] DispatchDataFunc get_dispatch_data_func() const override {+ return DispatchDataFunc{[](const RuntimeParams& params, KernelData& kd, ImplRuntimeParams*) {+ const auto& updates_l = params.get_input_layout(kUpdates);+ auto b = extract_channel(ChannelName::BATCH, updates_l);+ auto f = extract_channel(ChannelName::FEATURE, updates_l);+ auto z = extract_channel(ChannelName::Z, updates_l);+ auto y = extract_channel(ChannelName::Y, updates_l);+ auto x = extract_channel(ChannelName::X, updates_l);++ const size_t total_spatial = z * y * x;+ const size_t num_blocks = (total_spatial + VEC_SIZE - 1) / VEC_SIZE;++ auto& wgs = kd.params.workGroups;+ wgs.global = {b, f, num_blocks};+ wgs.local = ov::intel_gpu::get_optimal_lws(wgs.global, params.get_device_info());+ }};+ }+};++// --- PrimitiveImplOCL ---++class SliceScatterImpl : public PrimitiveImplOCL {+public:+ DECLARE_OBJECT_TYPE_SERIALIZATION(ov::intel_gpu::ocl::SliceScatterImpl)++ ParamConfig m_config;+ Stage::Ptr ref_stage = make_stage<SliceScatterRef>(&m_config);+ Stage::Ptr opt_stage = make_stage<SliceScatterOpt>(&m_config);++ SliceScatterImpl() : PrimitiveImplOCL(SliceScatter::get_type_info_static()) {}+ SliceScatterImpl(const program_node& node, const RuntimeParams& params) : SliceScatterImpl() {+ m_config = getParamConfig(node, params);+ add_stage(ref_stage, params);+ if (canCompileOpt()) {+ add_stage(opt_stage, params);+ }+ }++ [[nodiscard]] std::unique_ptr<primitive_impl> clone() const override {+ auto copy = make_deep_copy<SliceScatterImpl>(this);+ copy->m_config = m_config;+ return copy;+ }++ std::vector<size_t> get_stages_execution_order(const cldnn::primitive_inst& instance) const override {+ if (canCompileOpt()) {+ auto params = instance.get_impl_params();+ auto x = extract_channel(ChannelName::X, params->get_input_layout(kUpdates));+ if (x >= VEC_SIZE) {+ return {KernelsTypes::UPDATE_OPT};+ }+ }+ return {KernelsTypes::UPDATE_REF};+ }++private:+ bool canCompileOpt() const {+ // Opt kernel requires all steps to be compile-time 1+ if (m_config.compile_time_step.empty())+ return false;+ for (auto s : m_config.compile_time_step) {+ if (s != 1)+ return false;+ }+ return true;+ }+};++} // namespace++std::unique_ptr<primitive_impl> SliceScatter::create_impl(const program_node& node, const RuntimeParams& params) const {+ assert(node.is_type<slice_scatter>());+ return std::make_unique<SliceScatterImpl>(node, params);+}++} // namespace ov::intel_gpu::ocl++BIND_BINARY_BUFFER_WITH_TYPE(cldnn::slice_scatter)+BIND_BINARY_BUFFER_WITH_TYPE(ov::intel_gpu::ocl::SliceScatterImpl)diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.hppnew file mode 100644index 00000000000..2f471900744--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.hpp@@ -0,0 +1,53 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "program_node.h"+#include "registry/implementation_manager.hpp"++using namespace cldnn; // TODO: Remove once namespaces are aligned+namespace ov::intel_gpu::ocl {++struct SliceScatter : public ImplementationManager {+ OV_GPU_PRIMITIVE_IMPL("ocl::slice_scatter")+ explicit SliceScatter(shape_types shape_type, ValidateFunc vf = nullptr) : ImplementationManager(impl_types::ocl, shape_type, std::move(vf)) {}++ [[nodiscard]] std::unique_ptr<primitive_impl> create_impl(const program_node& node, const RuntimeParams& params) const override;++ [[nodiscard]] bool validate_impl(const program_node& node) const override {+ static constexpr std::array supported_types = {+ ov::element::f32,+ ov::element::f16,+ ov::element::i32,+ ov::element::i64,+ ov::element::i8,+ ov::element::u8,+ };++ static constexpr std::array supported_fmts = {+ format::bfyx,+ format::bfzyx,+ };++ const auto& in0_layout = node.get_input_layout(0);+ const auto& out_layout = node.get_output_layout(0);++ if (!one_of(in0_layout.data_type, supported_types) || !one_of(out_layout.data_type, supported_types))+ return false;++ if (!one_of(in0_layout.format, supported_fmts) || !one_of(out_layout.format, supported_fmts))+ return false;++ if (out_layout.get_rank() > 5)+ return false;++ if (node.has_fused_primitives())+ return false;++ return true;+ }+};++} // namespace ov::intel_gpu::ocldiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter_opt.cl b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter_opt.clnew file mode 100644index 00000000000..92e62dcb138--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter_opt.cl@@ -0,0 +1,165 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+// SliceScatter optimized kernel.+// Uses sub-group block writes for contiguous inner-dimension scatters.+// Condition: step == 1 on all axes, so the slice region is contiguous.+// Dispatched over updates (INPUT1) dimensions with vectorized inner-dim processing.++#include "include/batch_headers/fetch_data.cl"++#define BRING_INTO_RANGE(VAL, MAX) \+ clamp((long)VAL < 0l ? (long)VAL + (long)MAX : (long)VAL, 0l, (long)MAX - 1l);++#if INPUT0_DIMS < 5+#define LOAD_BUFFER(in_prefix, out_name) \+ long out_name[INPUT0_DIMS]; \+ out_name[0] = in_prefix##_VAL0; \+ out_name[1] = in_prefix##_VAL1; \+ out_name[2] = in_prefix##_VAL2; \+ out_name[3] = in_prefix##_VAL3;+#else+#define LOAD_BUFFER(in_prefix, out_name) \+ long out_name[INPUT0_DIMS]; \+ out_name[0] = in_prefix##_VAL0; \+ out_name[1] = in_prefix##_VAL1; \+ out_name[2] = in_prefix##_VAL2; \+ out_name[3] = in_prefix##_VAL3; \+ out_name[4] = in_prefix##_VAL4;+#endif++#define VEC_SIZE SLICE_SCATTER_VEC_SIZE+#define SUBGROUP_SIZE get_sub_group_size()++#if VEC_SIZE == 8+ #define VEC_TYPE MAKE_VECTOR_TYPE(INPUT1_TYPE, 8)+ #define VLOAD(offset, ptr) vload8(offset, ptr)+ #define VSTORE(val, offset, ptr) vstore8(val, offset, ptr)+#elif VEC_SIZE == 4+ #define VEC_TYPE MAKE_VECTOR_TYPE(INPUT1_TYPE, 4)+ #define VLOAD(offset, ptr) vload4(offset, ptr)+ #define VSTORE(val, offset, ptr) vstore4(val, offset, ptr)+#else+ #define VEC_TYPE INPUT1_TYPE+ #define VLOAD(offset, ptr) (ptr[offset])+ #define VSTORE(val, offset, ptr) (ptr[offset] = val)+#endif++REQD_SUB_GROUP_SIZE(SIMD_SIZE)+KERNEL(slice_scatter_opt)(OPTIONAL_SHAPE_INFO_ARG+ const __global INPUT0_TYPE* restrict data,+ const __global INPUT1_TYPE* restrict updates,+ START_BUFFER+ STEP_BUFFER+ AXES_BUFFER+ __global OUTPUT_TYPE* restrict output)+{+ LOAD_BUFFER(START, start_buff);+ LOAD_BUFFER(AXES, axes_buff);++ // Compute start offsets per dimension (step is always 1 for opt kernel)+ long slice_start[INPUT0_DIMS];+ unroll_for(int i = 0; i < INPUT0_DIMS; ++i) {+ slice_start[i] = 0;+ }+ unroll_for(int i = 0; i < (AXES_BUFFER_SIZE < INPUT0_DIMS ? AXES_BUFFER_SIZE : INPUT0_DIMS); ++i) {+ const long axis = axes_buff[i];+ if (axis < 0 || axis >= INPUT0_DIMS)+ continue;+ slice_start[axis] = start_buff[i];+ }++ // Global IDs: dim0=batch, dim1=feature, dim2=spatial(Z*Y*X or Y*X)+ const long upd_dim0 = get_global_id(0); // batch+ const long upd_dim1 = get_global_id(1); // feature+ const long slice_begin_dim0 = BRING_INTO_RANGE(slice_start[0], INPUT0_BATCH_NUM);+ const long slice_begin_dim1 = BRING_INTO_RANGE(slice_start[1], INPUT0_FEATURE_NUM);++#if INPUT0_DIMS <= 4+ const long slice_begin_dim2 = BRING_INTO_RANGE(slice_start[2], INPUT0_SIZE_Y);+ const long slice_begin_dim3 = BRING_INTO_RANGE(slice_start[3], INPUT0_SIZE_X);++ // Each work-item in the sub-group processes VEC_SIZE elements along X+ const long upd_dim23_base = get_global_id(2);+ const long total_spatial = (long)INPUT1_SIZE_Y * (long)INPUT1_SIZE_X;++ // Bounds check - skip excess work-items+ const long num_blocks_4d = (total_spatial + VEC_SIZE - 1) / VEC_SIZE;+ if (upd_dim23_base >= num_blocks_4d)+ return;++ const long linear_pos = upd_dim23_base * VEC_SIZE;+ const long upd_dim2 = linear_pos / INPUT1_SIZE_X;+ const long upd_dim3_start = linear_pos % INPUT1_SIZE_X;++ // Compute base indices for vectorized access+ const long updates_base = INPUT1_GET_INDEX(upd_dim0, upd_dim1, upd_dim2, upd_dim3_start);+ const long output_base = OUTPUT_GET_INDEX(+ slice_begin_dim0 + upd_dim0,+ slice_begin_dim1 + upd_dim1,+ slice_begin_dim2 + upd_dim2,+ slice_begin_dim3 + upd_dim3_start);++#if VEC_SIZE > 1+ // Check if remaining elements on this row are enough for full vector+ if (upd_dim3_start + VEC_SIZE <= INPUT1_SIZE_X) {+ VEC_TYPE val = VLOAD(0, &updates[updates_base]);+ VSTORE(val, 0, &output[output_base]);+ } else {+ // Scalar fallback for tail elements+ for (long i = 0; i < VEC_SIZE && upd_dim3_start + i < INPUT1_SIZE_X; ++i) {+ output[output_base + i] = updates[updates_base + i];+ }+ }+#else+ output[output_base] = updates[updates_base];+#endif++#elif INPUT0_DIMS == 5+ const long slice_begin_dim2 = BRING_INTO_RANGE(slice_start[2], INPUT0_SIZE_Z);+ const long slice_begin_dim3 = BRING_INTO_RANGE(slice_start[3], INPUT0_SIZE_Y);+ const long slice_begin_dim4 = BRING_INTO_RANGE(slice_start[4], INPUT0_SIZE_X);++ const long upd_dim234_base = get_global_id(2);+ const long total_spatial = (long)INPUT1_SIZE_Z * (long)INPUT1_SIZE_Y * (long)INPUT1_SIZE_X;++ const long num_blocks_5d = (total_spatial + VEC_SIZE - 1) / VEC_SIZE;+ if (upd_dim234_base >= num_blocks_5d)+ return;++ const long linear_pos = upd_dim234_base * VEC_SIZE;+ const long upd_dim4_start = linear_pos % INPUT1_SIZE_X;+ const long upd_dim34 = linear_pos / INPUT1_SIZE_X;+ const long upd_dim3 = upd_dim34 % INPUT1_SIZE_Y;+ const long upd_dim2 = upd_dim34 / INPUT1_SIZE_Y;++ const long updates_base = INPUT1_GET_INDEX(upd_dim0, upd_dim1, upd_dim2, upd_dim3, upd_dim4_start);+ const long output_base = OUTPUT_GET_INDEX(+ slice_begin_dim0 + upd_dim0,+ slice_begin_dim1 + upd_dim1,+ slice_begin_dim2 + upd_dim2,+ slice_begin_dim3 + upd_dim3,+ slice_begin_dim4 + upd_dim4_start);++#if VEC_SIZE > 1+ if (upd_dim4_start + VEC_SIZE <= INPUT1_SIZE_X) {+ VEC_TYPE val = VLOAD(0, &updates[updates_base]);+ VSTORE(val, 0, &output[output_base]);+ } else {+ for (long i = 0; i < VEC_SIZE && upd_dim4_start + i < INPUT1_SIZE_X; ++i) {+ output[output_base + i] = updates[updates_base + i];+ }+ }+#else+ output[output_base] = updates[updates_base];+#endif++#endif+}++#undef LOAD_BUFFER+#undef BRING_INTO_RANGE+#undef VEC_SIZE+#undef VEC_TYPE+#undef VLOAD+#undef VSTOREdiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter_ref.cl b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter_ref.clnew file mode 100644index 00000000000..16962b69c91--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter_ref.cl@@ -0,0 +1,98 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+// SliceScatter reference kernel.+// Dispatched over updates (INPUT1) dimensions.+// Before this kernel runs, data is already copied to output.++#include "include/batch_headers/fetch_data.cl"++#define BRING_INTO_RANGE(VAL, MAX) \+ clamp((long)VAL < 0l ? (long)VAL + (long)MAX : (long)VAL, 0l, (long)MAX-1l);++#if INPUT0_DIMS < 5+#define LOAD_BUFFER(in_prefix, out_name) \+ long out_name[INPUT0_DIMS]; \+ out_name[0] = in_prefix##_VAL0; \+ out_name[1] = in_prefix##_VAL1; \+ out_name[2] = in_prefix##_VAL2; \+ out_name[3] = in_prefix##_VAL3;+#else+#define LOAD_BUFFER(in_prefix, out_name) \+ long out_name[INPUT0_DIMS]; \+ out_name[0] = in_prefix##_VAL0; \+ out_name[1] = in_prefix##_VAL1; \+ out_name[2] = in_prefix##_VAL2; \+ out_name[3] = in_prefix##_VAL3; \+ out_name[4] = in_prefix##_VAL4;+#endif++KERNEL(slice_scatter_ref)(OPTIONAL_SHAPE_INFO_ARG+ const __global INPUT0_TYPE* restrict data,+ const __global INPUT1_TYPE* restrict updates,+ START_BUFFER+ STEP_BUFFER+ AXES_BUFFER+ __global OUTPUT_TYPE* restrict output)+{+ LOAD_BUFFER(START, start_buff);+ LOAD_BUFFER(STEP, step_buff);+ LOAD_BUFFER(AXES, axes_buff);++ long slice_step[INPUT0_DIMS];+ long slice_start[INPUT0_DIMS];++ unroll_for(int i = 0; i < INPUT0_DIMS; ++i) {+ slice_step[i] = 1;+ slice_start[i] = 0;+ }++ unroll_for(int i = 0; i < (AXES_BUFFER_SIZE < INPUT0_DIMS ? AXES_BUFFER_SIZE : INPUT0_DIMS); ++i) {+ const long axis = axes_buff[i];+ if (axis < 0 || axis >= INPUT0_DIMS)+ continue;+ slice_step[axis] = step_buff[i];+ slice_start[axis] = start_buff[i];+ }++ // Global IDs map to updates (INPUT1) dimensions+ const long upd_dim0 = get_global_id(0); // batch+ const long upd_dim1 = get_global_id(1); // feature+ const long slice_begin_dim0 = BRING_INTO_RANGE(slice_start[0], INPUT0_BATCH_NUM);+ const long slice_begin_dim1 = BRING_INTO_RANGE(slice_start[1], INPUT0_FEATURE_NUM);++#if INPUT0_DIMS <= 4+ const long slice_begin_dim2 = BRING_INTO_RANGE(slice_start[2], INPUT0_SIZE_Y);+ const long slice_begin_dim3 = BRING_INTO_RANGE(slice_start[3], INPUT0_SIZE_X);+ const long upd_dim23 = get_global_id(2);+ const long upd_dim2 = upd_dim23 / INPUT1_SIZE_X;+ const long upd_dim3 = upd_dim23 % INPUT1_SIZE_X;+ const long updates_index = INPUT1_GET_INDEX(upd_dim0, upd_dim1, upd_dim2, upd_dim3);+ const long output_index = OUTPUT_GET_INDEX(+ slice_begin_dim0 + upd_dim0 * slice_step[0],+ slice_begin_dim1 + upd_dim1 * slice_step[1],+ slice_begin_dim2 + upd_dim2 * slice_step[2],+ slice_begin_dim3 + upd_dim3 * slice_step[3]);+#elif INPUT0_DIMS == 5+ const long slice_begin_dim2 = BRING_INTO_RANGE(slice_start[2], INPUT0_SIZE_Z);+ const long slice_begin_dim3 = BRING_INTO_RANGE(slice_start[3], INPUT0_SIZE_Y);+ const long slice_begin_dim4 = BRING_INTO_RANGE(slice_start[4], INPUT0_SIZE_X);+ const long upd_dim234 = get_global_id(2);+ const long upd_dim4 = upd_dim234 % INPUT1_SIZE_X;+ const long upd_dim23 = upd_dim234 / INPUT1_SIZE_X;+ const long upd_dim3 = upd_dim23 % INPUT1_SIZE_Y;+ const long upd_dim2 = upd_dim23 / INPUT1_SIZE_Y;+ const long updates_index = INPUT1_GET_INDEX(upd_dim0, upd_dim1, upd_dim2, upd_dim3, upd_dim4);+ const long output_index = OUTPUT_GET_INDEX(+ slice_begin_dim0 + upd_dim0 * slice_step[0],+ slice_begin_dim1 + upd_dim1 * slice_step[1],+ slice_begin_dim2 + upd_dim2 * slice_step[2],+ slice_begin_dim3 + upd_dim3 * slice_step[3],+ slice_begin_dim4 + upd_dim4 * slice_step[4]);+#endif++ output[output_index] = updates[updates_index];+}++#undef LOAD_BUFFER+#undef BRING_INTO_RANGEdiff --git a/src/plugins/intel_gpu/src/graph/include/slice_scatter_inst.h b/src/plugins/intel_gpu/src/graph/include/slice_scatter_inst.hnew file mode 100644index 00000000000..79e21a9f667--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/include/slice_scatter_inst.h@@ -0,0 +1,69 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once+#include <intel_gpu/primitives/slice_scatter.hpp>++#include "primitive_inst.h"++namespace cldnn {++using slice_scatter_node = typed_program_node<slice_scatter>;++// Helper class for determining which SliceScatter inputs are needed by the kernel at runtime.+// Similar to SliceKernelRefNeededInputs for Slice.+class SliceScatterKernelRefNeededInputs {+public:+ enum InputIndices { kData, kUpdates, kStart, kEnd, kStep, kAxes, kInputsNum };++ static SliceScatterKernelRefNeededInputs Create(const slice_scatter_node& node);++ const std::vector<size_t>& GetNeededInputIndexes() const;+ bool IsInputNeededInRuntime(InputIndices type) const;++private:+ std::vector<size_t> neededIndexes;+};++template <>+struct typed_program_node<slice_scatter> : public typed_program_node_base<slice_scatter> {+ using parent = typed_program_node_base<slice_scatter>;++public:+ using parent::parent;+ typed_program_node(const std::shared_ptr<slice_scatter> prim, program& prog) : parent(prim, prog) {}++ program_node& input(std::size_t i = 0) const {+ return get_dependency(i);+ }+ std::vector<size_t> get_shape_infer_dependencies() const override {+ return {};+ }+};++template <>+class typed_primitive_inst<slice_scatter> : public typed_primitive_inst_base<slice_scatter> {+ using parent = typed_primitive_inst_base<slice_scatter>;+ using parent::parent;++public:+ template <typename ShapeType>+ static std::vector<layout> calc_output_layouts(const slice_scatter_node& node, const kernel_impl_params& impl_param);+ static layout calc_output_layout(const slice_scatter_node& node, const kernel_impl_params& impl_param);+ static std::string to_string(const slice_scatter_node& node);++ typed_primitive_inst(network& network, const slice_scatter_node& desc);+ void update_output_memory() override;++private:+ void on_execute() override;+};++using slice_scatter_inst = typed_primitive_inst<slice_scatter>;++inline const std::vector<size_t>& SliceScatterKernelRefNeededInputs::GetNeededInputIndexes() const {+ return neededIndexes;+}++} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/registry/registry.hpp b/src/plugins/intel_gpu/src/graph/registry/registry.hppindex 6dc994ee30d..9ac7ddf9d50 100644--- a/src/plugins/intel_gpu/src/graph/registry/registry.hpp+++ b/src/plugins/intel_gpu/src/graph/registry/registry.hpp@@ -161,6 +161,8 @@ REGISTER_IMPLS(scaled_dot_product_attention);REGISTER_IMPLS(scatter_update);REGISTER_IMPLS(scatter_elements_update);REGISTER_IMPLS(scatter_nd_update);+REGISTER_IMPLS(segment_max);+REGISTER_IMPLS(slice_scatter);REGISTER_IMPLS(softmax);REGISTER_IMPLS(shape_of);REGISTER_IMPLS(strided_slice);@@ -237,7 +239,6 @@ REGISTER_DEFAULT_IMPLS(eye, OCL_S);REGISTER_DEFAULT_IMPLS(unique_count, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(unique_gather, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(search_sorted, OCL_S, OCL_D);-REGISTER_IMPLS(segment_max);REGISTER_DEFAULT_IMPLS(STFT, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(ISTFT, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(sparse_fill_empty_rows, OCL_S, OCL_D);diff --git a/src/plugins/intel_gpu/src/graph/registry/slice_scatter_impls.cpp b/src/plugins/intel_gpu/src/graph/registry/slice_scatter_impls.cppnew file mode 100644index 00000000000..b1ad850a6c3--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/registry/slice_scatter_impls.cpp@@ -0,0 +1,25 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "intel_gpu/primitives/slice_scatter.hpp"+#include "primitive_inst.h"+#include "registry.hpp"++#if OV_GPU_WITH_OCL+# include "impls/ocl_v2/slice_scatter.hpp"+#endif++namespace ov {+namespace intel_gpu {++using namespace cldnn;++const std::vector<std::shared_ptr<cldnn::ImplementationManager>>& Registry<slice_scatter>::get_implementations() {+ static const std::vector<std::shared_ptr<ImplementationManager>> impls = {OV_GPU_CREATE_INSTANCE_OCL(ocl::SliceScatter, shape_types::any)};++ return impls;+}++} // namespace intel_gpu+} // namespace ovdiff --git a/src/plugins/intel_gpu/src/graph/slice_scatter.cpp b/src/plugins/intel_gpu/src/graph/slice_scatter.cppnew file mode 100644index 00000000000..7bb0d7d134b--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/slice_scatter.cpp@@ -0,0 +1,134 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/slice_scatter.hpp"++#include <json_object.h>+#include <slice_scatter_inst.h>++#include <sstream>++#include "primitive_type_base.h"+#include "slice_scatter_shape_inference.hpp"++namespace cldnn {++SliceScatterKernelRefNeededInputs SliceScatterKernelRefNeededInputs::Create(const slice_scatter_node& node) {+ SliceScatterKernelRefNeededInputs inputs;++ const auto& node_inputs = node.get_dependencies();++ // data and updates are always needed+ inputs.neededIndexes.push_back(InputIndices::kData);+ inputs.neededIndexes.push_back(InputIndices::kUpdates);++ const bool start_in_runtime = !node_inputs[InputIndices::kStart].first->is_constant();+ const bool step_in_runtime = !node_inputs[InputIndices::kStep].first->is_constant();+ const bool axes_in_runtime = ((node_inputs.size() > InputIndices::kAxes) && !node_inputs[InputIndices::kAxes].first->is_constant());++ if (start_in_runtime)+ inputs.neededIndexes.push_back(InputIndices::kStart);+ if (step_in_runtime)+ inputs.neededIndexes.push_back(InputIndices::kStep);+ if (axes_in_runtime)+ inputs.neededIndexes.push_back(InputIndices::kAxes);++ // NOTE: stop/end is never needed at runtime as it is passed implicitly via the updates shape.++ return inputs;+}++bool SliceScatterKernelRefNeededInputs::IsInputNeededInRuntime(InputIndices type) const {+ for (const auto& idx : neededIndexes) {+ if (idx == static_cast<size_t>(type))+ return true;+ }+ return false;+}++GPU_DEFINE_PRIMITIVE_TYPE_ID(slice_scatter)++slice_scatter_inst::typed_primitive_inst(network& network, const slice_scatter_node& node) : parent(network, node) {+ update_output_memory();+}++void slice_scatter_inst::on_execute() {+ update_output_memory();++ // If output is not sharing buffer with data input (e.g. dynamic shapes or not optimized),+ // explicitly copy data to output before the kernel writes updates into slice positions.+ if (!_network.get_engine().is_the_same_buffer(output_memory(), input_memory())) {+ output_memory().copy_from(_network.get_stream(), input_memory());+ }+}++void slice_scatter_inst::update_output_memory() {+ if (!can_be_optimized() || _impl_params->is_dynamic())+ return;++ if (_outputs.size() > 0 && static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()))+ return;++ build_deps();++ if (static_cast<bool>(_outputs[0]) && get_node().get_program().get_config().get_enable_memory_pool()) {+ _network.get_memory_pool().release_memory(_outputs[0].get(), get_node().get_unique_id(), get_node().id(), _network.get_id());+ }+ _outputs = {_network.get_engine().reinterpret_buffer(input_memory(), _impl_params->get_output_layout())};+ _mem_allocated = false;+}++layout slice_scatter_inst::calc_output_layout(const slice_scatter_node& node, const kernel_impl_params& impl_param) {+ return calc_output_layouts<ov::PartialShape>(node, impl_param)[0];+}++template <typename ShapeType>+inline std::vector<layout> slice_scatter_inst::calc_output_layouts(const slice_scatter_node&, const kernel_impl_params& impl_param) {+ std::vector<ShapeType> input_shapes;+ std::unordered_map<size_t, ov::Tensor> const_data;++ for (std::size_t i = 0; i < impl_param.input_layouts.size(); i++) {+ if (i >= 2) {+ // Reshape 1D for start/stop/step/axes inputs (same as Slice)+ ov::PartialShape input_shape = ov::PartialShape::dynamic(1);+ if (impl_param.memory_deps.find(i) != impl_param.memory_deps.end()) {+ auto gpu_mem = impl_param.memory_deps.at(i);+ input_shape = {static_cast<ov::Dimension::value_type>(gpu_mem->count())};+ cldnn::mem_lock<uint8_t, mem_lock_type::read> gpu_mem_lock(gpu_mem, impl_param.get_stream());+ const_data.emplace(i, make_tensor(layout{input_shape, gpu_mem->get_layout().data_type, gpu_mem->get_layout().format}, gpu_mem_lock.data()));+ }+ input_shapes.push_back(input_shape);+ } else {+ input_shapes.push_back(impl_param.input_layouts[i].get<ShapeType>());+ }+ }++ ov::op::v15::SliceScatter op;+ auto output_shapes = shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data));+ auto input_layout = impl_param.get_input_layout();+ std::vector<layout> output_layouts;+ for (size_t i = 0; i < output_shapes.size(); ++i) {+ output_layouts.push_back(layout({output_shapes[i], input_layout.data_type, input_layout.format}));+ }+ return output_layouts;+}++std::string slice_scatter_inst::to_string(const slice_scatter_node& node) {+ auto node_info = node.desc_to_json();+ json_composite slice_scatter_info;+ slice_scatter_info.add("data", node.input(0).id());+ slice_scatter_info.add("updates", node.input(1).id());+ slice_scatter_info.add("start", node.get_dependency(2).id());+ slice_scatter_info.add("stop", node.get_dependency(3).id());+ slice_scatter_info.add("step", node.get_dependency(4).id());+ if (node.get_dependencies().size() > 5) {+ slice_scatter_info.add("axes", node.get_dependency(5).id());+ }+ node_info->add("slice_scatter info", slice_scatter_info);+ std::stringstream primitive_description;+ node_info->dump(primitive_description);+ return primitive_description.str();+}++} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/kernel_selector/common_types.h b/src/plugins/intel_gpu/src/kernel_selector/common_types.hindex bfe46927111..b7dbdf3b09c 100644--- a/src/plugins/intel_gpu/src/kernel_selector/common_types.h+++ b/src/plugins/intel_gpu/src/kernel_selector/common_types.h@@ -66,6 +66,7 @@ enum class KernelType {SDPA,SHUFFLE_CHANNELS,SLICE,+ SLICE_SCATTER,STRIDED_SLICE,REVERSE_SEQUENCE,QUANTIZE,diff --git a/src/plugins/intel_gpu/src/plugin/ops/slice_scatter.cpp b/src/plugins/intel_gpu/src/plugin/ops/slice_scatter.cppnew file mode 100644index 00000000000..ab4ae73a74a--- /dev/null+++ b/src/plugins/intel_gpu/src/plugin/ops/slice_scatter.cpp@@ -0,0 +1,29 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "intel_gpu/plugin/program_builder.hpp"+#include "intel_gpu/plugin/common_utils.hpp"++#include "openvino/op/slice_scatter.hpp"++#include "intel_gpu/primitives/slice_scatter.hpp"++#include <memory>++namespace ov::intel_gpu {++namespace {++static void CreateSliceScatterOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v15::SliceScatter>& op) {+ validate_inputs_count(op, {5, 6});+ auto inputs = p.GetInputInfo(op);+ cldnn::slice_scatter slice_scatter_prim{layer_type_name_ID(op), inputs};+ p.add_primitive(*op, slice_scatter_prim);+}++} // namespace++REGISTER_FACTORY_IMPL(v15, SliceScatter);++} // namespace ov::intel_gpudiff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/slice_scatter.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/slice_scatter.cppnew file mode 100644index 00000000000..d5ed577d585--- /dev/null+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/slice_scatter.cpp@@ -0,0 +1,120 @@+// Copyright (C) 2018-2026 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::f16, ov::element::i8};++const std::vector<ov::element::Type> model_types_extra = {ov::element::i64, ov::element::i32, 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{{{{}, {{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, 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{{{{}, {{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{{{{}, {{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{{{{}, {{10, 12}}}, {{}, {{10, 9}}}}, {-1, 1}, {-9999, 10}, {-1, 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},+ {}},+};++INSTANTIATE_TEST_SUITE_P(smoke_GPU,+ SliceScatterLayerTest,+ ::testing::Combine(::testing::ValuesIn(static_params),+ ::testing::ValuesIn(model_types),+ ::testing::Values(ov::test::utils::DEVICE_GPU)),+ SliceScatterLayerTest::getTestCaseName);++INSTANTIATE_TEST_SUITE_P(smoke_GPU_PrecisionTransformation,+ SliceScatterLayerTest,+ ::testing::Combine(::testing::Values(static_params[0]),+ ::testing::ValuesIn(model_types_extra),+ ::testing::Values(ov::test::utils::DEVICE_GPU)),+ 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, -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{{{{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{{{{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_GPU_dynamic,+ SliceScatterLayerTest,+ ::testing::Combine(::testing::ValuesIn(dynamic_params),+ ::testing::ValuesIn(model_types),+ ::testing::Values(ov::test::utils::DEVICE_GPU)),+ SliceScatterLayerTest::getTestCaseName);++} // namespacediff --git a/src/plugins/intel_gpu/tests/unit/test_cases/slice_scatter_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/slice_scatter_gpu_test.cppnew file mode 100644index 00000000000..49d15497315--- /dev/null+++ b/src/plugins/intel_gpu/tests/unit/test_cases/slice_scatter_gpu_test.cpp@@ -0,0 +1,776 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#include <chrono>+#include <intel_gpu/primitives/data.hpp>+#include <intel_gpu/primitives/input_layout.hpp>+#include <intel_gpu/primitives/slice_scatter.hpp>+#include <numeric>+#include <vector>++#include "test_utils.h"++using namespace cldnn;+using namespace ::tests;++namespace {++namespace helpers {++template <typename T>+data_types ToDataType();++template <>+data_types ToDataType<float>() {+ return data_types::f32;+}++template <>+data_types ToDataType<int32_t>() {+ return data_types::i32;+}++template <>+data_types ToDataType<int64_t>() {+ return data_types::i64;+}++template <typename T>+std::vector<T> GenInput(const ov::PartialShape& shape) {+ const size_t size = ov::shape_size(shape.get_shape());+ std::vector<T> result(size);+ std::iota(result.begin(), result.end(), T{0});+ return result;+}++} // namespace helpers++struct SliceScatterTestParams {+ memory::ptr data;+ memory::ptr updates;+ memory::ptr start;+ memory::ptr stop;+ memory::ptr step;+ memory::ptr axes;+ memory::ptr wanted_output;+ bool is_data_dynamic = false;+ bool is_updates_dynamic = false;+ bool is_start_dynamic = false;+ bool is_stop_dynamic = false;+ bool is_step_dynamic = false;+ bool is_axes_dynamic = false;+ bool is_caching_test = false;+};++template <typename T>+class SliceScatterTest : public ::testing::Test {+public:+ void RunAllTestCasesForParams(const SliceScatterTestParams& params) {+ RunTestCase(params);+ }++ template <typename TDataType>+ memory::ptr AllocateTensor(ov::PartialShape shape, cldnn::format fmt, const std::vector<TDataType>& data) {+ const layout lo = {shape, helpers::ToDataType<TDataType>(), fmt};+ EXPECT_EQ(lo.get_linear_size(), data.size());+ memory::ptr tensor = this->engine_.allocate_memory(lo);+ set_values<TDataType>(tensor, data);+ return tensor;+ }++ // Test case: basic bfyx with positive step, no axes+ // data [1,1,3,4] = GenInput(0..11)+ // updates [1,1,2,2] = [20,21,22,23]+ // start=[0,0,0,1], stop=[1,1,2,3], step=[1,1,1,1]+ // Slice region: b[0:1],f[0:1],y[0:2],x[1:3]+ // Expected: [0,20,21,3, 4,22,23,7, 8,9,10,11]+ template <typename TypeParam>+ void FillWithBasicBfyxData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 1, 3, 4};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 2, 2}, format::bfyx, std::vector<TypeParam>{20, 21, 22, 23});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{4}, format::bfyx, {0, 0, 0, 1});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{4}, format::bfyx, {1, 1, 2, 3});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{4}, format::bfyx, {1, 1, 1, 1});+ params.wanted_output =+ this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{0, 20, 21, 3, 4, 22, 23, 7, 8, 9, 10, 11});+ }++ // Test case: with explicit axes parameter+ // data [1,1,4,4] = GenInput(0..15)+ // updates [1,1,2,4] = [100..107]+ // start=[1], stop=[3], step=[1], axes=[2]+ // Slice axis 2 (y): y[1:3], all other axes full+ // Expected: [0,1,2,3, 100,101,102,103, 104,105,106,107, 12,13,14,15]+ template <typename TypeParam>+ void FillWithAxesData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 1, 4, 4};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 2, 4},+ format::bfyx,+ std::vector<TypeParam>{100, 101, 102, 103, 104, 105, 106, 107});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {3});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.axes = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {2});+ params.wanted_output =+ this->template AllocateTensor<TypeParam>(data_shape,+ format::bfyx,+ std::vector<TypeParam>{0, 1, 2, 3, 100, 101, 102, 103, 104, 105, 106, 107, 12, 13, 14, 15});+ }++ // Test case: step > 1+ // data [1,1,1,8] = GenInput(0..7)+ // updates [1,1,1,4] = [10,11,12,13]+ // start=[0], stop=[8], step=[2], axes=[3]+ // Scatter at x=0,2,4,6+ // Expected: [10,1,11,3,12,5,13,7]+ template <typename TypeParam>+ void FillWithStepData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 1, 1, 8};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 1, 4}, format::bfyx, std::vector<TypeParam>{10, 11, 12, 13});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {0});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {8});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {2});+ params.axes = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {3});+ params.wanted_output = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{10, 1, 11, 3, 12, 5, 13, 7});+ }++ // Test case: negative indices+ // data [1,1,1,8] = GenInput(0..7)+ // updates [1,1,1,2] = [10,11]+ // start=[-3], stop=[-1], step=[1], axes=[3]+ // start=-3 -> 5, stop=-1 -> 7: x[5:7] = [10,11]+ // Expected: [0,1,2,3,4,10,11,7]+ template <typename TypeParam>+ void FillWithNegativeIndicesData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 1, 1, 8};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 1, 2}, format::bfyx, std::vector<TypeParam>{10, 11});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {-3});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {-1});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.axes = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {3});+ params.wanted_output = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{0, 1, 2, 3, 4, 10, 11, 7});+ }++ // Test case: 5D bfzyx+ // data [1,2,2,2,3] = GenInput(0..23)+ // updates [1,1,1,2,3] = [100..105]+ // start=[0,0,0,0,0], stop=[1,1,1,2,3], step=[1,1,1,1,1]+ // Replace b=0,f=0,z=0 region+ // Expected: [100,101,102,103,104,105, 6..23]+ template <typename TypeParam>+ void FillWithBfzyxData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 2, 2, 2, 3};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfzyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates =+ this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 1, 2, 3}, format::bfzyx, std::vector<TypeParam>{100, 101, 102, 103, 104, 105});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{5}, format::bfzyx, {0, 0, 0, 0, 0});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{5}, format::bfzyx, {1, 1, 1, 2, 3});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{5}, format::bfzyx, {1, 1, 1, 1, 1});+ params.wanted_output =+ this->template AllocateTensor<TypeParam>(data_shape, format::bfzyx, std::vector<TypeParam>{100, 101, 102, 103, 104, 105, 6, 7, 8, 9, 10, 11,+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23});+ }++ // Test case: negative step (backward slicing)+ // data [1,1,1,8] = GenInput(0..7) = [0,1,2,3,4,5,6,7]+ // updates [1,1,1,3] = [10,11,12]+ // start=[6], stop=[0], step=[-2], axes=[3]+ // Backward: x=6,4,2 => positions 6,4,2+ // Expected: [0,1,12,3,11,5,10,7]+ template <typename TypeParam>+ void FillWithNegativeStepData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 1, 1, 8};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 1, 3}, format::bfyx, std::vector<TypeParam>{10, 11, 12});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {6});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {0});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {-2});+ params.axes = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {3});+ params.wanted_output = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{0, 1, 12, 3, 11, 5, 10, 7});+ }++ // Test case: start/stop clamping+ // Spec says: "A value larger than the size of a dimension is silently clamped."+ // data [1,1,2,5] = GenInput(0..9) = [[0,1,2,3,4],[5,6,7,8,9]]+ // updates [1,1,2,3] = [10,20,30,40,50,60]+ // start=[-25], stop=[25], step=[2], axes=[3]+ // start=-25 clamped to 0, stop=25 clamped to 5 => x=0,2,4+ // Expected: [[10,1,20,3,30],[40,6,50,8,60]]+ // This matches Spec Example 2 pattern (clamping + step=2)+ template <typename TypeParam>+ void FillWithClampingData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 1, 2, 5};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 2, 3}, format::bfyx, std::vector<TypeParam>{10, 20, 30, 40, 50, 60});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {-25});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {25});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {2});+ params.axes = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {3});+ params.wanted_output = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{10, 1, 20, 3, 30, 40, 6, 50, 8, 60});+ }++ // Test case: negative axes+ // data [1,1,4,4] = GenInput(0..15)+ // updates [1,1,2,4] = [100..107]+ // start=[1], stop=[3], step=[1], axes=[-2]+ // axes=-2 with rank=4 => axis 2 (y dimension)+ // Same result as with_axes (axis=2), y[1:3]+ // Expected: [0,1,2,3, 100,101,102,103, 104,105,106,107, 12,13,14,15]+ template <typename TypeParam>+ void FillWithNegativeAxesData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 1, 4, 4};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 2, 4},+ format::bfyx,+ std::vector<TypeParam>{100, 101, 102, 103, 104, 105, 106, 107});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {3});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.axes = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {-2});+ params.wanted_output =+ this->template AllocateTensor<TypeParam>(data_shape,+ format::bfyx,+ std::vector<TypeParam>{0, 1, 2, 3, 100, 101, 102, 103, 104, 105, 106, 107, 12, 13, 14, 15});+ }++ // Test case: Spec Example 1 - fill slice over axis==0+ // data [1,1,2,5] = [[0,1,2,3,4],[5,6,7,8,9]]+ // updates [1,1,1,5] = [[10,20,30,40,50]]+ // start=[0], stop=[1], step=[1], axes=[2] (axis 0 in spec = axis 2 in bfyx)+ // y[0:1] replaced+ // Expected: [[10,20,30,40,50],[5,6,7,8,9]]+ template <typename TypeParam>+ void FillWithSpecExample1Data(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 1, 2, 5};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9});+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 1, 5}, format::bfyx, std::vector<TypeParam>{10, 20, 30, 40, 50});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {0});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.axes = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {2});+ params.wanted_output = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{10, 20, 30, 40, 50, 5, 6, 7, 8, 9});+ }++ // Test case: Spec Example 3 - multi-axis step=2 without explicit axes+ // data [1,1,3,5] = [[0..4],[5..9],[10..14]]+ // updates [1,1,2,2] = [[50,60],[70,80]]+ // start=[0,0,0,1], stop=[1,1,3,5], step=[1,1,2,2]+ // axis 2 (y): y=0,2 axis 3 (x): x=1,3+ // Expected: [[0,50,2,60,4],[5,6,7,8,9],[10,70,12,80,14]]+ template <typename TypeParam>+ void FillWithSpecExample3Data(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 1, 3, 5};+ params.data =+ this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14});+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 2, 2}, format::bfyx, std::vector<TypeParam>{50, 60, 70, 80});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{4}, format::bfyx, {0, 0, 0, 1});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{4}, format::bfyx, {1, 1, 3, 5});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{4}, format::bfyx, {1, 1, 2, 2});+ params.wanted_output =+ this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{0, 50, 2, 60, 4, 5, 6, 7, 8, 9, 10, 70, 12, 80, 14});+ }++ // Test case: 1D tensor+ // data [8] = [0,1,2,3,4,5,6,7]+ // updates [3] = [10,20,30]+ // start=[2], stop=[5], step=[1], axes=[0]+ // x[2:5] = [10,20,30]+ // Expected: [0,1,10,20,30,5,6,7]+ template <typename TypeParam>+ void FillWith1DData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{8};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{3}, format::bfyx, std::vector<TypeParam>{10, 20, 30});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {2});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {5});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.axes = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {0});+ params.wanted_output = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{0, 1, 10, 20, 30, 5, 6, 7});+ }++ // Test case: 2D tensor+ // data [3,4] = GenInput(0..11) = [[0,1,2,3],[4,5,6,7],[8,9,10,11]]+ // updates [3,2] = [100,101,102,103,104,105]+ // start=[1], stop=[3], step=[1], axes=[1]+ // x[1:3] on each row+ // Expected: [[0,100,101,3],[4,102,103,7],[8,104,105,11]]+ template <typename TypeParam>+ void FillWith2DData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{3, 4};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{3, 2}, format::bfyx, std::vector<TypeParam>{100, 101, 102, 103, 104, 105});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {3});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.axes = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.wanted_output =+ this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{0, 100, 101, 3, 4, 102, 103, 7, 8, 104, 105, 11});+ }++ // Test case: INT_MAX stop (slice to end of dimension)+ // data [1,1,1,10] = GenInput(0..9)+ // updates [1,1,1,4] = [50,51,52,53]+ // start=[6], stop=[INT_MAX], step=[1], axes=[3]+ // x[6:10] = [50,51,52,53]+ // Expected: [0,1,2,3,4,5,50,51,52,53]+ template <typename TypeParam>+ void FillWithIntMaxStopData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 1, 1, 10};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 1, 4}, format::bfyx, std::vector<TypeParam>{50, 51, 52, 53});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {6});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {std::numeric_limits<int64_t>::max()});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {1});+ params.axes = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {3});+ params.wanted_output = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{0, 1, 2, 3, 4, 5, 50, 51, 52, 53});+ }++ // Test case: negative step=-1 (full reverse on one axis)+ // data [1,1,1,6] = [0,1,2,3,4,5]+ // updates [1,1,1,3] = [10,11,12]+ // start=[5], stop=[2], step=[-1], axes=[3]+ // Backward: x=5,4,3 => positions 5,4,3+ // Expected: [0,1,2,12,11,10]+ template <typename TypeParam>+ void FillWithNegativeStepReverseData(SliceScatterTestParams& params) {+ const ov::PartialShape data_shape{1, 1, 1, 6};+ params.data = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, helpers::GenInput<TypeParam>(data_shape));+ params.updates = this->template AllocateTensor<TypeParam>(ov::PartialShape{1, 1, 1, 3}, format::bfyx, std::vector<TypeParam>{10, 11, 12});+ params.start = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {5});+ params.stop = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {2});+ params.step = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {-1});+ params.axes = this->template AllocateTensor<int64_t>(ov::PartialShape{1}, format::bfyx, {3});+ params.wanted_output = this->template AllocateTensor<TypeParam>(data_shape, format::bfyx, std::vector<TypeParam>{0, 1, 2, 12, 11, 10});+ }++private:+ void SetParameterInput(const std::string& name, topology& topo, const memory::ptr& data_ptr, bool is_dynamic) {+ if (is_dynamic) {+ auto dynamic_shape = data_ptr->get_layout();+ dynamic_shape.set_partial_shape(ov::PartialShape::dynamic(dynamic_shape.get_rank()));+ topo.add(input_layout(name, dynamic_shape));+ } else {+ topo.add(data(name, data_ptr));+ }+ }++ void RunTestCase(const SliceScatterTestParams& params) {+ topology topo;++ // data input - always input_layout+ auto data_layout = params.data->get_layout();+ if (params.is_data_dynamic) {+ data_layout.set_partial_shape(ov::PartialShape::dynamic(data_layout.get_rank()));+ }+ topo.add(input_layout("data", data_layout));++ // updates input - always input_layout+ auto updates_layout = params.updates->get_layout();+ if (params.is_updates_dynamic) {+ updates_layout.set_partial_shape(ov::PartialShape::dynamic(updates_layout.get_rank()));+ }+ topo.add(input_layout("updates", updates_layout));++ // start, stop, step: can be data (constant) or input_layout (dynamic)+ SetParameterInput("start", topo, params.start, params.is_start_dynamic);+ SetParameterInput("stop", topo, params.stop, params.is_stop_dynamic);+ SetParameterInput("step", topo, params.step, params.is_step_dynamic);++ if (params.axes) {+ SetParameterInput("axes", topo, params.axes, params.is_axes_dynamic);+ }++ std::vector<input_info> inputs{input_info("data"), input_info("updates"), input_info("start"), input_info("stop"), input_info("step")};+ if (params.axes) {+ inputs.push_back(input_info("axes"));+ }+ topo.add(slice_scatter("slice_scatter", inputs));++ ExecutionConfig config = get_test_default_config(engine_);+ config.set_property(ov::intel_gpu::allow_new_shape_infer(true));++ cldnn::network::ptr network = get_network(engine_, topo, config, get_test_stream_ptr(), params.is_caching_test);++ network->set_input_data("data", params.data);+ network->set_input_data("updates", params.updates);++ if (params.is_start_dynamic)+ network->set_input_data("start", params.start);+ if (params.is_stop_dynamic)+ network->set_input_data("stop", params.stop);+ if (params.is_step_dynamic)+ network->set_input_data("step", params.step);+ if (params.axes && params.is_axes_dynamic)+ network->set_input_data("axes", params.axes);++ auto outputs = network->execute();++ ASSERT_EQ(outputs.size(), size_t(1));+ ASSERT_EQ(outputs.begin()->first, "slice_scatter");++ auto output = outputs.at("slice_scatter").get_memory();++ cldnn::mem_lock<T> output_ptr(output, get_test_stream());+ cldnn::mem_lock<T> wanted_output_ptr(params.wanted_output, get_test_stream());++ ASSERT_EQ(output->get_layout().get_shape(), params.wanted_output->get_layout().get_shape());+ ASSERT_EQ(output_ptr.size(), wanted_output_ptr.size());+ for (size_t i = 0; i < output_ptr.size(); ++i)+ ASSERT_TRUE(are_equal(wanted_output_ptr[i], output_ptr[i], 2e-3));+ }++ engine& engine_ = get_test_engine();+};++using testing::Types;+typedef Types<float, int32_t, int64_t> DataTypes;+TYPED_TEST_SUITE(SliceScatterTest, DataTypes);++// ===== Static shape tests =====++TYPED_TEST(SliceScatterTest, basic_bfyx) {+ SliceScatterTestParams params;+ this->template FillWithBasicBfyxData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, basic_bfyx_caching) {+ SliceScatterTestParams params;+ this->template FillWithBasicBfyxData<TypeParam>(params);+ params.is_caching_test = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, with_axes) {+ SliceScatterTestParams params;+ this->template FillWithAxesData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, with_step) {+ SliceScatterTestParams params;+ this->template FillWithStepData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, negative_indices) {+ SliceScatterTestParams params;+ this->template FillWithNegativeIndicesData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, bfzyx) {+ SliceScatterTestParams params;+ this->template FillWithBfzyxData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, negative_step) {+ SliceScatterTestParams params;+ this->template FillWithNegativeStepData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, negative_step_reverse) {+ SliceScatterTestParams params;+ this->template FillWithNegativeStepReverseData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, clamping) {+ SliceScatterTestParams params;+ this->template FillWithClampingData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, int_max_stop) {+ SliceScatterTestParams params;+ this->template FillWithIntMaxStopData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, negative_axes) {+ SliceScatterTestParams params;+ this->template FillWithNegativeAxesData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, spec_example1) {+ SliceScatterTestParams params;+ this->template FillWithSpecExample1Data<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, spec_example3) {+ SliceScatterTestParams params;+ this->template FillWithSpecExample3Data<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, tensor_1d) {+ SliceScatterTestParams params;+ this->template FillWith1DData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, tensor_2d) {+ SliceScatterTestParams params;+ this->template FillWith2DData<TypeParam>(params);+ this->RunAllTestCasesForParams(params);+}++// ===== Dynamic shape tests =====++TYPED_TEST(SliceScatterTest, basic_bfyx_data_dynamic) {+ SliceScatterTestParams params;+ this->template FillWithBasicBfyxData<TypeParam>(params);+ params.is_data_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, basic_bfyx_updates_dynamic) {+ SliceScatterTestParams params;+ this->template FillWithBasicBfyxData<TypeParam>(params);+ params.is_updates_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, basic_bfyx_start_dynamic) {+ SliceScatterTestParams params;+ this->template FillWithBasicBfyxData<TypeParam>(params);+ params.is_start_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, basic_bfyx_all_dynamic) {+ SliceScatterTestParams params;+ this->template FillWithBasicBfyxData<TypeParam>(params);+ params.is_data_dynamic = true;+ params.is_updates_dynamic = true;+ params.is_start_dynamic = true;+ params.is_stop_dynamic = true;+ params.is_step_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, basic_bfyx_all_dynamic_caching) {+ SliceScatterTestParams params;+ this->template FillWithBasicBfyxData<TypeParam>(params);+ params.is_data_dynamic = true;+ params.is_updates_dynamic = true;+ params.is_start_dynamic = true;+ params.is_stop_dynamic = true;+ params.is_step_dynamic = true;+ params.is_caching_test = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, with_axes_all_dynamic) {+ SliceScatterTestParams params;+ this->template FillWithAxesData<TypeParam>(params);+ params.is_data_dynamic = true;+ params.is_updates_dynamic = true;+ params.is_start_dynamic = true;+ params.is_stop_dynamic = true;+ params.is_step_dynamic = true;+ params.is_axes_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, with_step_dynamic) {+ SliceScatterTestParams params;+ this->template FillWithStepData<TypeParam>(params);+ params.is_data_dynamic = true;+ params.is_step_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, negative_indices_all_dynamic) {+ SliceScatterTestParams params;+ this->template FillWithNegativeIndicesData<TypeParam>(params);+ params.is_data_dynamic = true;+ params.is_updates_dynamic = true;+ params.is_start_dynamic = true;+ params.is_stop_dynamic = true;+ params.is_step_dynamic = true;+ params.is_axes_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, bfzyx_all_dynamic) {+ SliceScatterTestParams params;+ this->template FillWithBfzyxData<TypeParam>(params);+ params.is_data_dynamic = true;+ params.is_updates_dynamic = true;+ params.is_start_dynamic = true;+ params.is_stop_dynamic = true;+ params.is_step_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, negative_step_all_dynamic) {+ SliceScatterTestParams params;+ this->template FillWithNegativeStepData<TypeParam>(params);+ params.is_data_dynamic = true;+ params.is_updates_dynamic = true;+ params.is_start_dynamic = true;+ params.is_stop_dynamic = true;+ params.is_step_dynamic = true;+ params.is_axes_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, clamping_all_dynamic) {+ SliceScatterTestParams params;+ this->template FillWithClampingData<TypeParam>(params);+ params.is_data_dynamic = true;+ params.is_updates_dynamic = true;+ params.is_start_dynamic = true;+ params.is_stop_dynamic = true;+ params.is_step_dynamic = true;+ params.is_axes_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, negative_axes_all_dynamic) {+ SliceScatterTestParams params;+ this->template FillWithNegativeAxesData<TypeParam>(params);+ params.is_data_dynamic = true;+ params.is_updates_dynamic = true;+ params.is_start_dynamic = true;+ params.is_stop_dynamic = true;+ params.is_step_dynamic = true;+ params.is_axes_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++TYPED_TEST(SliceScatterTest, tensor_1d_all_dynamic) {+ SliceScatterTestParams params;+ this->template FillWith1DData<TypeParam>(params);+ params.is_data_dynamic = true;+ params.is_updates_dynamic = true;+ params.is_start_dynamic = true;+ params.is_stop_dynamic = true;+ params.is_step_dynamic = true;+ params.is_axes_dynamic = true;+ this->RunAllTestCasesForParams(params);+}++} // anonymous namespace++// ===== Performance benchmark (large tensors, opt-eligible: step=1, X>=8) =====+namespace {++class SliceScatterPerfTest : public ::testing::Test {+protected:+ engine& engine_ = get_test_engine();++ // Benchmark: run the network 'iters' times and return average execution time in microseconds+ double BenchmarkSliceScatter(const ov::PartialShape& data_shape,+ const ov::PartialShape& updates_shape,+ const std::vector<int64_t>& start_vals,+ const std::vector<int64_t>& stop_vals,+ const std::vector<int64_t>& step_vals,+ int warmup_iters,+ int measure_iters) {+ // Allocate data+ auto data_size = ov::shape_size(data_shape.get_shape());+ auto updates_size = ov::shape_size(updates_shape.get_shape());+ std::vector<float> data_vals(data_size);+ std::iota(data_vals.begin(), data_vals.end(), 0.0f);+ std::vector<float> upd_vals(updates_size, 1.0f);++ layout data_lo{data_shape, data_types::f32, format::bfyx};+ layout updates_lo{updates_shape, data_types::f32, format::bfyx};+ auto data_mem = engine_.allocate_memory(data_lo);+ auto updates_mem = engine_.allocate_memory(updates_lo);+ set_values<float>(data_mem, data_vals);+ set_values<float>(updates_mem, upd_vals);++ ov::PartialShape idx_shape{static_cast<int64_t>(start_vals.size())};+ layout idx_lo{idx_shape, data_types::i64, format::bfyx};+ auto start_mem = engine_.allocate_memory(idx_lo);+ auto stop_mem = engine_.allocate_memory(idx_lo);+ auto step_mem = engine_.allocate_memory(idx_lo);+ set_values<int64_t>(start_mem, start_vals);+ set_values<int64_t>(stop_mem, stop_vals);+ set_values<int64_t>(step_mem, step_vals);++ // Build topology+ topology topo;+ topo.add(input_layout("data", data_lo));+ topo.add(input_layout("updates", updates_lo));+ topo.add(data("start", start_mem));+ topo.add(data("stop", stop_mem));+ topo.add(data("step", step_mem));+ topo.add(slice_scatter("slice_scatter", {input_info("data"), input_info("updates"), input_info("start"), input_info("stop"), input_info("step")}));++ ExecutionConfig config = get_test_default_config(engine_);+ config.set_property(ov::intel_gpu::allow_new_shape_infer(true));+ auto network = get_network(engine_, topo, config, get_test_stream_ptr(), false);++ // Warmup+ for (int i = 0; i < warmup_iters; ++i) {+ network->set_input_data("data", data_mem);+ network->set_input_data("updates", updates_mem);+ auto outputs = network->execute();+ // Force sync+ auto out = outputs.at("slice_scatter").get_memory();+ cldnn::mem_lock<float> lock(out, get_test_stream());+ (void)lock[0];+ }++ // Measure+ auto t0 = std::chrono::high_resolution_clock::now();+ for (int i = 0; i < measure_iters; ++i) {+ network->set_input_data("data", data_mem);+ network->set_input_data("updates", updates_mem);+ auto outputs = network->execute();+ auto out = outputs.at("slice_scatter").get_memory();+ cldnn::mem_lock<float> lock(out, get_test_stream());+ (void)lock[0];+ }+ auto t1 = std::chrono::high_resolution_clock::now();+ double total_us = std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count();+ return total_us / measure_iters;+ }+};++TEST_F(SliceScatterPerfTest, DISABLED_large_tensor_perf) {+ // Large tensor: data [4, 16, 64, 256], updates [4, 16, 32, 256]+ // step=1 on all axes => opt kernel eligible (X=256 >> VEC_SIZE=8)+ const ov::PartialShape data_shape{4, 16, 64, 256};+ const ov::PartialShape updates_shape{4, 16, 32, 256};+ std::vector<int64_t> start_vals{0, 0, 0, 0};+ std::vector<int64_t> stop_vals{4, 16, 32, 256};+ std::vector<int64_t> step_vals{1, 1, 1, 1};++ const int warmup = 10;+ const int iters = 50;++ double avg_us = BenchmarkSliceScatter(data_shape, updates_shape, start_vals, stop_vals, step_vals, warmup, iters);+ std::cout << "[PERF] SliceScatter large tensor (4x64x128x256, step=1): " << avg_us << " us/iter (" << iters << " iters)" << std::endl;+ ASSERT_GT(avg_us, 0.0);+}++TEST_F(SliceScatterPerfTest, DISABLED_medium_tensor_perf) {+ // Medium tensor: data [8, 32, 64, 64], updates [8, 32, 32, 64]+ const ov::PartialShape data_shape{8, 32, 64, 64};+ const ov::PartialShape updates_shape{8, 32, 32, 64};+ std::vector<int64_t> start_vals{0, 0, 0, 0};+ std::vector<int64_t> stop_vals{8, 32, 32, 64};+ std::vector<int64_t> step_vals{1, 1, 1, 1};++ const int warmup = 10;+ const int iters = 100;++ double avg_us = BenchmarkSliceScatter(data_shape, updates_shape, start_vals, stop_vals, step_vals, warmup, iters);+ std::cout << "[PERF] SliceScatter medium tensor (8x32x64x64, step=1): " << avg_us << " us/iter (" << iters << " iters)" << std::endl;+ ASSERT_GT(avg_us, 0.0);+}++} // anonymous namespace