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 SparseFillEmptyRows-16 support (#31226)
Przemyslaw Wysocki986477da0f66
diff --git a/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp b/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hppindex f582a9d4939..c08472654a3 100644--- a/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp@@ -281,6 +281,7 @@ REGISTER_FACTORY(v15, Col2Im);// ------------------------------ Supported v16 ops ----------------------------- //REGISTER_FACTORY(v16, ISTFT);+REGISTER_FACTORY(v16, SparseFillEmptyRows);REGISTER_FACTORY(v16, AvgPool);// --------------------------- Supported internal ops --------------------------- //diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/sparse_fill_empty_rows.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/sparse_fill_empty_rows.hppnew file mode 100644index 00000000000..a84147ef920--- /dev/null+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/sparse_fill_empty_rows.hpp@@ -0,0 +1,84 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once+#include "primitive.hpp"+#include "intel_gpu/graph/serialization/utils.hpp"++namespace cldnn {++/// @brief sparse_fill_empty_rows operation.+/// @details Checks the specification for details.+struct sparse_fill_empty_rows : public primitive_base<sparse_fill_empty_rows> {+ CLDNN_DECLARE_PRIMITIVE(sparse_fill_empty_rows)++ sparse_fill_empty_rows() : primitive_base("", {}) {}++ /// @brief Constructs sparse_fill_empty_rows primitive.+ /// @param id This primitive id.+ /// @param inputs List of input primitives (check specification for details).+ sparse_fill_empty_rows(const primitive_id& id,+ const std::vector<input_info>& inputs)+ : primitive_base(id, inputs, 3) {}++ std::vector<float> values;+ std::vector<int64_t> dense_shape;+ std::vector<int64_t> indices;+ float default_value;++ sparse_fill_empty_rows(const primitive_id& id,+ const std::vector<input_info>& inputs,+ const std::vector<float>& values,+ const std::vector<int64_t>& dense_shape,+ const std::vector<int64_t>& indices,+ float default_value)+ : primitive_base(id, inputs, 3),+ values(values),+ dense_shape(dense_shape),+ indices(indices),+ default_value(default_value) {}++ size_t hash() const override {+ size_t seed = primitive::hash();+ membuf mem_buf;+ {+ std::ostream out_mem(&mem_buf);+ BinaryOutputBuffer ob = BinaryOutputBuffer(out_mem);+ save(ob);+ }+ seed = hash_range(seed, mem_buf.begin(), mem_buf.end());+ seed = hash_range(seed, indices.begin(), indices.end());+ seed = hash_range(seed, values.begin(), values.end());+ seed = hash_range(seed, dense_shape.begin(), dense_shape.end());+ seed = hash_combine(seed, default_value);+ return seed;+ }++ bool operator==(const primitive& rhs) const override {+ if (!compare_common_params(rhs))+ return false;+ auto rhs_casted = downcast<const sparse_fill_empty_rows>(rhs);+ return indices == rhs_casted.indices &&+ values == rhs_casted.values &&+ dense_shape == rhs_casted.dense_shape &&+ default_value == rhs_casted.default_value;+ }++ void save(BinaryOutputBuffer& ob) const override {+ primitive_base<sparse_fill_empty_rows>::save(ob);+ ob << indices;+ ob << values;+ ob << dense_shape;+ ob << default_value;+ }++ void load(BinaryInputBuffer& ib) override {+ primitive_base<sparse_fill_empty_rows>::load(ib);+ ib >> indices;+ ib >> values;+ ib >> dense_shape;+ ib >> default_value;+ }+};+} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/register.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/register.cppindex a3928f5b420..3002a779c89 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/register.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/register.cpp@@ -83,6 +83,7 @@ void register_implementations() {REGISTER_OCL(search_sorted);REGISTER_OCL(STFT);REGISTER_OCL(ISTFT);+ REGISTER_OCL(sparse_fill_empty_rows);}} // namespace ocldiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/register.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl/register.hppindex c5f697c8135..7960a8803f5 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/register.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/register.hpp@@ -56,6 +56,7 @@#include "intel_gpu/primitives/shuffle_channels.hpp"#include "intel_gpu/primitives/slice.hpp"#include "intel_gpu/primitives/space_to_batch.hpp"+#include "intel_gpu/primitives/sparse_fill_empty_rows.hpp"#include "intel_gpu/primitives/strided_slice.hpp"#include "intel_gpu/primitives/swiglu.hpp"#include "intel_gpu/primitives/tile.hpp"@@ -152,6 +153,7 @@ REGISTER_OCL(unique_gather);REGISTER_OCL(search_sorted);REGISTER_OCL(STFT);REGISTER_OCL(ISTFT);+REGISTER_OCL(sparse_fill_empty_rows);#undef REGISTER_OCLdiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/sparse_fill_empty_rows.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/sparse_fill_empty_rows.cppnew file mode 100644index 00000000000..31f710ac383--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/sparse_fill_empty_rows.cpp@@ -0,0 +1,67 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "primitive_base.hpp"++#include "sparse_fill_empty_rows_inst.h"+#include "sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_ref.h"+#include "sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_selector.h"++namespace cldnn::ocl {++struct sparse_fill_empty_rows_impl : typed_primitive_impl_ocl<sparse_fill_empty_rows> {+ using parent = typed_primitive_impl_ocl<sparse_fill_empty_rows>;+ using parent::parent;+ using kernel_selector_t = kernel_selector::sparse_fill_empty_rows_kernel_selector;+ using kernel_params_t = kernel_selector::sparse_fill_empty_rows_params;++ DECLARE_OBJECT_TYPE_SERIALIZATION(cldnn::ocl::sparse_fill_empty_rows_impl)++ std::unique_ptr<primitive_impl> clone() const override {+ return make_deep_copy<sparse_fill_empty_rows_impl, kernel_params_t>(*this);+ }++public:+ static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param, bool shape_agnostic = false) {+ auto params = get_default_params<kernel_selector::sparse_fill_empty_rows_params>(impl_param, shape_agnostic);++ // Manually add all inputs/outputs except for the first ones+ for (size_t i = 1; i < impl_param.input_layouts.size(); ++i) {+ params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(i)));+ }+ for (size_t i = 1; i < impl_param.output_layouts.size(); ++i) {+ params.outputs.push_back(convert_data_tensor(impl_param.get_output_layout(i)));+ }+ return params;+ }++ void update_dispatch_data(const kernel_impl_params& impl_param) override {+ // If model loaded from cache, params are not initialized, so we create a new object and reuse it in the future+ if (_kernel_data.params == nullptr) {+ _kernel_data.params = std::make_shared<kernel_params_t>(get_kernel_params(impl_param, true));+ }++ update_shapes(*_kernel_data.params, impl_param);+ (_kernel_data.update_dispatch_data_func)(*_kernel_data.params, _kernel_data);+ }+};++namespace detail {++attach_sparse_fill_empty_rows_impl::attach_sparse_fill_empty_rows_impl() {+ auto types = {data_types::f16, data_types::f32, data_types::i8, data_types::u8, data_types::i32, data_types::i64};+ auto formats = {format::bfyx};+ implementation_map<sparse_fill_empty_rows>::add(+ impl_types::ocl,+ shape_types::static_shape,+ typed_primitive_impl_ocl<sparse_fill_empty_rows>::create<sparse_fill_empty_rows_impl>,+ types,+ formats);+}++} // namespace detail+} // namespace cldnn::ocl++BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::sparse_fill_empty_rows_impl)+BIND_BINARY_BUFFER_WITH_TYPE(cldnn::sparse_fill_empty_rows)diff --git a/src/plugins/intel_gpu/src/graph/include/sparse_fill_empty_rows_inst.h b/src/plugins/intel_gpu/src/graph/include/sparse_fill_empty_rows_inst.hnew file mode 100644index 00000000000..ce2d7d01a23--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/include/sparse_fill_empty_rows_inst.h@@ -0,0 +1,45 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#pragma once++#include <intel_gpu/primitives/sparse_fill_empty_rows.hpp>+#include "primitive_inst.h"++namespace cldnn {+template <>+struct typed_program_node<sparse_fill_empty_rows> : public typed_program_node_base<sparse_fill_empty_rows> {+ using parent = typed_program_node_base<sparse_fill_empty_rows>;+ typed_program_node(const std::shared_ptr<sparse_fill_empty_rows> prim, program& prog) : parent(prim, prog) {}++public:+ using parent::parent;++ program_node& input(size_t idx = 0) const {+ return get_dependency(idx);+ }+ std::vector<size_t> get_shape_infer_dependencies() const override {+ return {1, 2};+ }+};++using SparseFillEmptyRows_node = typed_program_node<sparse_fill_empty_rows>;++template <>+class typed_primitive_inst<sparse_fill_empty_rows> : public typed_primitive_inst_base<sparse_fill_empty_rows> {+ using parent = typed_primitive_inst_base<sparse_fill_empty_rows>;+ using parent::parent;++public:+ typed_primitive_inst(network& network, SparseFillEmptyRows_node const& desc);+ template <typename ShapeType>+ static std::vector<layout> calc_output_layouts(SparseFillEmptyRows_node const& node, kernel_impl_params const& impl_param);+ static layout calc_output_layout(SparseFillEmptyRows_node const& node, kernel_impl_params const& impl_param);+ static std::string to_string(SparseFillEmptyRows_node const& node);+ bool need_reset_output_memory() const override {+ return true;+ }+};++using SparseFillEmptyRows_inst = typed_primitive_inst<sparse_fill_empty_rows>;+} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/registry/registry.hpp b/src/plugins/intel_gpu/src/graph/registry/registry.hppindex d33a3a21e3c..5b779a245ef 100644--- a/src/plugins/intel_gpu/src/graph/registry/registry.hpp+++ b/src/plugins/intel_gpu/src/graph/registry/registry.hpp@@ -232,3 +232,4 @@ REGISTER_DEFAULT_IMPLS(unique_gather, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(search_sorted, OCL_S, OCL_D);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);diff --git a/src/plugins/intel_gpu/src/graph/sparse_fill_empty_rows.cpp b/src/plugins/intel_gpu/src/graph/sparse_fill_empty_rows.cppnew file mode 100644index 00000000000..3551ec36b34--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/sparse_fill_empty_rows.cpp@@ -0,0 +1,72 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#include <sparse_fill_empty_rows_inst.h>+#include <json_object.h>++#include <sstream>++#include "sparse_fill_empty_rows_shape_inference.hpp"+#include "memory_accessor.hpp"+#include "openvino/core/enum_names.hpp"+#include "primitive_type_base.h"++namespace cldnn {+GPU_DEFINE_PRIMITIVE_TYPE_ID(sparse_fill_empty_rows)++SparseFillEmptyRows_inst::typed_primitive_inst(network& network, SparseFillEmptyRows_node const& node) : parent(network, node) {}++layout SparseFillEmptyRows_inst::calc_output_layout(SparseFillEmptyRows_node const& node, kernel_impl_params const& impl_param) {+ return calc_output_layouts<ov::PartialShape>(node, impl_param)[0];+}++template <typename ShapeType>+std::vector<layout> SparseFillEmptyRows_inst::calc_output_layouts(SparseFillEmptyRows_node const& node, kernel_impl_params const& impl_param) {+ auto primitive = impl_param.typed_desc<sparse_fill_empty_rows>();++ const auto& values_layout = impl_param.get_input_layout(0);+ const auto& dense_shape_layout = impl_param.get_input_layout(1);+ const auto& indices_layout = impl_param.get_input_layout(2);+ const auto& default_value_layout = impl_param.get_input_layout(3);++ std::vector<ShapeType> input_shapes = {+ values_layout.get<ShapeType>(),+ dense_shape_layout.get<ShapeType>(),+ indices_layout.get<ShapeType>(),+ default_value_layout.get<ShapeType>(),+ };+ std::unordered_map<size_t, ov::Tensor> tensors;+ if (!primitive->dense_shape.empty()) {+ tensors.emplace(1, ov::Tensor(ov::element::i64, ov::Shape{primitive->dense_shape.size()}, primitive->dense_shape.data()));+ }+ if (!primitive->indices.empty()) {+ tensors.emplace(2, ov::Tensor(ov::element::i64, ov::Shape{primitive->indices.size()}, primitive->indices.data()));+ }++ const auto ta = MemoryAccessor(&impl_param.memory_deps, impl_param.get_stream(), ov::make_tensor_accessor(tensors));++ std::vector<ShapeType> output_shapes;+ ov::op::v16::SparseFillEmptyRows op;+ output_shapes = shape_infer(&op, input_shapes, ta);++ return {+ layout{output_shapes[0], indices_layout.data_type, indices_layout.format},+ layout{output_shapes[1], values_layout.data_type, values_layout.format},+ layout{output_shapes[2], indices_layout.data_type, indices_layout.format}+ };+}++std::string SparseFillEmptyRows_inst::to_string(SparseFillEmptyRows_node const& node) {+ auto node_info = node.desc_to_json();+ json_composite SparseFillEmptyRows_info;+ SparseFillEmptyRows_info.add("values", node.input(0).id());+ SparseFillEmptyRows_info.add("dense_shape", node.input(1).id());+ SparseFillEmptyRows_info.add("indices", node.input(2).id());+ SparseFillEmptyRows_info.add("default_value", node.input(3).id());+ node_info->add("SparseFillEmptyRows info", SparseFillEmptyRows_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/cl_kernels/sparse_fill_empty_rows_ref.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/sparse_fill_empty_rows_ref.clnew file mode 100644index 00000000000..587f4e97723--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/sparse_fill_empty_rows_ref.cl@@ -0,0 +1,62 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "include/batch_headers/common.cl"++inline bool FUNC(row_exists)(const __global INPUT2_TYPE* restrict indices, uint indices_count, INPUT2_TYPE row_idx) {+ for (uint i = 0; i < indices_count; i++) {+ if (indices[i * 2] == row_idx) {+ return true;+ }+ }+ return false;+}++KERNEL(sparse_fill_empty_rows_ref)(+ const __global INPUT0_TYPE* restrict values, // [N] - values at specified indices+ const __global INPUT1_TYPE* restrict _unused, // [2] - shape of the dense tensor (rows, cols)+ const __global INPUT2_TYPE* restrict indices, // [N, 2] - indices (row, col) coordinates+ const __global INPUT3_TYPE* restrict default_value, // scalar - default value+ __global OUTPUT_TYPE* restrict output_indices, // [M, 2] - output indices+ __global OUTPUT1_TYPE* restrict output_values, // [M] - output values+ __global OUTPUT2_TYPE* restrict empty_row_indicator // [dense_shape[0]] - indicator if row was empty+) {+ const uint indices_count = INDICES_COUNT; // JIT constant for N+ const uint row_idx = get_global_id(0);+ uint output_base_pos = 0;++ // Count all indices in rows before this one+ for (uint i = 0; i < indices_count; i++) {+ if (indices[i * 2] < row_idx) {+ output_base_pos++;+ }+ }+ // Add empty rows before this one+ for (uint i = 0; i < row_idx; i++) {+ if (!FUNC_CALL(row_exists)(indices, indices_count, i)) {+ output_base_pos++;+ }+ }++ const bool is_empty = !FUNC_CALL(row_exists)(indices, indices_count, row_idx);+ empty_row_indicator[row_idx] = is_empty;+ if (is_empty) {+ // Insert default value at [row_idx, 0]+ output_indices[output_base_pos * 2] = row_idx;+ output_indices[output_base_pos * 2 + 1] = 0;+ output_values[output_base_pos] = *default_value;+ } else {+ // Find all existing entries for this row and place them in order+ uint row_pos = 0;+ for (uint i = 0; i < indices_count; i++) {+ if (indices[i * 2] == row_idx) {+ uint output_pos = output_base_pos + row_pos;+ output_indices[output_pos * 2] = indices[i * 2];+ output_indices[output_pos * 2 + 1] = indices[i * 2 + 1];+ output_values[output_pos] = values[i];+ row_pos++;+ }+ }+ }+}diff --git a/src/plugins/intel_gpu/src/kernel_selector/common_types.h b/src/plugins/intel_gpu/src/kernel_selector/common_types.hindex ea9656817a9..01d9f019d3e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/common_types.h+++ b/src/plugins/intel_gpu/src/kernel_selector/common_types.h@@ -73,6 +73,7 @@ enum class KernelType {GATHER_TREE,SPACE_TO_DEPTH,SPACE_TO_BATCH,+ SPARSE_FILL_EMPTY_ROWS,GRN,CTC_GREEDY_DECODER,CTC_LOSS,diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_ref.cppnew file mode 100644index 00000000000..1d0a70cb2d9--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_ref.cpp@@ -0,0 +1,96 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#include "sparse_fill_empty_rows_kernel_ref.h"+#include <kernel_selector_utils.h>++namespace kernel_selector {++ParamsKey SparseFillEmptyRowsKernelRef::GetSupportedKey() const {+ ParamsKey k;+ k.EnableInputDataType(Datatype::F16);+ k.EnableInputDataType(Datatype::F32);+ k.EnableInputDataType(Datatype::UINT8);+ k.EnableInputDataType(Datatype::INT8);+ k.EnableInputDataType(Datatype::INT32);+ k.EnableInputDataType(Datatype::INT64);+ k.EnableOutputDataType(Datatype::F16);+ k.EnableOutputDataType(Datatype::F32);+ k.EnableOutputDataType(Datatype::UINT8);+ k.EnableOutputDataType(Datatype::INT8);+ k.EnableOutputDataType(Datatype::INT32);+ k.EnableOutputDataType(Datatype::INT64);+ k.EnableAllInputLayout();+ k.EnableAllOutputLayout();+ k.EnableTensorOffset();+ k.EnableTensorPitches();+ k.EnableBatching();+ k.EnableDifferentTypes();+ return k;+}++namespace {+SparseFillEmptyRowsKernelRef::DispatchData SetDefault(const sparse_fill_empty_rows_params& params) {+ SparseFillEmptyRowsKernelRef::DispatchData dispatchData;+ const auto rows_count = params.outputs[2].GetDims()[3].v; // empty_row_indicator has size [rows]+ dispatchData.gws[0] = rows_count;+ dispatchData.gws[1] = 1;+ dispatchData.gws[2] = 1;+ dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo);++ return dispatchData;+}+} // anonymous namespace++KernelsData SparseFillEmptyRowsKernelRef::GetKernelsData(const Params ¶ms) const {+ if (!Validate(params)) {+ return {};+ }+ KernelData kernel_data = KernelData::Default<sparse_fill_empty_rows_params>(params);+ kernel_data.kernels[0].skip_execution = SkipKernelExecution(static_cast<const sparse_fill_empty_rows_params&>(params));+ sparse_fill_empty_rows_params &new_params = dynamic_cast<sparse_fill_empty_rows_params&>(*kernel_data.params.get());+ auto sparse_fill_empty_rows_specific_jit = GetJitConstants(new_params);+ auto dispatch_data = SetDefault(new_params);+ auto entry_point = GetEntryPoint(kernelName, new_params.layerID, params);+ auto jit = CreateJit(kernelName, sparse_fill_empty_rows_specific_jit, entry_point);+ FillCLKernelData(kernel_data.kernels[0],+ dispatch_data,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ EXE_MODE_DEFAULT, // exeMode+ false, // weights+ false, // bias+ 4, // number_of_inputs+ 0, // number_of_inputs_for_fused_prims+ 3, // number_of_outputs+ false); // is_dynamic+ return {kernel_data};+}++float SparseFillEmptyRowsKernelRef::GetKernelsPriority(const Params ¶ms) const {+ return FORCE_PRIORITY_1;+}++bool SparseFillEmptyRowsKernelRef::Validate(const Params& p) const {+ if (p.GetType() != KernelType::SPARSE_FILL_EMPTY_ROWS) {+ return false;+ }+ return true;+}++JitConstants SparseFillEmptyRowsKernelRef::GetJitConstants(const sparse_fill_empty_rows_params& params) const {+ JitConstants jit = MakeBaseParamsJitConstants(params);+ jit.AddConstant(MakeJitConstant("INDICES_COUNT", params.inputs[2].LogicalSize() / 2));+ return jit;+}++bool SparseFillEmptyRowsKernelRef::SkipKernelExecution(const sparse_fill_empty_rows_params& params, size_t kernel_id) const {+ // If indices tensor size has changed the kernel has to be executed+ if (params.inputs[2].LogicalSize() != params.outputs[0].LogicalSize()) {+ return false;+ }+ return KernelData::SkipKernelExecution(params);+}+} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_ref.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_ref.hnew file mode 100644index 00000000000..c973fec1d4a--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_ref.h@@ -0,0 +1,31 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#pragma once++#include <kernel_base_opencl.h>++namespace kernel_selector {+struct sparse_fill_empty_rows_params : public base_params {+ sparse_fill_empty_rows_params() : base_params{KernelType::SPARSE_FILL_EMPTY_ROWS} {}+};++class SparseFillEmptyRowsKernelRef : public KernelBaseOpenCL {+public:+ using KernelBaseOpenCL::KernelBaseOpenCL;++ using DispatchData = CommonDispatchData;++ SparseFillEmptyRowsKernelRef() : KernelBaseOpenCL{"sparse_fill_empty_rows_ref"} {}+ KernelsData GetKernelsData(const Params& params) const override;+ KernelsPriority GetKernelsPriority(const Params& params) const override;+ ParamsKey GetSupportedKey() const override;+ bool Validate(const Params&) const override;++protected:+ JitConstants GetJitConstants(const sparse_fill_empty_rows_params& params) const;+ bool SkipKernelExecution(const sparse_fill_empty_rows_params& params, size_t kernel_id = 0) const;+// void GetUpdateDispatchDataFunc(KernelData& kd) const override;+};++} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_selector.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_selector.cppnew file mode 100644index 00000000000..796d04a41e3--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_selector.cpp@@ -0,0 +1,17 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#include "sparse_fill_empty_rows_kernel_selector.h"+#include "sparse_fill_empty_rows_kernel_ref.h"++namespace kernel_selector {++sparse_fill_empty_rows_kernel_selector::sparse_fill_empty_rows_kernel_selector() {+ Attach<SparseFillEmptyRowsKernelRef>();+}++KernelsData sparse_fill_empty_rows_kernel_selector::GetBestKernels(const Params ¶ms) const {+ return GetNaiveBestKernel(params, KernelType::SPARSE_FILL_EMPTY_ROWS);+}++} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_selector.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_selector.hnew file mode 100644index 00000000000..63991666435--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/sparse_fill_empty_rows/sparse_fill_empty_rows_kernel_selector.h@@ -0,0 +1,20 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#pragma once++#include "kernel_selector.h"++namespace kernel_selector {+class sparse_fill_empty_rows_kernel_selector : public kernel_selector_base {+public:+ static sparse_fill_empty_rows_kernel_selector& Instance() {+ static sparse_fill_empty_rows_kernel_selector instance_;+ return instance_;+ }++ sparse_fill_empty_rows_kernel_selector();++ KernelsData GetBestKernels(const Params& params) const override;+};+} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/plugin/ops/sparse_fill_empty_rows.cpp b/src/plugins/intel_gpu/src/plugin/ops/sparse_fill_empty_rows.cppnew file mode 100644index 00000000000..1274a57ceb5--- /dev/null+++ b/src/plugins/intel_gpu/src/plugin/ops/sparse_fill_empty_rows.cpp@@ -0,0 +1,50 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/sparse_fill_empty_rows.hpp"++#include "intel_gpu/plugin/common_utils.hpp"+#include "intel_gpu/plugin/program_builder.hpp"+#include "intel_gpu/primitives/sparse_fill_empty_rows.hpp"+#include "openvino/op/constant.hpp"++namespace ov::intel_gpu {++static void CreateSparseFillEmptyRowsOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v16::SparseFillEmptyRows>& op) {+ validate_inputs_count(op, {4});+ auto inputs = p.GetInputInfo(op);+ std::string layerName = layer_type_name_ID(op);++ auto indices_constant = ov::as_type_ptr<ov::op::v0::Constant>(op->get_input_node_shared_ptr(0));+ auto values_constant = ov::as_type_ptr<ov::op::v0::Constant>(op->get_input_node_shared_ptr(1));+ auto dense_shape_constant = ov::as_type_ptr<ov::op::v0::Constant>(op->get_input_node_shared_ptr(2));+ auto default_value_constant = ov::as_type_ptr<ov::op::v0::Constant>(op->get_input_node_shared_ptr(3));++ std::vector<int64_t> indices = indices_constant ? indices_constant->cast_vector<int64_t>() : std::vector<int64_t>{};+ std::vector<float> values = values_constant ? values_constant->cast_vector<float>() : std::vector<float>{};+ std::vector<int64_t> dense_shape = dense_shape_constant ? dense_shape_constant->cast_vector<int64_t>() : std::vector<int64_t>{};+ float default_value = default_value_constant ? default_value_constant->cast_vector<float>()[0] : 0.0f;++ std::shared_ptr<cldnn::sparse_fill_empty_rows> prim = nullptr;++ if (indices_constant && values_constant && dense_shape_constant && default_value_constant) {+ prim = std::make_shared<cldnn::sparse_fill_empty_rows>(+ layerName,+ inputs,+ values,+ dense_shape,+ indices,+ default_value);+ } else {+ prim = std::make_shared<cldnn::sparse_fill_empty_rows>(+ layerName,+ inputs);+ }++ p.add_primitive(*op, prim);+}++REGISTER_FACTORY_IMPL(v16, SparseFillEmptyRows);++} // namespace ov::intel_gpudiff --git a/src/plugins/intel_gpu/src/runtime/execution_config.cpp b/src/plugins/intel_gpu/src/runtime/execution_config.cppindex 03fc7da88a8..15cb99193e8 100644--- a/src/plugins/intel_gpu/src/runtime/execution_config.cpp+++ b/src/plugins/intel_gpu/src/runtime/execution_config.cpp@@ -15,6 +15,7 @@#include "intel_gpu/op/sdpa.hpp"#include "intel_gpu/op/indirect_sdpa.hpp"#include "openvino/op/search_sorted.hpp"+#include "openvino/op/sparse_fill_empty_rows.hpp"#include "openvino/op/stft.hpp"#include "openvino/op/istft.hpp"#include "ov_ops/dynamic_quantize.hpp"@@ -52,7 +53,10 @@ bool requires_new_shape_infer(const std::shared_ptr<ov::Node>& op) {// E.g. static input shapes: sorted:[8], values:[2,3,4] are prefectly fine,// but sorted:[8,1,1,1], values:[2,3,4,1] is not valid.// Similar case for STFT and ISTFT- if (ov::is_type<ov::op::v15::SearchSorted>(op) || ov::is_type<ov::op::v15::STFT>(op) || ov::is_type<ov::op::v16::ISTFT>(op))+ if (ov::is_type<ov::op::v15::SearchSorted>(op)||+ ov::is_type<ov::op::v15::STFT>(op) ||+ ov::is_type<ov::op::v16::ISTFT>(op) ||+ ov::is_type<ov::op::v16::SparseFillEmptyRows>(op))return true;if (ov::is_type<ov::op::internal::DynamicQuantize>(op) || ov::is_type<ov::op::internal::RMS>(op))diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/sparse_fill_empty_rows.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/sparse_fill_empty_rows.cppnew file mode 100644index 00000000000..cfb9274a456--- /dev/null+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/sparse_fill_empty_rows.cpp@@ -0,0 +1,14 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "single_op_tests/sparse_fill_empty_rows.hpp"++#include "common_test_utils/test_constants.hpp"++namespace ov::test {+INSTANTIATE_TEST_SUITE_P(smoke_SparseFillEmptyRows_static,+ SparseFillEmptyRowsLayerTest,+ SparseFillEmptyRowsLayerTest::GetTestDataForDevice(ov::test::utils::DEVICE_GPU),+ SparseFillEmptyRowsLayerTest::getTestCaseName);+} // namespace ov::testdiff --git a/src/plugins/intel_gpu/tests/unit/test_cases/sparse_fill_empty_rows_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/sparse_fill_empty_rows_gpu_test.cppnew file mode 100644index 00000000000..50fbe6f7f22--- /dev/null+++ b/src/plugins/intel_gpu/tests/unit/test_cases/sparse_fill_empty_rows_gpu_test.cpp@@ -0,0 +1,223 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include <intel_gpu/primitives/data.hpp>+#include <intel_gpu/primitives/input_layout.hpp>+#include <intel_gpu/primitives/mutable_data.hpp>+#include <intel_gpu/primitives/sparse_fill_empty_rows.hpp>++#include "test_utils.h"++using namespace cldnn;+using namespace ::tests;++namespace {++constexpr float REL_EPS = 2e-3f;+constexpr float ABS_EPS = 1e-5f;++namespace helpers {+// TODO: Move to common place.++// Converts float vector to another type vector.+template <typename T>+std::vector<T> ConverFloatVector(const std::vector<float>& vec) {+ std::vector<T> ret;+ ret.reserve(vec.size());+ for (const auto& val : vec) {+ ret.push_back(T(val));+ }+ return ret;+}++// Allocates tensor with given shape and data.+template <typename TDataType>+memory::ptr AllocateTensor(ov::PartialShape shape, const std::vector<TDataType>& data) {+ const layout lo = {shape, ov::element::from<TDataType>(), cldnn::format::bfyx};+ EXPECT_EQ(lo.get_linear_size(), data.size());+ memory::ptr tensor = get_test_engine().allocate_memory(lo);+ set_values<TDataType>(tensor, data);+ return tensor;+}++template <typename T>+void CompareTypedBuffers(const memory::ptr& output, const memory::ptr& expectedOutput, cldnn::stream& stream) {+ mem_lock<T> output_ptr(output, stream);+ mem_lock<T> wanted_output_ptr(expectedOutput, stream);++ ASSERT_EQ(output->get_layout(), expectedOutput->get_layout());+ 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], REL_EPS, ABS_EPS)) << "at index " << i;+}++void CompareBuffers(const memory::ptr& output, const memory::ptr& expectedOutput, cldnn::stream& stream) {+ ASSERT_EQ(output->get_layout(), expectedOutput->get_layout());+ auto type = output->get_layout().data_type;++ switch (type) {+ case data_types::f32:+ helpers::CompareTypedBuffers<float>(output, expectedOutput, stream);+ break;+ case data_types::i64:+ helpers::CompareTypedBuffers<int64_t>(output, expectedOutput, stream);+ break;+ default:+ GTEST_FAIL() << "Unsupported data type: " << type;+ break;+ }+}++} // namespace helpers++struct SparseFillEmptyRowsTestParams {+ std::vector<float> indicesData;+ std::vector<float> valuesData;+ std::vector<float> denseShapeData;+ std::vector<float> expectedIndicesOutput;+ std::vector<float> expectedValuesOutput;+ std::vector<float> expectedEmptyRowIndicatorOutput;+ std::string testcaseName;+};++class sparse_fill_empty_rows_test : public ::testing::TestWithParam<SparseFillEmptyRowsTestParams> {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<SparseFillEmptyRowsTestParams>& obj) {+ const auto& param = obj.param;+ std::ostringstream result;+ result << "indicesDataSize=" << param.indicesData.size();+ result << "_valuesDataSize=" << param.valuesData.size();+ result << "_expectedIndicesOutputSize=" << param.expectedIndicesOutput.size();+ result << "_expectedValuesOutputSize=" << param.expectedValuesOutput.size();+ result << "_expectedEmptyRowIndicatorOutputSize=" << param.expectedEmptyRowIndicatorOutput.size();+ result << "_" << param.testcaseName;+ return result.str();+ }++ struct SparseFillEmptyRowsInferenceParams {+ memory::ptr values;+ memory::ptr denseShape;+ memory::ptr indices;+ memory::ptr defaultValue;+ memory::ptr expectedIndicesOutput;+ memory::ptr expectedValuesOutput;+ memory::ptr expectedEmptyRowIndicatorOutput;+ };++ template <ov::element::Type_t ET>+ SparseFillEmptyRowsInferenceParams PrepareInferenceParams(const SparseFillEmptyRowsTestParams& testParam) {+ using T = typename ov::element_type_traits<ET>::value_type;+ SparseFillEmptyRowsInferenceParams ret;+ const auto indicesRows = testParam.indicesData.size() / 2;++ ret.indices = helpers::AllocateTensor<int64_t>(+ ov::Shape{indicesRows, 2},+ helpers::ConverFloatVector<int64_t>(testParam.indicesData));+ ret.values = helpers::AllocateTensor<T>(+ ov::Shape{testParam.valuesData.size()},+ helpers::ConverFloatVector<T>(testParam.valuesData));+ ret.denseShape = helpers::AllocateTensor<int64_t>(+ ov::Shape{2}, helpers::ConverFloatVector<int64_t>(testParam.denseShapeData));+ ret.defaultValue = helpers::AllocateTensor<T>(ov::Shape{}, {42.0f});++ ret.expectedIndicesOutput = helpers::AllocateTensor<int64_t>(+ ov::Shape{testParam.expectedIndicesOutput.size() / 2, 2},+ helpers::ConverFloatVector<int64_t>(testParam.expectedIndicesOutput));+ ret.expectedValuesOutput = helpers::AllocateTensor<T>(+ ov::Shape{testParam.expectedValuesOutput.size()},+ helpers::ConverFloatVector<T>(testParam.expectedValuesOutput));+ ret.expectedEmptyRowIndicatorOutput = helpers::AllocateTensor<int64_t>(+ ov::Shape{testParam.expectedEmptyRowIndicatorOutput.size()},+ helpers::ConverFloatVector<int64_t>(testParam.expectedEmptyRowIndicatorOutput));++ return ret;+ }++ void Execute(const SparseFillEmptyRowsInferenceParams& params, const SparseFillEmptyRowsTestParams& testParams) {+ auto stream = get_test_stream_ptr(get_test_default_config(engine_));+ topology topology;++ topology.add(input_layout("values", params.values->get_layout()));+ topology.add(input_layout("denseShape", params.denseShape->get_layout()));+ topology.add(input_layout("indices", params.indices->get_layout()));+ topology.add(input_layout("default_value", params.defaultValue->get_layout()));++ std::vector<input_info> inputs = {+ input_info("values"),+ input_info("denseShape"),+ input_info("indices"),+ input_info("default_value"),+ };++ topology.add(sparse_fill_empty_rows(+ "sparse_fill_empty_rows",+ inputs,+ testParams.valuesData,+ helpers::ConverFloatVector<int64_t>(testParams.denseShapeData),+ helpers::ConverFloatVector<int64_t>(testParams.indicesData),+ 42.0f+ ));++ topology.add(reorder("output_indices", input_info("sparse_fill_empty_rows", 0), format::bfyx, data_types::i64));+ topology.add(reorder("output_values", input_info("sparse_fill_empty_rows", 1), format::bfyx, params.values->get_layout().data_type));+ topology.add(reorder("output_empty_row_indicator", input_info("sparse_fill_empty_rows", 2), format::bfyx, data_types::i64));++ 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_, topology, config, stream, false);+ network->set_input_data("values", params.values);+ network->set_input_data("denseShape", params.denseShape);+ network->set_input_data("indices", params.indices);+ network->set_input_data("default_value", params.defaultValue);++ auto outputs = network->execute();+ auto output_indices = outputs.at("output_indices").get_memory();+ auto output_values = outputs.at("output_values").get_memory();+ auto output_empty_row_indicator = outputs.at("output_empty_row_indicator").get_memory();++ helpers::CompareBuffers(output_indices, params.expectedIndicesOutput, get_test_stream());+ helpers::CompareBuffers(output_values, params.expectedValuesOutput, get_test_stream());+ helpers::CompareBuffers(output_empty_row_indicator, params.expectedEmptyRowIndicatorOutput, get_test_stream());+ }++private:+ engine& engine_ = get_test_engine();+};++std::vector<SparseFillEmptyRowsTestParams> generateTestParams() {+ std::vector<SparseFillEmptyRowsTestParams> params;+#define TEST_DATA(indicesData, \+ valuesData, \+ denseShapeData, \+ expectedIndicesOutput, \+ expectedValuesOutput, \+ expectedEmptyRowIndicatorOutput, \+ testcaseName) \+ params.push_back(SparseFillEmptyRowsTestParams{indicesData, \+ valuesData, \+ denseShapeData, \+ expectedIndicesOutput, \+ expectedValuesOutput, \+ expectedEmptyRowIndicatorOutput, \+ testcaseName});++#include "unit_test_utils/tests_data/sparse_fill_empty_rows_data.h"+#undef TEST_DATA++ return params;+}++} // namespace++#define SparseFillEmptyRows_TEST_P(precision) \++ TEST_P(sparse_fill_empty_rows_test, ref_comp_f32) {+ const auto& testParams = GetParam();+ Execute(PrepareInferenceParams<ov::element::Type_t::f32>(testParams), testParams);+ }+++SparseFillEmptyRows_TEST_P(f32);++INSTANTIATE_TEST_SUITE_P(sparse_fill_empty_rows_test_suite, sparse_fill_empty_rows_test, testing::ValuesIn(generateTestParams()), sparse_fill_empty_rows_test::getTestCaseName);diff --git a/src/tests/functional/plugin/shared/include/shared_test_classes/single_op/sparse_fill_empty_rows.hpp b/src/tests/functional/plugin/shared/include/shared_test_classes/single_op/sparse_fill_empty_rows.hppnew file mode 100644index 00000000000..7889ec99ae1--- /dev/null+++ b/src/tests/functional/plugin/shared/include/shared_test_classes/single_op/sparse_fill_empty_rows.hpp@@ -0,0 +1,40 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include <string>+#include <tuple>++#include "common_test_utils/test_enums.hpp"+#include "shared_test_classes/base/ov_subgraph.hpp"++namespace ov {+namespace test {+typedef std::tuple<std::vector<InputShape>, // Input shapes (indices, values, dense_shape)+ std::vector<float>, // Default value+ ov::element::Type, // Data type for values and default value+ ov::test::utils::InputLayerType, // Input layer type+ ov::test::TargetDevice> // Target device+ SparseFillEmptyRowsParams;++class SparseFillEmptyRowsLayerTest : public testing::WithParamInterface<SparseFillEmptyRowsParams>,+ virtual public ov::test::SubgraphBaseTest {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<SparseFillEmptyRowsParams>& obj);+ using TGenData =+ testing::internal::CartesianProductHolder<testing::internal::ParamGenerator<std::vector<ov::test::InputShape>>,+ testing::internal::ParamGenerator<std::vector<float>>,+ testing::internal::ParamGenerator<ov::element::Type>,+ testing::internal::ParamGenerator<ov::test::utils::InputLayerType>,+ testing::internal::ValueArray<const char*>>;++ static const TGenData GetTestDataForDevice(const char* deviceName);++protected:+ void SetUp() override;+ void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override;+};+} // namespace test+} // namespace ovdiff --git a/src/tests/functional/plugin/shared/include/single_op_tests/sparse_fill_empty_rows.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/sparse_fill_empty_rows.hppnew file mode 100644index 00000000000..3fa9a7e38bc--- /dev/null+++ b/src/tests/functional/plugin/shared/include/single_op_tests/sparse_fill_empty_rows.hpp@@ -0,0 +1,13 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "shared_test_classes/single_op/sparse_fill_empty_rows.hpp"++namespace ov::test {+TEST_P(SparseFillEmptyRowsLayerTest, CompareWithRefs) {+ run();+};+} // namespace ov::testdiff --git a/src/tests/functional/plugin/shared/src/single_op/sparse_fill_empty_rows.cpp b/src/tests/functional/plugin/shared/src/single_op/sparse_fill_empty_rows.cppnew file mode 100644index 00000000000..d794c984dcd--- /dev/null+++ b/src/tests/functional/plugin/shared/src/single_op/sparse_fill_empty_rows.cpp@@ -0,0 +1,122 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "shared_test_classes/single_op/sparse_fill_empty_rows.hpp"++#include "common_test_utils/ov_tensor_utils.hpp"+#include "shared_test_classes/base/utils/ranges.hpp"++namespace ov {+namespace test {+std::string SparseFillEmptyRowsLayerTest::getTestCaseName(const testing::TestParamInfo<SparseFillEmptyRowsParams>& obj) {+ std::ostringstream result;+ const auto& [input_shapes, default_value, values_type, in_type, dev] = obj.param;++ for (size_t s = 0; s < input_shapes.size(); ++s) {+ const auto& shape_item = input_shapes[s];+ result << "IS" << s << "=(" << shape_item.first << ")_TS=";+ for (size_t i = 0; i < shape_item.second.size(); ++i) {+ result << "{" << ov::test::utils::vec2str(shape_item.second[i]) << "}_";+ }+ }+ result << "DefaultValue=" << default_value[0] << "_";+ result << "ValuesType=" << values_type << "_";+ result << "InputType=" << in_type << "_";+ result << "Device=" << dev;+ return result.str();+}++void SparseFillEmptyRowsLayerTest::SetUp() {+ const auto& [input_shapes, default_value, values_type, in_type, dev] = this->GetParam();+ targetDevice = dev;+ abs_threshold = 2e-5;+ init_input_shapes(input_shapes);++ auto values = std::make_shared<ov::op::v0::Parameter>(values_type, inputDynamicShapes[0]);+ auto dense_shape = std::make_shared<ov::op::v0::Parameter>(ov::element::i64, inputDynamicShapes[1]);+ auto indices = std::make_shared<ov::op::v0::Parameter>(ov::element::i64, inputDynamicShapes[2]);+ std::shared_ptr<ov::Node> default_value_node;+ if (in_type == utils::InputLayerType::PARAMETER) {+ default_value_node = std::make_shared<ov::op::v0::Parameter>(values_type, ov::Shape{});+ } else {+ default_value_node = std::make_shared<ov::op::v0::Constant>(values_type, ov::Shape{}, default_value);+ }++ auto sfe_rows = std::make_shared<ov::op::v16::SparseFillEmptyRows>(values, dense_shape, indices, default_value_node);+ if (in_type == utils::InputLayerType::PARAMETER) {+ function = std::make_shared<ov::Model>(+ sfe_rows->outputs(),+ ov::ParameterVector{values, dense_shape, indices, std::dynamic_pointer_cast<ov::op::v0::Parameter>(default_value_node)});+ } else {+ function = std::make_shared<ov::Model>(sfe_rows->outputs(), ov::ParameterVector{values, dense_shape, indices});+ }+}++void SparseFillEmptyRowsLayerTest::generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) {+ inputs.clear();+ const auto& funcInputs = function->inputs();+ const auto& valuesShape = targetInputStaticShapes[0];+ const auto& denseShapeShape = targetInputStaticShapes[1];+ const auto& indicesShape = targetInputStaticShapes[2];+ const auto valuesType = funcInputs[0].get_element_type();+ const auto idxType = funcInputs[2].get_element_type();++ std::vector<int64_t> dense_shape_values;+ for (auto v : indicesShape) {+ dense_shape_values.push_back(static_cast<int64_t>(v));+ }+ ov::Tensor dense_shape_tensor(idxType, {2});+ auto* ptr = dense_shape_tensor.data<int64_t>();+ ptr[0] = dense_shape_values[0];+ ptr[1] = dense_shape_values[1];+ inputs[funcInputs[1].get_node_shared_ptr()] = dense_shape_tensor;++ ov::test::utils::InputGenerateData valuesData;+ valuesData.start_from = 1;+ valuesData.range = 10;+ auto values_tensor = ov::test::utils::create_and_fill_tensor(valuesType, valuesShape, valuesData);+ inputs[funcInputs[0].get_node_shared_ptr()] = values_tensor;++ // Generate indices: [M, 2], each row in [0, num_rows-1], col in [0, num_cols-1]+ size_t num_rows = dense_shape_values[0];+ size_t num_cols = dense_shape_values[1];+ ov::Tensor indices_tensor(idxType, indicesShape);+ size_t M = indicesShape[0];+ auto* iptr = indices_tensor.data<int64_t>();+ for (size_t i = 0; i < M; ++i) {+ iptr[i * 2 + 0] = static_cast<int64_t>(i % num_rows);+ iptr[i * 2 + 1] = static_cast<int64_t>((i * 2) % num_cols);+ }+ inputs[funcInputs[2].get_node_shared_ptr()] = indices_tensor;++ const auto& default_value_type = funcInputs.size() > 3 ? funcInputs[3].get_element_type() : valuesType;+ ov::test::utils::InputGenerateData defvalData;+ defvalData.start_from = 42;+ defvalData.range = 1;+ auto default_value_tensor = ov::test::utils::create_and_fill_tensor(default_value_type, {}, defvalData);+ if (funcInputs.size() > 3)+ inputs[funcInputs[3].get_node_shared_ptr()] = default_value_tensor;+}++const SparseFillEmptyRowsLayerTest::TGenData SparseFillEmptyRowsLayerTest::GetTestDataForDevice(const char* deviceName) {+ const std::vector<std::vector<InputShape>> input_shapes = {{+ // values: [M], dense_shape: [2], indices: [M, 2]+ {{{4}, {{4}}}, {{2}, {{2}}}, {{4, 2}, {{4, 2}}}},+ {{{8}, {{8}}}, {{2}, {{2}}}, {{8, 2}, {{8, 2}}}}+ }};+ const std::vector<std::vector<float>> default_values = {{0.0f}, {42.0f}};+ const std::vector<ov::element::Type> values_types = {ov::element::f32, ov::element::f16};+ std::vector<utils::InputLayerType> in_types = {utils::InputLayerType::CONSTANT, utils::InputLayerType::PARAMETER};++ auto data = ::testing::Combine(+ ::testing::ValuesIn(input_shapes),+ ::testing::ValuesIn(default_values),+ ::testing::ValuesIn(values_types),+ ::testing::ValuesIn(in_types),+ ::testing::Values(deviceName));+ return data;+}++} // namespace test+} // namespace ovdiff --git a/src/tests/test_utils/unit_test_utils/tests_data/sparse_fill_empty_rows_data.h b/src/tests/test_utils/unit_test_utils/tests_data/sparse_fill_empty_rows_data.hnew file mode 100644index 00000000000..5a2d308017d--- /dev/null+++ b/src/tests/test_utils/unit_test_utils/tests_data/sparse_fill_empty_rows_data.h@@ -0,0 +1,454 @@+#pragma once++#define LIST(...) {__VA_ARGS__}++// TEST_DATA(indicesData,+// valuesData,+// denseShapeData,+// expectedIndicesOutput,+// expectedValuesOutput,+// expectedEmptyRowIndicatorOutput,+// testcaseName)++// Expected outputs were generated using TensorFlow++TEST_DATA(LIST(0, 1, 0, 3, 2, 2),+ LIST(1, 2, 3),+ LIST(3, 5),+ LIST(0, 1, 0, 3, 1, 0, 2, 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