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]: Added basic STFT implementation (#27794)
Piotr Kowalczyk706f340f6505
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/stft.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/stft.cppindex 91505d131d6..f3cf3280288 100644--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/stft.cpp+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/stft.cpp@@ -10,75 +10,10 @@namespace ov {namespace test {-using ov::test::STFTLayerTest;-const std::vector<ov::element::Type> data_type = {ov::element::f32, ov::element::bf16};-const std::vector<ov::element::Type> step_size_type = {ov::element::i32, ov::element::i64};--const std::vector<std::vector<InputShape>> input_shapes = {- { // Static shapes- {{}, {{128}}}, // 1st input- {{}, {{8}}}, // 2nd input- {{}, {{}}}, // 3rd input- {{}, {{}}} // 4th input- },- { // Static shapes- {{}, {{1, 128}}}, // 1st input- {{}, {{8}}}, // 2nd input- {{}, {{}}}, // 3rd input- {{}, {{}}} // 4th input- },- { // Static shapes- {{}, {{2, 226}}}, // 1st input- {{}, {{16}}}, // 2nd input- {{}, {{}}}, // 3rd input- {{}, {{}}} // 4th input- },- { // Dynamic dims in the first input shape- {{-1, -1}, {{1, 128}, {2, 226}}}, // 1st input- {{}, {{8}}}, // 2nd input- {{}, {{}}}, // 3rd input- {{}, {{}}} // 4th input- },- { // Dynamic dims in the first and second input shape- {{-1}, {{128}}}, // 1st input- {{-1}, {{8}}}, // 2nd input- {{}, {{}}}, // 3rd input- {{}, {{}}} // 4th input- },- { // Dynamic dims in the first and second input shape- {{-1, -1}, {{1, 128}, {2, 226}}}, // 1st input- {{-1}, {{8}, {16}}}, // 2nd input- {{}, {{}}}, // 3rd input- {{}, {{}}} // 4th input- },- { // Dynamic dims with range in the first and second input shape- {{{2, 4}, {1, 300}}, {{2, 226}, {3, 128}}}, // 1st input- {{{3, 16}}, {{4}, {16}}}, // 2nd input- {{}, {{}}}, // 3rd input- {{}, {{}}} // 4th input- }-};--const std::vector<int64_t> frame_size = {16, 24};-const std::vector<int64_t> step_size = {2, 3, 4};--const std::vector<bool> transpose_frames = {- false,- true,-};--std::vector<utils::InputLayerType> in_types = {utils::InputLayerType::CONSTANT, utils::InputLayerType::PARAMETER};--const auto testCaseStatic = ::testing::Combine(::testing::ValuesIn(input_shapes),- ::testing::ValuesIn(frame_size),- ::testing::ValuesIn(step_size),- ::testing::ValuesIn(transpose_frames),- ::testing::ValuesIn(data_type),- ::testing::ValuesIn(step_size_type),- ::testing::ValuesIn(in_types),- ::testing::Values(ov::test::utils::DEVICE_CPU));--INSTANTIATE_TEST_SUITE_P(smoke_STFT_static, STFTLayerTest, testCaseStatic, STFTLayerTest::getTestCaseName);+INSTANTIATE_TEST_SUITE_P(smoke_STFT_static,+ STFTLayerTest,+ STFTLayerTest::GetTestDataForDevice(ov::test::utils::DEVICE_CPU),+ STFTLayerTest::getTestCaseName);} // namespace test} // namespace ovdiff --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 e234bc68de0..c7524f18801 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@@ -273,6 +273,7 @@ REGISTER_FACTORY(v15, ROIAlignRotated);REGISTER_FACTORY(v15, BitwiseRightShift);REGISTER_FACTORY(v15, BitwiseLeftShift);REGISTER_FACTORY(v15, SearchSorted);+REGISTER_FACTORY(v15, STFT);// --------------------------- Supported internal ops --------------------------- //REGISTER_FACTORY(internal, NonMaxSuppressionIEInternal);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/stft.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/stft.hppnew file mode 100644index 00000000000..8cb1a4028df--- /dev/null+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/stft.hpp@@ -0,0 +1,62 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once+#include "primitive.hpp"++namespace cldnn {++/// @brief Short time fourier transform (STFT) operation.+/// @details Checks the specification for details.+struct STFT : public primitive_base<STFT> {+ CLDNN_DECLARE_PRIMITIVE(STFT)++ STFT() : primitive_base("", {}) {}++ /// @brief Constructs STFT primitive.+ /// @param id This primitive id.+ /// @param signal signal input.+ /// @param window window input.+ /// @param frame_size Size of the frame.+ /// @param frame_step Step between frames.+ /// @param transpose_frames Enable/Disable transpose_frames(check specification for details)..++ STFT(const primitive_id& id,+ const input_info& signal,+ const input_info& window,+ const input_info& frame_size,+ const input_info& frame_step,+ const bool transpose_frames)+ : primitive_base(id, {signal, window, frame_size, frame_step}),+ transpose_frames(transpose_frames) {}++ /// @brief Enable/Disabletranspose_frames(check specification for details).+ bool transpose_frames = false;++ size_t hash() const override {+ size_t seed = primitive::hash();+ seed = hash_combine(seed, transpose_frames);+ return seed;+ }++ bool operator==(const primitive& rhs) const override {+ if (!compare_common_params(rhs))+ return false;++ auto rhs_casted = downcast<const STFT>(rhs);++ return transpose_frames == rhs_casted.transpose_frames;+ }++ void save(BinaryOutputBuffer& ob) const override {+ primitive_base<STFT>::save(ob);+ ob << transpose_frames;+ }++ void load(BinaryInputBuffer& ib) override {+ primitive_base<STFT>::load(ib);+ ib >> transpose_frames;+ }+};+} // 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 2a38d20ac8c..29c0e3371ca 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/register.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/register.cpp@@ -88,6 +88,7 @@ void register_implementations() {REGISTER_OCL(scaled_dot_product_attention);REGISTER_OCL(rope);REGISTER_OCL(search_sorted);+ REGISTER_OCL(STFT);}} // 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 c65a23822a6..28e8956619b 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/register.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/register.hpp@@ -162,6 +162,7 @@ REGISTER_OCL(unique_gather);REGISTER_OCL(scaled_dot_product_attention);REGISTER_OCL(rope);REGISTER_OCL(search_sorted);+REGISTER_OCL(STFT);#undef REGISTER_OCLdiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/stft.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/stft.cppnew file mode 100644index 00000000000..329b442e731--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/stft.cpp@@ -0,0 +1,97 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "primitive_base.hpp"+#include "stft/stft_kernel_base.h"+#include "stft/stft_kernel_selector.h"+#include "stft_inst.h"++namespace cldnn {+namespace ocl {++struct STFT_impl : typed_primitive_impl_ocl<STFT> {+ using parent = typed_primitive_impl_ocl<STFT>;+ using parent::parent;+ using kernel_selector_t = kernel_selector::STFT_kernel_selector;+ using kernel_params_t = kernel_selector::STFT_params;++ DECLARE_OBJECT_TYPE_SERIALIZATION(cldnn::ocl::STFT_impl)++ std::unique_ptr<primitive_impl> clone() const override {+ return make_unique<STFT_impl>(*this);+ }++ void load(BinaryInputBuffer& ib) override {+ parent::load(ib);+ if (is_dynamic()) {+ auto& kernel_selector = kernel_selector_t::Instance();+ auto kernel_impl = kernel_selector.GetImplementation(_kernel_data.kernelName);+ kernel_impl->GetUpdateDispatchDataFunc(_kernel_data);+ }+ }++ 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);+ }++ static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param, bool shape_agnostic = false) {+ const auto& primitive = impl_param.typed_desc<STFT>();+ auto params = get_default_params<kernel_selector::STFT_params>(impl_param, shape_agnostic);++ // Manually add all inputs except first one, since get_default_params does not handle it.+ 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)));+ }++ params.transpose_frames = primitive->transpose_frames;+ return params;+ }++ // [NOTE]: Has to be added as a separete static function, since it is called via static dispatching in+ // typed_primitive_impl_ocl::create()..+ static kernel_impl_params static_canonicalize_shapes(const kernel_impl_params& impl_params) {+ auto updated_impl_params = canonicalize_fused_shapes(impl_params);++ for (auto& input_layout : updated_impl_params.input_layouts) {+ input_layout.set_partial_shape(extend_shape_to_rank_from_begin(input_layout.get_partial_shape()));+ }++ for (auto& output_layout : updated_impl_params.output_layouts) {+ output_layout.set_partial_shape(extend_shape_to_rank_from_begin(output_layout.get_partial_shape()));+ }++ return updated_impl_params;+ }++ kernel_impl_params canonicalize_shapes(const kernel_impl_params& impl_params) const override {+ return static_canonicalize_shapes(impl_params);+ }+};++namespace detail {++attach_STFT_impl::attach_STFT_impl() {+ auto types = {data_types::i32, data_types::i64, data_types::f16, data_types::f32};++ auto formats = {format::bfyx};++ implementation_map<STFT>::add(impl_types::ocl,+ shape_types::any,+ typed_primitive_impl_ocl<STFT>::create<STFT_impl>,+ types,+ formats);+}++} // namespace detail+} // namespace ocl+} // namespace cldnn++BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::STFT_impl)+BIND_BINARY_BUFFER_WITH_TYPE(cldnn::STFT)diff --git a/src/plugins/intel_gpu/src/graph/impls/registry/registry.hpp b/src/plugins/intel_gpu/src/graph/impls/registry/registry.hppindex b7dbbaef6e6..f45d0897f01 100644--- a/src/plugins/intel_gpu/src/graph/impls/registry/registry.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/registry/registry.hpp@@ -216,3 +216,4 @@ REGISTER_DEFAULT_IMPLS(unique_gather, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(scaled_dot_product_attention, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(rope, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(search_sorted, OCL_S, OCL_D);+REGISTER_DEFAULT_IMPLS(STFT, OCL_S, OCL_D);diff --git a/src/plugins/intel_gpu/src/graph/include/stft_inst.h b/src/plugins/intel_gpu/src/graph/include/stft_inst.hnew file mode 100644index 00000000000..1c770e93253--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/include/stft_inst.h@@ -0,0 +1,45 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#pragma once++#include <intel_gpu/primitives/stft.hpp>++#include "primitive_inst.h"++namespace cldnn {++template <>+struct typed_program_node<STFT> : public typed_program_node_base<STFT> {+ using parent = typed_program_node_base<STFT>;+ typed_program_node(const std::shared_ptr<STFT> 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 {2, 3};+ }+};++using STFT_node = typed_program_node<STFT>;++template <>+class typed_primitive_inst<STFT> : public typed_primitive_inst_base<STFT> {+ using parent = typed_primitive_inst_base<STFT>;+ using parent::parent;++public:+ typed_primitive_inst(network& network, STFT_node const& desc);+ template <typename ShapeType>+ static std::vector<layout> calc_output_layouts(STFT_node const& node, kernel_impl_params const& impl_param);+ static layout calc_output_layout(STFT_node const& node, kernel_impl_params const& impl_param);+ static std::string to_string(STFT_node const& node);+};++using STFT_inst = typed_primitive_inst<STFT>;++} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/stft.cpp b/src/plugins/intel_gpu/src/graph/stft.cppnew file mode 100644index 00000000000..33de025249a--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/stft.cpp@@ -0,0 +1,63 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#include <json_object.h>+#include <stft_inst.h>++#include <sstream>++#include "memory_accessor.hpp"+#include "openvino/core/enum_names.hpp"+#include "primitive_type_base.h"+#include "stft_shape_inference.hpp"++namespace cldnn {+GPU_DEFINE_PRIMITIVE_TYPE_ID(STFT)++STFT_inst::typed_primitive_inst(network& network, STFT_node const& node) : parent(network, node) {}++layout STFT_inst::calc_output_layout(STFT_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> STFT_inst::calc_output_layouts(STFT_node const& node, kernel_impl_params const& impl_param) {+ auto primitive = impl_param.typed_desc<STFT>();++ const auto& signal_layout = impl_param.get_input_layout(0);+ const auto& window_layout = impl_param.get_input_layout(1);+ const auto& frame_size_layout = impl_param.get_input_layout(2);+ const auto& frame_step_layout = impl_param.get_input_layout(3);++ std::vector<ShapeType> input_shapes = {+ signal_layout.get<ShapeType>(),+ window_layout.get<ShapeType>(),+ frame_size_layout.get<ShapeType>(),+ frame_step_layout.get<ShapeType>(),+ };++ const auto ta = MemoryAccessor(&impl_param.memory_deps, impl_param.get_stream());++ std::vector<ShapeType> output_shapes;+ ov::op::v15::STFT op;+ op.set_transpose_frames(primitive->transpose_frames);+ output_shapes = shape_infer(&op, input_shapes, ta);++ return {layout{output_shapes[0], signal_layout.data_type, signal_layout.format}};+}++std::string STFT_inst::to_string(STFT_node const& node) {+ auto node_info = node.desc_to_json();+ json_composite STFT_info;+ STFT_info.add("signal", node.input(0).id());+ STFT_info.add("window", node.input(1).id());+ STFT_info.add("framesize", node.input(2).id());+ STFT_info.add("framestep", node.input(3).id());+ STFT_info.add("transpose_frames", node.get_primitive()->transpose_frames);+ node_info->add("STFT info", STFT_info);+ std::stringstream primitive_description;+ node_info->dump(primitive_description);+ return primitive_description.str();+}++} // namespace cldnn\ No newline at end of filediff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/stft_ref.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/stft_ref.clnew file mode 100644index 00000000000..2f43e1e25aa--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/stft_ref.cl@@ -0,0 +1,68 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++// alternative: https://github.com/OpenCL/ComplexMath/blob/master/clcomplex.h+typedef float2 cfloat;+#define real(a) ((a).s0)+#define imag(a) ((a).s1)+#define crmult(a, b) ((cfloat)(real(a) * (b), imag(a) * (b)))+#define cadd(a, b) ((cfloat)(real(a) + real(b), imag(a) + imag(b)))+#define csub(a, b) ((cfloat)(real(a) - real(b), imag(a) - imag(b)))+#define expmi(x) ((cfloat)(cos(x), -sin(x)))+#define czero() ((cfloat)(0))++// Unoptimized, the most obvious stft impl from the definition.+KERNEL(stft_ref)(+ OPTIONAL_SHAPE_INFO_ARG+ const __global INPUT0_TYPE* restrict signal,+ const __global INPUT1_TYPE* restrict window,+ const __global INPUT2_TYPE* restrict frame_size_buff,+ const __global INPUT3_TYPE* restrict frame_step_buff,+ __global OUTPUT_TYPE* restrict output)+{+ const int freq_id = get_global_id(0);+ const int frame_id = get_global_id(1);+ const int batch = get_global_id(2);+ const int frame_size = (int)frame_size_buff[0];+ const int frame_step = (int)frame_step_buff[0];+ const int window_size = INPUT1_SIZE_X;++ // Handling case where window size is smaller than frame size.+ const int start_offset = (frame_size - window_size) / 2;++ const INPUT0_TYPE* restrict signal_for_this_frame = signal + batch*INPUT0_SIZE_X + frame_id*frame_step + start_offset;++ // FT from def for single freq for given frame:+ cfloat freq_val = czero();++ // dft_power = 2*PI*(k/N) from dft def.+ const float dft_power = 2.0f * M_PI_F * (float)freq_id / (float)frame_size;++ cfloat err = czero();+ for(int i = 0; i < window_size; ++i) {+ const float signal_val = (float)signal_for_this_frame[i];+ const float window_val = (float)window[i];+ const float x_i = signal_val*window_val;+ const cfloat e_i = expmi(dft_power*(float)(i+start_offset));+ const cfloat val_i = crmult(e_i, x_i);++ // Kahan sum algo:+ const cfloat y = csub(val_i, err);+ const cfloat newSum = cadd(freq_val, y);+ err = csub(newSum, freq_val);+ err = csub(err, y);+ freq_val = newSum;+ }++#if TRANSPOSE_FRAMES+ const int output_real_idx = OUTPUT_GET_INDEX(batch, freq_id, frame_id, 0);+ const int output_imag_idx = OUTPUT_GET_INDEX(batch, freq_id, frame_id, 1);+#else+ const int output_real_idx = OUTPUT_GET_INDEX(batch, frame_id, freq_id, 0);+ const int output_imag_idx = OUTPUT_GET_INDEX(batch, frame_id, freq_id, 1);+#endif++ output[output_real_idx] = (OUTPUT_TYPE)real(freq_val);+ output[output_imag_idx] = (OUTPUT_TYPE)imag(freq_val);+}\ No newline at end of filediff --git a/src/plugins/intel_gpu/src/kernel_selector/common_types.h b/src/plugins/intel_gpu/src/kernel_selector/common_types.hindex 06b3e04d40e..704c1151092 100644--- a/src/plugins/intel_gpu/src/kernel_selector/common_types.h+++ b/src/plugins/intel_gpu/src/kernel_selector/common_types.h@@ -102,7 +102,8 @@ enum class KernelType {SWIGLU,ROPE,DYNAMIC_QUANTIZE,- SEARCH_SORTED+ SEARCH_SORTED,+ STFT};////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_base.cppnew file mode 100644index 00000000000..8eb8ce36c14--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_base.cpp@@ -0,0 +1,90 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "stft_kernel_base.h"++#include <vector>++#include "kernel_selector_utils.h"++namespace kernel_selector {+JitConstants STFTKernelBase::GetJitConstants(const STFT_params& params) const {+ JitConstants jit = MakeBaseParamsJitConstants(params);++ jit.AddConstants({MakeJitConstant("TRANSPOSE_FRAMES", params.transpose_frames)});++ return jit;+}++void STFTKernelBase::GetUpdateDispatchDataFunc(KernelData& kd) const {+ kd.update_dispatch_data_func = [](const Params& params, KernelData& kd) {+ const auto& prim_params = static_cast<const STFT_params&>(params);+ auto dispatchData = SetDefault(prim_params);+ OPENVINO_ASSERT(kd.kernels.size() == 1, "[GPU] Invalid kernels size for update dispatch data func");+ kd.kernels[0].params.workGroups.global = dispatchData.gws;+ kd.kernels[0].params.workGroups.local = dispatchData.lws;+ kd.kernels[0].skip_execution = KernelData::SkipKernelExecution(prim_params);+ };+}++STFTKernelBase::DispatchData STFTKernelBase::SetDefault(const STFT_params& params) {+ CommonDispatchData dispatchData;+ const auto inLayout = params.inputs.front().GetLayout();+ const auto& output = params.outputs.front();+ const auto outLayout = output.GetLayout();++ OPENVINO_ASSERT(output.Dimentions() == 4);+ OPENVINO_ASSERT(output.X().v == 2);++ std::vector<std::vector<Tensor::DataChannelName>> dimsByGws;++ if (params.transpose_frames) {+ dispatchData.gws = {output.Feature().v, output.Y().v, output.Batch().v};+ dimsByGws = {{Tensor::DataChannelName::FEATURE},+ {Tensor::DataChannelName::Y},+ {Tensor::DataChannelName::BATCH}};+ } else {+ dispatchData.gws = {output.Y().v, output.Feature().v, output.Batch().v};+ dimsByGws = {{Tensor::DataChannelName::Y},+ {Tensor::DataChannelName::FEATURE},+ {Tensor::DataChannelName::BATCH}};+ }+ dispatchData.lws =+ GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, inLayout, outLayout, dimsByGws);++ return dispatchData;+}++KernelsData STFTKernelBase::GetCommonKernelsData(const Params& params) const {+ assert(params.GetType() == KernelType::STFT);++ const auto& prim_params = static_cast<const STFT_params&>(params);++ auto dispatchData = SetDefault(prim_params);+ KernelData k_data = KernelData::Default<STFT_params>(params);++ auto cldnn_jit = GetJitConstants(prim_params);+ auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, params);+ auto jit = CreateJit(kernelName, cldnn_jit, entry_point);++ GetUpdateDispatchDataFunc(k_data);++ auto& kernel = k_data.kernels[0];+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 4,+ GetFusedPrimitiveInputsCount(params),+ 1,+ prim_params.is_shape_agnostic);++ return {k_data};+}+} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_base.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_base.hnew file mode 100644index 00000000000..75ad08280e6--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_base.h@@ -0,0 +1,34 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "kernel_base_opencl.h"+#include "kernel_selector_params.h"++namespace kernel_selector {+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+// STFT+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+struct STFT_params : public base_params {+ STFT_params() : base_params(KernelType::STFT), transpose_frames(false) {}+ bool transpose_frames;+};++////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+// STFTKernelBase+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+class STFTKernelBase : public KernelBaseOpenCL {+public:+ using KernelBaseOpenCL::KernelBaseOpenCL;++ using DispatchData = CommonDispatchData;++protected:+ JitConstants GetJitConstants(const STFT_params& params) const;+ static DispatchData SetDefault(const STFT_params& params);+ KernelsData GetCommonKernelsData(const Params& params) const;+ void GetUpdateDispatchDataFunc(KernelData& kd) const override;+};+} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_ref.cppnew file mode 100644index 00000000000..dfc9a9596fe--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_ref.cpp@@ -0,0 +1,36 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "stft_kernel_ref.h"++namespace kernel_selector {+ParamsKey STFTKernelRef::GetSupportedKey() const {+ ParamsKey k;++ k.EnableInputDataType(Datatype::INT32);+ k.EnableInputDataType(Datatype::INT64);+ k.EnableInputDataType(Datatype::F32);+ k.EnableInputDataType(Datatype::F16);++ k.EnableOutputDataType(Datatype::F32);+ k.EnableOutputDataType(Datatype::F16);++ k.EnableInputLayout(DataLayout::bfyx);++ k.EnableOutputLayout(DataLayout::bfyx);++ k.EnableBatching();+ k.EnableDifferentTypes();+ k.EnableDynamicShapesSupport();+ return k;+}++KernelsData STFTKernelRef::GetKernelsData(const Params& params) const {+ return GetCommonKernelsData(params);+}++KernelsPriority STFTKernelRef::GetKernelsPriority(const Params& /*params*/) const {+ return FORCE_PRIORITY_9;+}+} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_ref.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_ref.hnew file mode 100644index 00000000000..3651539fd7d--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_ref.h@@ -0,0 +1,18 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "stft_kernel_base.h"++namespace kernel_selector {+class STFTKernelRef : public STFTKernelBase {+public:+ STFTKernelRef() : STFTKernelBase("stft_ref") {}++ KernelsData GetKernelsData(const Params& params) const override;+ KernelsPriority GetKernelsPriority(const Params& params) const override;+ ParamsKey GetSupportedKey() const override;+};+} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_selector.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_selector.cppnew file mode 100644index 00000000000..02edc108c2e--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_selector.cpp@@ -0,0 +1,17 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "stft_kernel_selector.h"++#include "stft_kernel_ref.h"++namespace kernel_selector {+STFT_kernel_selector::STFT_kernel_selector() {+ Attach<STFTKernelRef>();+}++KernelsData STFT_kernel_selector::GetBestKernels(const Params& params) const {+ return GetNaiveBestKernel(params, KernelType::STFT);+}+} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_selector.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_selector.hnew file mode 100644index 00000000000..7e1f9e714cc--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_selector.h@@ -0,0 +1,21 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "kernel_selector.h"++namespace kernel_selector {+class STFT_kernel_selector : public kernel_selector_base {+public:+ static STFT_kernel_selector& Instance() {+ static STFT_kernel_selector instance;+ return instance;+ }++ STFT_kernel_selector();++ KernelsData GetBestKernels(const Params& params) const override;+};+} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/plugin/ops/stft.cpp b/src/plugins/intel_gpu/src/plugin/ops/stft.cppnew file mode 100644index 00000000000..9b082cf7176--- /dev/null+++ b/src/plugins/intel_gpu/src/plugin/ops/stft.cpp@@ -0,0 +1,25 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/stft.hpp"++#include "intel_gpu/plugin/common_utils.hpp"+#include "intel_gpu/plugin/program_builder.hpp"+#include "intel_gpu/primitives/stft.hpp"++namespace ov {+namespace intel_gpu {++static void CreateSTFTOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v15::STFT>& op) {+ validate_inputs_count(op, {4});+ auto inputs = p.GetInputInfo(op);+ auto prim =+ cldnn::STFT(layer_type_name_ID(op), inputs[0], inputs[1], inputs[2], inputs[3], op->get_transpose_frames());+ p.add_primitive(*op, prim);+}++REGISTER_FACTORY_IMPL(v15, STFT);++} // namespace intel_gpu+} // namespace ovdiff --git a/src/plugins/intel_gpu/src/plugin/program_builder.cpp b/src/plugins/intel_gpu/src/plugin/program_builder.cppindex a9bb813d0ce..a87c5cbcbd8 100644--- a/src/plugins/intel_gpu/src/plugin/program_builder.cpp+++ b/src/plugins/intel_gpu/src/plugin/program_builder.cpp@@ -10,6 +10,7 @@#include "openvino/op/lstm_sequence.hpp"#include "openvino/op/loop.hpp"#include "openvino/op/search_sorted.hpp"+#include "openvino/op/stft.hpp"#include "ov_ops/dynamic_quantize.hpp"#include "intel_gpu/plugin/common_utils.hpp"@@ -360,7 +361,8 @@ bool ProgramBuilder::requires_new_shape_infer(const std::shared_ptr<ov::Node>& o// HACK: SearchSorted has specific shape requirements.// 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.- if (ov::is_type<ov::op::v15::SearchSorted>(op))+ // Similar case for STFT.+ if (ov::is_type<ov::op::v15::SearchSorted>(op) || ov::is_type<ov::op::v15::STFT>(op))return true;if (ov::is_type<ov::op::internal::DynamicQuantize>(op))diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/stft.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/stft.cppnew file mode 100644index 00000000000..755c0514ae4--- /dev/null+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/stft.cpp@@ -0,0 +1,17 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "single_op_tests/stft.hpp"++#include "common_test_utils/test_constants.hpp"++namespace ov {+namespace test {++INSTANTIATE_TEST_SUITE_P(smoke_STFT_static,+ STFTLayerTest,+ STFTLayerTest::GetTestDataForDevice(ov::test::utils::DEVICE_GPU),+ STFTLayerTest::getTestCaseName);+} // namespace test+} // namespace ovdiff --git a/src/plugins/intel_gpu/tests/unit/test_cases/stft_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/stft_gpu_test.cppnew file mode 100644index 00000000000..060ebfd4a07--- /dev/null+++ b/src/plugins/intel_gpu/tests/unit/test_cases/stft_gpu_test.cpp@@ -0,0 +1,208 @@+// Copyright (C) 2018-2024 Intel Corporation+// Copyright (C) 2018-2024 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/stft.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 tensoer 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;++ default:+ GTEST_FAIL() << "Unsupported data type: " << type;+ break;+ }+}++} // namespace helpers++struct STFTTestParams {+ ov::PartialShape signalShape;+ ov::PartialShape windowShape;+ ov::PartialShape outputShape;+ int64_t frameSize;+ int64_t frameStep;+ bool transposedFrames;+ std::vector<float> signalData;+ std::vector<float> windowData;+ std::vector<float> expectedOutput;+ std::string testcaseName;+};++class stft_test : public ::testing::TestWithParam<STFTTestParams> {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<STFTTestParams>& obj) {+ auto param = obj.param;+ std::ostringstream result;+ result << "signalShape=" << param.signalShape;+ result << "_windowShape=" << param.windowShape;+ result << "_outputShape=" << param.outputShape;+ result << "_frameSize=" << param.frameSize;+ result << "_frameStep=" << param.frameStep;+ result << "_transposedFrames=" << param.transposedFrames;+ result << "_" << param.testcaseName;+ return result.str();+ }++ struct STFTInferenceParams {+ bool transposedFrames;+ memory::ptr signal;+ memory::ptr window;+ memory::ptr frameSize;+ memory::ptr frameStep;+ memory::ptr expectedOutput;+ };++ template <ov::element::Type_t ET>+ STFTInferenceParams PrepareInferenceParams(const STFTTestParams& testParam) {+ using T = typename ov::element_type_traits<ET>::value_type;+ STFTInferenceParams ret;++ ret.transposedFrames = testParam.transposedFrames;++ ret.signal =+ helpers::AllocateTensor<T>(testParam.signalShape, helpers::ConverFloatVector<T>(testParam.signalData));+ ret.window =+ helpers::AllocateTensor<T>(testParam.windowShape, helpers::ConverFloatVector<T>(testParam.windowData));+ ret.expectedOutput =+ helpers::AllocateTensor<T>(testParam.outputShape, helpers::ConverFloatVector<T>(testParam.expectedOutput));++ ret.frameStep = helpers::AllocateTensor<int64_t>({}, {testParam.frameStep});+ ret.frameSize = helpers::AllocateTensor<int64_t>({}, {testParam.frameSize});++ return ret;+ }++ void Execute(const STFTInferenceParams& params) {+ // Prepare the network.+ auto stream = get_test_stream_ptr(get_test_default_config(engine_));++ auto scalar_layout = params.frameSize->get_layout();+ scalar_layout.set_partial_shape({});++ topology topology;+ topology.add(input_layout("signal", params.signal->get_layout()));+ topology.add(input_layout("window", params.window->get_layout()));+ topology.add(input_layout("frameSize", scalar_layout));+ topology.add(input_layout("frameStep", scalar_layout));+ topology.add(STFT("stft",+ input_info("signal"),+ input_info("window"),+ input_info("frameSize"),+ input_info("frameStep"),+ params.transposedFrames));++ cldnn::network::ptr network = get_network(engine_, topology, get_test_default_config(engine_), stream, false);++ network->set_input_data("signal", params.signal);+ network->set_input_data("window", params.window);+ network->set_input_data("frameSize", params.frameSize);+ network->set_input_data("frameStep", params.frameStep);++ // Run and check results.+ auto outputs = network->execute();++ auto output = outputs.at("stft").get_memory();++ helpers::CompareBuffers(output, params.expectedOutput, get_test_stream());+ }++private:+ engine& engine_ = get_test_engine();+};++std::vector<STFTTestParams> generateTestParams() {+ std::vector<STFTTestParams> params;+#define TEST_DATA(signalShape, \+ windowShape, \+ outputShape, \+ frameSize, \+ frameStep, \+ transposedFrames, \+ signalData, \+ windowData, \+ expectedOutput, \+ testcaseName) \+ params.push_back(STFTTestParams{signalShape, \+ windowShape, \+ outputShape, \+ frameSize, \+ frameStep, \+ transposedFrames, \+ signalData, \+ windowData, \+ expectedOutput, \+ testcaseName});++#include "unit_test_utils/tests_data/stft_data.h"+#undef TEST_DATA++ return params;+}++} // namespace++#define STFT_TEST_P(precision) \+ TEST_P(stft_test, ref_comp_##precision) { \+ Execute(PrepareInferenceParams<ov::element::Type_t::precision>(GetParam())); \+ }++STFT_TEST_P(f32);++INSTANTIATE_TEST_SUITE_P(stft_test_suit,+ stft_test,+ testing::ValuesIn(generateTestParams()),+ stft_test::getTestCaseName);diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hppindex 19de8ce5eb6..362258598a1 100644--- a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hpp+++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hpp@@ -240,7 +240,7 @@ static std::map<ov::NodeTypeInfo, Range> inputRanges = {{ov::op::v1::BatchToSpace::get_type_info_static(), Range({{0, 15}}, {{0, 8, 32}})},{ov::op::v15::BitwiseLeftShift::get_type_info_static(), Range({{0, 5}, {0, 4}}, {})},{ov::op::v15::BitwiseRightShift::get_type_info_static(), Range({{0, 5}, {0, 4}}, {})},- {ov::op::v15::STFT::get_type_info_static(), Range({{16, 24}, {1, 16}}, {{-100, 100}, {-100, 100}})},+ {ov::op::v15::STFT::get_type_info_static(), Range({{16, 24}, {1, 16}}, {{0, 1, 10000}, {0, 1, 10000}})},};class ModelRange {diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/stft.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/stft.hppindex 0e165ace364..22de0ef8c75 100644--- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/stft.hpp+++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/stft.hpp@@ -25,6 +25,17 @@ typedef std::tuple<std::vector<InputShape>,class STFTLayerTest : public testing::WithParamInterface<STFTParams>, virtual public ov::test::SubgraphBaseTest {public:static std::string getTestCaseName(const testing::TestParamInfo<STFTParams>& obj);+ using TGenData =+ testing::internal::CartesianProductHolder<testing::internal::ParamGenerator<std::vector<ov::test::InputShape>>,+ testing::internal::ParamGenerator<int64_t>,+ testing::internal::ParamGenerator<int64_t>,+ testing::internal::ParamGenerator<bool>,+ testing::internal::ParamGenerator<ov::element::Type>,+ 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;diff --git a/src/tests/functional/shared_test_classes/src/single_op/stft.cpp b/src/tests/functional/shared_test_classes/src/single_op/stft.cppindex 2d25b6f3860..141728b6d60 100644--- a/src/tests/functional/shared_test_classes/src/single_op/stft.cpp+++ b/src/tests/functional/shared_test_classes/src/single_op/stft.cpp@@ -84,5 +84,82 @@ void STFTLayerTest::SetUp() {function = std::make_shared<ov::Model>(STFT->outputs(), ov::ParameterVector{in_signal, in_window});}}++const STFTLayerTest::TGenData STFTLayerTest::GetTestDataForDevice(const char* deviceName) {+ const std::vector<ov::element::Type> data_type = {ov::element::bf16, ov::element::f16};+ const std::vector<ov::element::Type> step_size_type = {ov::element::i32, ov::element::i64};++ const std::vector<std::vector<InputShape>> input_shapes = {+ {+ // Static shapes+ {{}, {{128}}}, // 1st input+ {{}, {{8}}}, // 2nd input+ {{}, {{}}}, // 3rd input+ {{}, {{}}} // 4th input+ },+ {+ // Static shapes+ {{}, {{1, 128}}}, // 1st input+ {{}, {{8}}}, // 2nd input+ {{}, {{}}}, // 3rd input+ {{}, {{}}} // 4th input+ },+ {+ // Static shapes+ {{}, {{2, 226}}}, // 1st input+ {{}, {{16}}}, // 2nd input+ {{}, {{}}}, // 3rd input+ {{}, {{}}} // 4th input+ },+ {+ // Dynamic dims in the first input shape+ {{-1, -1}, {{1, 128}, {2, 226}}}, // 1st input+ {{}, {{8}}}, // 2nd input+ {{}, {{}}}, // 3rd input+ {{}, {{}}} // 4th input+ },+ {+ // Dynamic dims in the first and second input shape+ {{-1}, {{128}}}, // 1st input+ {{-1}, {{8}}}, // 2nd input+ {{}, {{}}}, // 3rd input+ {{}, {{}}} // 4th input+ },+ {+ // Dynamic dims in the first and second input shape+ {{-1, -1}, {{1, 128}, {2, 226}}}, // 1st input+ {{-1}, {{8}, {16}}}, // 2nd input+ {{}, {{}}}, // 3rd input+ {{}, {{}}} // 4th input+ },+ {+ // Dynamic dims with range in the first and second input shape+ {{{2, 4}, {1, 300}}, {{2, 226}, {3, 128}}}, // 1st input+ {{{3, 16}}, {{4}, {16}}}, // 2nd input+ {{}, {{}}}, // 3rd input+ {{}, {{}}} // 4th input+ }};++ const std::vector<int64_t> frame_size = {16, 24};+ const std::vector<int64_t> step_size = {2, 3, 4};++ const std::vector<bool> transpose_frames = {+ false,+ true,+ };++ std::vector<utils::InputLayerType> in_types = {utils::InputLayerType::CONSTANT, utils::InputLayerType::PARAMETER};++ auto data = ::testing::Combine(::testing::ValuesIn(input_shapes),+ ::testing::ValuesIn(frame_size),+ ::testing::ValuesIn(step_size),+ ::testing::ValuesIn(transpose_frames),+ ::testing::ValuesIn(data_type),+ ::testing::ValuesIn(step_size_type),+ ::testing::ValuesIn(in_types),+ ::testing::Values(deviceName));++ return data;+}} // namespace test} // namespace ovdiff --git a/src/tests/test_utils/unit_test_utils/tests_data/stft_data.h b/src/tests/test_utils/unit_test_utils/tests_data/stft_data.hnew file mode 100644index 00000000000..4a6257743f5--- /dev/null+++ b/src/tests/test_utils/unit_test_utils/tests_data/stft_data.h@@ -0,0 +1,1299 @@+#pragma once++#define LIST(...) \+ { __VA_ARGS__ }++// TEST_DATA(signalShape,+// windowShape,+// outputShape,+// frameSize,+// frameStep,+// transposedFrames,+// signalData,+// windowData,+// expectedOutput,+// testcaseName)++// NOTE: expected output were generated using pyTorch.searchsorted implementation.++TEST_DATA(LIST(48),+ LIST(16),+ LIST(9, 3, 2),+ 16,+ 16,+ true,+ LIST(0.421005,+ 0.023465,+ -0.394774,+ 0.974785,+ 0.512418,+ 0.219203,+ -0.338684,+ 1.122448,+ -0.128486,+ -0.484502,+ 0.56865,+ 1.332561,+ 0.222876,+ 0.093504,+ 0.89355,+ -0.659941,+ 1.187668,+ -2.086986,+ -0.42915,+ -0.198203,+ 1.385841,+ 0.052231,+ 0.587976,+ -0.684267,+ -0.045731,+ 0.629634,+ 1.78197,+ -1.381788,+ 0.812565,+ 0.522027,+ 0.013688,+ -0.070836,+ 1.131118,+ 0.147256,+ -0.452005,+ 0.263287,+ 0.489187,+ -0.710666,+ 0.531863,+ -0.996062,+ 0.188195,+ -0.022838,+ -0.961315,+ 0.174546,+ -2.681746,+ -0.311997,+ -0.007598,+ 0.152766),+ LIST(0.0,+ 0.03806,+ 0.146447,+ 0.308658,+ 0.5,+ 0.691342,+ 0.853553,+ 0.96194,+ 1.0,+ 0.96194,+ 0.853553,+ 0.691342,+ 0.5,+ 0.308658,+ 0.146446,+ 0.03806),+ LIST(2.500471,+ 0.0,+ 2.061596,+ 0.0,+ -2.69633,+ 0.0,+ -0.832353,+ 0.394573,+ -1.064999,+ 0.282346,+ 1.075557,+ -1.680968,+ -1.071078,+ -0.247753,+ -0.660887,+ -0.935516,+ 0.872213,+ 0.11946,+ 0.658023,+ -0.816808,+ 0.566273,+ 2.586032,+ -0.348891,+ 1.429143,+ -0.030171,+ 2.561505,+ -0.90856,+ -2.40086,+ -0.474217,+ -0.146423,+ -0.226757,+ -2.46842,+ 2.472012,+ 0.479764,+ -0.450706,+ -0.031404,+ 0.078811,+ 0.923822,+ -1.628981,+ 0.973055,+ 1.696735,+ -2.559718,+ 0.915031,+ -0.677954,+ -1.790362,+ -0.677371,+ -1.028739,+ 3.200351,+ -1.483484,+ 0.0,+ 3.969412,+ 0.0,+ 0.012426,+ 0.0),+ "test_case_0");++TEST_DATA(LIST(1, 48),+ LIST(16),+ LIST(1, 9, 3, 2),+ 16,+ 16,+ true,+ LIST(0.421005,+ 0.023465,+ -0.394774,+ 0.974785,+ 0.512418,+ 0.219203,+ -0.338684,+ 1.122448,+ -0.128486,+ -0.484502,+ 0.56865,+ 1.332561,+ 0.222876,+ 0.093504,+ 0.89355,+ -0.659941,+ 1.187668,+ -2.086986,+ -0.42915,+ -0.198203,+ 1.385841,+ 0.052231,+ 0.587976,+ -0.684267,+ -0.045731,+ 0.629634,+ 1.78197,+ -1.381788,+ 0.812565,+ 0.522027,+ 0.013688,+ -0.070836,+ 1.131118,+ 0.147256,+ -0.452005,+ 0.263287,+ 0.489187,+ -0.710666,+ 0.531863,+ -0.996062,+ 0.188195,+ -0.022838,+ -0.961315,+ 0.174546,+ -2.681746,+ -0.311997,+ -0.007598,+ 0.152766),+ LIST(0.0,+ 0.03806,+ 0.146447,+ 0.308658,+ 0.5,+ 0.691342,+ 0.853553,+ 0.96194,+ 1.0,+ 0.96194,+ 0.853553,+ 0.691342,+ 0.5,+ 0.308658,+ 0.146446,+ 0.03806),+ LIST(2.500471,+ 0.0,+ 2.061596,+ 0.0,+ -2.69633,+ 0.0,+ -0.832353,+ 0.394573,+ -1.064999,+ 0.282346,+ 1.075557,+ -1.680968,+ -1.071078,+ -0.247753,+ -0.660887,+ -0.935516,+ 0.872213,+ 0.11946,+ 0.658023,+ -0.816808,+ 0.566273,+ 2.586032,+ -0.348891,+ 1.429143,+ -0.030171,+ 2.561505,+ -0.90856,+ -2.40086,+ -0.474217,+ -0.146423,+ -0.226757,+ -2.46842,+ 2.472012,+ 0.479764,+ -0.450706,+ -0.031404,+ 0.078811,+ 0.923822,+ -1.628981,+ 0.973055,+ 1.696735,+ -2.559718,+ 0.915031,+ -0.677954,+ -1.790362,+ -0.677371,+ -1.028739,+ 3.200351,+ -1.483484,+ 0.0,+ 3.969412,+ 0.0,+ 0.012426,+ 0.0),+ "test_case_1");++TEST_DATA(LIST(1, 48),+ LIST(16),+ LIST(1, 9, 2, 2),+ 16,+ 32,+ true,+ LIST(0.421005,+ 0.023465,+ -0.394774,+ 0.974785,+ 0.512418,+ 0.219203,+ -0.338684,+ 1.122448,+ -0.128486,+ -0.484502,+ 0.56865,+ 1.332561,+ 0.222876,+ 0.093504,+ 0.89355,+ -0.659941,+ 1.187668,+ -2.086986,+ -0.42915,+ -0.198203,+ 1.385841,+ 0.052231,+ 0.587976,+ -0.684267,+ -0.045731,+ 0.629634,+ 1.78197,+ -1.381788,+ 0.812565,+ 0.522027,+ 0.013688,+ -0.070836,+ 1.131118,+ 0.147256,+ -0.452005,+ 0.263287,+ 0.489187,+ -0.710666,+ 0.531863,+ -0.996062,+ 0.188195,+ -0.022838,+ -0.961315,+ 0.174546,+ -2.681746,+ -0.311997,+ -0.007598,+ 0.152766),+ LIST(0.0,+ 0.03806,+ 0.146447,+ 0.308658,+ 0.5,+ 0.691342,+ 0.853553,+ 0.96194,+ 1.0,+ 0.96194,+ 0.853553,+ 0.691342,+ 0.5,+ 0.308658,+ 0.146446,+ 0.03806),+ LIST(2.500471,+ 0.0,+ -2.69633,+ 0.0,+ -0.832353,+ 0.394573,+ 1.075557,+ -1.680968,+ -1.071078,+ -0.247753,+ 0.872213,+ 0.11946,+ 0.658023,+ -0.816808,+ -0.348891,+ 1.429143,+ -0.030171,+ 2.561505,+ -0.474217,+ -0.146423,+ -0.226757,+ -2.46842,+ -0.450706,+ -0.031404,+ 0.078811,+ 0.923822,+ 1.696735,+ -2.559718,+ 0.915031,+ -0.677954,+ -1.028739,+ 3.200351,+ -1.483484,+ 0.0,+ 0.012426,+ 0.0),+ "test_case_2");++TEST_DATA(LIST(3, 48),+ LIST(16),+ LIST(3, 9, 2, 2),+ 16,+ 32,+ true,+ LIST(0.421005,+ 0.023465,+ -0.394774,+ 0.974785,+ 0.512418,+ 0.219203,+ -0.338684,+ 1.122448,+ -0.128486,+ -0.484502,+ 0.56865,+ 1.332561,+ 0.222876,+ 0.093504,+ 0.89355,+ -0.659941,+ 1.187668,+ -2.086986,+ -0.42915,+ -0.198203,+ 1.385841,+ 0.052231,+ 0.587976,+ -0.684267,+ -0.045731,+ 0.629634,+ 1.78197,+ -1.381788,+ 0.812565,+ 0.522027,+ 0.013688,+ -0.070836,+ 1.131118,+ 0.147256,+ -0.452005,+ 0.263287,+ 0.489187,+ -0.710666,+ 0.531863,+ -0.996062,+ 0.188195,+ -0.022838,+ -0.961315,+ 0.174546,+ -2.681746,+ -0.311997,+ -0.007598,+ 0.152766,+ -0.700153,+ 0.785022,+ 0.449904,+ -0.437027,+ 0.846442,+ -2.708081,+ -0.357738,+ 1.859077,+ -1.122008,+ 0.797016,+ -0.205318,+ 0.620443,+ -1.210487,+ -0.100233,+ -0.644188,+ 1.252426,+ -1.503346,+ 1.685813,+ -0.655548,+ 0.148169,+ 0.98681,+ -1.806409,+ -0.789457,+ 0.934387,+ 0.819341,+ -0.359637,+ -0.394646,+ -0.040578,+ 1.10817,+ 1.745871,+ -0.706232,+ 2.154361,+ -0.417549,+ 0.724758,+ -1.090765,+ 0.9193,+ 0.535271,+ -0.979016,+ 0.870831,+ -0.405604,+ -0.192899,+ 0.242223,+ -2.103053,+ -0.234349,+ -1.273937,+ -0.334684,+ -1.239732,+ 1.185672,+ 1.292743,+ 0.741054,+ -0.700485,+ -0.252933,+ -0.760226,+ 0.68806,+ 0.761746,+ 0.065581,+ -0.189028,+ 0.253604,+ 0.17645,+ 0.993091,+ 0.771911,+ -0.45738,+ -0.123291,+ -0.150833,+ -1.207279,+ -1.033516,+ -0.975503,+ 0.626698,+ 0.50241,+ -1.377113,+ -0.788385,+ 0.043618,+ -0.945737,+ 0.093409,+ -0.43187,+ 0.748239,+ 1.084854,+ 1.147015,+ 0.171417,+ -0.231462,+ -1.082049,+ 0.213656,+ -0.888956,+ 0.489294,+ -0.722142,+ 0.920915,+ -1.327819,+ -1.384117,+ -1.432893,+ -0.535934,+ 0.48227,+ 0.220006,+ -0.589304,+ -1.305996,+ -1.089244,+ 1.762965),+ LIST(0.0,+ 0.03806,+ 0.146447,+ 0.308658,+ 0.5,+ 0.691342,+ 0.853553,+ 0.96194,+ 1.0,+ 0.96194,+ 0.853553,+ 0.691342,+ 0.5,+ 0.308658,+ 0.146446,+ 0.03806),+ LIST(2.500471,+ 0.0,+ -2.69633,+ 0.0,+ -0.832353,+ 0.394573,+ 1.075557,+ -1.680968,+ -1.071078,+ -0.247753,+ 0.872213,+ 0.11946,+ 0.658023,+ -0.816808,+ -0.348891,+ 1.429143,+ -0.030171,+ 2.561505,+ -0.474217,+ -0.146423,+ -0.226757,+ -2.46842,+ -0.450706,+ -0.031404,+ 0.078811,+ 0.923822,+ 1.696735,+ -2.559718,+ 0.915031,+ -0.677954,+ -1.028739,+ 3.200351,+ -1.483484,+ 0.0,+ 0.012426,+ 0.0,+ -0.789636,+ 0.0,+ -2.698145,+ 0.0,+ -0.35829,+ 0.7881,+ 1.297723,+ -2.351696,+ 2.059313,+ -1.108987,+ 0.58228,+ 1.450589,+ -1.325991,+ -0.840667,+ -1.163221,+ -0.362671,+ -0.79498,+ 3.236621,+ 0.830829,+ 0.296243,+ 2.930576,+ -2.854989,+ 0.544256,+ 1.448767,+ -3.939284,+ -0.528339,+ -0.229411,+ -3.582516,+ 3.241738,+ 2.887635,+ 0.092836,+ 3.078159,+ -2.836527,+ 0.0,+ -1.212438,+ 0.0,+ 1.769482,+ 0.0,+ -4.335095,+ 0.0,+ -1.254114,+ 0.665334,+ 3.115947,+ 0.51333,+ -0.628684,+ 0.238478,+ -2.409475,+ -2.158762,+ 2.008016,+ -0.98037,+ 2.824623,+ 2.211092,+ -0.863346,+ 0.059172,+ -1.077194,+ -0.687371,+ -0.326849,+ 1.138742,+ -0.569806,+ 0.200439,+ 0.238943,+ -0.929741,+ 0.855134,+ 0.989918,+ 0.329058,+ -0.27983,+ 0.360809,+ -1.762999,+ -0.775532,+ 0.0,+ -1.864981,+ 0.0),+ "test_case_3");++TEST_DATA(LIST(3, 48),+ LIST(16),+ LIST(3, 2, 9, 2),+ 16,+ 32,+ false,+ LIST(0.421005,+ 0.023465,+ -0.394774,+ 0.974785,+ 0.512418,+ 0.219203,+ -0.338684,+ 1.122448,+ -0.128486,+ -0.484502,+ 0.56865,+ 1.332561,+ 0.222876,+ 0.093504,+ 0.89355,+ -0.659941,+ 1.187668,+ -2.086986,+ -0.42915,+ -0.198203,+ 1.385841,+ 0.052231,+ 0.587976,+ -0.684267,+ -0.045731,+ 0.629634,+ 1.78197,+ -1.381788,+ 0.812565,+ 0.522027,+ 0.013688,+ -0.070836,+ 1.131118,+ 0.147256,+ -0.452005,+ 0.263287,+ 0.489187,+ -0.710666,+ 0.531863,+ -0.996062,+ 0.188195,+ -0.022838,+ -0.961315,+ 0.174546,+ -2.681746,+ -0.311997,+ -0.007598,+ 0.152766,+ -0.700153,+ 0.785022,+ 0.449904,+ -0.437027,+ 0.846442,+ -2.708081,+ -0.357738,+ 1.859077,+ -1.122008,+ 0.797016,+ -0.205318,+ 0.620443,+ -1.210487,+ -0.100233,+ -0.644188,+ 1.252426,+ -1.503346,+ 1.685813,+ -0.655548,+ 0.148169,+ 0.98681,+ -1.806409,+ -0.789457,+ 0.934387,+ 0.819341,+ -0.359637,+ -0.394646,+ -0.040578,+ 1.10817,+ 1.745871,+ -0.706232,+ 2.154361,+ -0.417549,+ 0.724758,+ -1.090765,+ 0.9193,+ 0.535271,+ -0.979016,+ 0.870831,+ -0.405604,+ -0.192899,+ 0.242223,+ -2.103053,+ -0.234349,+ -1.273937,+ -0.334684,+ -1.239732,+ 1.185672,+ 1.292743,+ 0.741054,+ -0.700485,+ -0.252933,+ -0.760226,+ 0.68806,+ 0.761746,+ 0.065581,+ -0.189028,+ 0.253604,+ 0.17645,+ 0.993091,+ 0.771911,+ -0.45738,+ -0.123291,+ -0.150833,+ -1.207279,+ -1.033516,+ -0.975503,+ 0.626698,+ 0.50241,+ -1.377113,+ -0.788385,+ 0.043618,+ -0.945737,+ 0.093409,+ -0.43187,+ 0.748239,+ 1.084854,+ 1.147015,+ 0.171417,+ -0.231462,+ -1.082049,+ 0.213656,+ -0.888956,+ 0.489294,+ -0.722142,+ 0.920915,+ -1.327819,+ -1.384117,+ -1.432893,+ -0.535934,+ 0.48227,+ 0.220006,+ -0.589304,+ -1.305996,+ -1.089244,+ 1.762965),+ LIST(0.0,+ 0.03806,+ 0.146447,+ 0.308658,+ 0.5,+ 0.691342,+ 0.853553,+ 0.96194,+ 1.0,+ 0.96194,+ 0.853553,+ 0.691342,+ 0.5,+ 0.308658,+ 0.146446,+ 0.03806),+ LIST(2.500471,+ 0.0,+ -0.832353,+ 0.394573,+ -1.071078,+ -0.247753,+ 0.658023,+ -0.816808,+ -0.030171,+ 2.561505,+ -0.226757,+ -2.46842,+ 0.078811,+ 0.923822,+ 0.915031,+ -0.677954,+ -1.483484,+ 0.0,+ -2.69633,+ 0.0,+ 1.075557,+ -1.680968,+ 0.872213,+ 0.11946,+ -0.348891,+ 1.429143,+ -0.474217,+ -0.146423,+ -0.450706,+ -0.031404,+ 1.696735,+ -2.559718,+ -1.028739,+ 3.200351,+ 0.012426,+ 0.0,+ -0.789636,+ 0.0,+ -0.35829,+ 0.7881,+ 2.059313,+ -1.108987,+ -1.325991,+ -0.840667,+ -0.79498,+ 3.236621,+ 2.930576,+ -2.854989,+ -3.939284,+ -0.528339,+ 3.241738,+ 2.887635,+ -2.836527,+ 0.0,+ -2.698145,+ 0.0,+ 1.297723,+ -2.351696,+ 0.58228,+ 1.450589,+ -1.163221,+ -0.362671,+ 0.830829,+ 0.296243,+ 0.544256,+ 1.448767,+ -0.229411,+ -3.582516,+ 0.092836,+ 3.078159,+ -1.212438,+ 0.0,+ 1.769482,+ 0.0,+ -1.254114,+ 0.665334,+ -0.628684,+ 0.238478,+ 2.008016,+ -0.98037,+ -0.863346,+ 0.059172,+ -0.326849,+ 1.138742,+ 0.238943,+ -0.929741,+ 0.329058,+ -0.27983,+ -0.775532,+ 0.0,+ -4.335095,+ 0.0,+ 3.115947,+ 0.51333,+ -2.409475,+ -2.158762,+ 2.824623,+ 2.211092,+ -1.077194,+ -0.687371,+ -0.569806,+ 0.200439,+ 0.855134,+ 0.989918,+ 0.360809,+ -1.762999,+ -1.864981,+ 0.0),+ "test_case_4");++TEST_DATA(LIST(1, 48),+ LIST(33),+ LIST(1, 2, 17, 2),+ 33,+ 11,+ false,+ LIST(0.421005,+ 0.023465,+ -0.394774,+ 0.974785,+ 0.512418,+ 0.219203,+ -0.338684,+ 1.122448,+ -0.128486,+ -0.484502,+ 0.56865,+ 1.332561,+ 0.222876,+ 0.093504,+ 0.89355,+ -0.659941,+ 1.187668,+ -2.086986,+ -0.42915,+ -0.198203,+ 1.385841,+ 0.052231,+ 0.587976,+ -0.684267,+ -0.045731,+ 0.629634,+ 1.78197,+ -1.381788,+ 0.812565,+ 0.522027,+ 0.013688,+ -0.070836,+ 1.131118,+ 0.147256,+ -0.452005,+ 0.263287,+ 0.489187,+ -0.710666,+ 0.531863,+ -0.996062,+ 0.188195,+ -0.022838,+ -0.961315,+ 0.174546,+ -2.681746,+ -0.311997,+ -0.007598,+ 0.152766),+ LIST(0.0,+ 0.009036,+ 0.035816,+ 0.079373,+ 0.138133,+ 0.209972,+ 0.292293,+ 0.382121,+ 0.476209,+ 0.571157,+ 0.663534,+ 0.75,+ 0.82743,+ 0.893027,+ 0.944418,+ 0.979746,+ 0.997736,+ 0.997736,+ 0.979746,+ 0.944418,+ 0.893027,+ 0.82743,+ 0.75,+ 0.663534,+ 0.571157,+ 0.476209,+ 0.382121,+ 0.292292,+ 0.209971,+ 0.138133,+ 0.079373,+ 0.035816,+ 0.009036),+ LIST(2.579306,+ 0.0,+ -0.152245,+ -0.738268,+ -2.416611,+ 1.261868,+ 2.867594,+ -1.060565,+ -3.284244,+ 0.170454,+ 2.868702,+ -0.841069,+ -1.104891,+ 3.300689,+ -1.140553,+ -4.425755,+ 0.251539,+ 2.542669,+ 1.792233,+ -0.387007,+ 1.135473,+ 1.006229,+ -3.639657,+ -1.375989,+ 1.341596,+ 1.403905,+ -0.208277,+ -2.707592,+ 0.588243,+ 3.234172,+ 1.73603,+ -4.193725,+ -1.924587,+ 6.196737,+ 3.055838,+ 0.0,+ -2.899791,+ 0.050701,+ 1.185766,+ 0.087218,+ 0.653565,+ 0.058316,+ 0.340882,+ -0.196132,+ -0.708827,+ -1.955343,+ -1.790521,+ 2.863453,+ 2.38143,+ -0.021196,+ -1.090831,+ -2.4223,+ 2.221659,+ 2.73066,+ -4.076646,+ -3.259353,+ 3.247396,+ 2.531169,+ -1.041836,+ -0.880713,+ 0.399545,+ 2.26406,+ -0.611558,+ -1.956384,+ 1.462047,+ 1.335275,+ -1.2002,+ -5.702536),+ "test_case_5");++TEST_DATA(LIST(48),+ LIST(7),+ LIST(6, 13, 2),+ 11,+ 3,+ true,+ LIST(-0.41676,+ -0.05627,+ -2.1362,+ 1.64027,+ -1.79344,+ -0.84175,+ 0.50288,+ -1.24529,+ -1.05795,+ -0.90901,+ 0.55145,+ 2.29221,+ 0.04154,+ -1.11793,+ 0.53906,+ -0.59616,+ -0.01913,+ 1.175,+ -0.74787,+ 0.00903,+ -0.87811,+ -0.15643,+ 0.25657,+ -0.98878,+ -0.33882,+ -0.23618,+ -0.63766,+ -1.18761,+ -1.42122,+ -0.1535,+ -0.26906,+ 2.23137,+ -2.43477,+ 0.11273,+ 0.37044,+ 1.35963,+ 0.50186,+ -0.84421,+ 0.00001,+ 0.54235,+ -0.31351,+ 0.77101,+ -1.86809,+ 1.73118,+ 1.46768,+ -0.33568,+ 0.61134,+ 0.04797),+ LIST(0.0, 0.25, 0.75, 1.0, 0.75, 0.25, 0.0),+ LIST(-1.71092,+ 0.,+ -2.41009,+ 0.,+ 2.23022,+ 0.,+ -0.7409,+ 0.,+ 0.45297,+ 0.,+ -1.11149,+ 0.,+ -1.14862,+ 0.,+ -2.14551,+ 0.,+ -1.16026,+ 0.,+ -0.65135,+ 0.,+ 1.83099,+ 0.,+ -0.1793,+ 0.,+ -0.2968,+ 0.,+ 1.47212,+ 0.71877,+ 2.17268,+ 0.79158,+ -2.28473,+ -0.93586,+ 0.4625,+ 0.34192,+ -0.56009,+ -0.32899,+ 0.93528,+ 0.44276,+ 1.11077,+ 0.05564,+ 1.82719,+ -0.1221,+ 0.71587,+ 1.50743,+ 1.10802,+ -0.41842,+ -1.71345,+ -0.67438,+ 0.05781,+ 0.40969,+ 0.4558,+ -0.24137,+ -0.54856,+ -1.56669,+ -1.47087,+ -1.22889,+ 2.1535,+ 1.84441,+ 0.18738,+ -0.28908,+ 0.66134,+ 0.88008,+ -0.66811,+ -0.52077,+ -1.02705,+ -0.15929,+ -1.12869,+ 0.2893,+ 0.0583,+ -1.66476,+ -2.16394,+ 0.18383,+ 1.42389,+ 1.02343,+ 0.32308,+ -0.7337,+ -0.68826,+ 0.55139,+ -0.91886,+ 1.85309,+ 0.52177,+ 0.97814,+ -1.50306,+ -2.29021,+ -0.76526,+ -0.28515,+ -0.47423,+ -1.4385,+ 0.63386,+ 0.43591,+ 0.90989,+ 0.38369,+ 0.51776,+ -0.36462,+ -0.31809,+ 0.57129,+ 2.99689,+ 0.98808,+ -1.06897,+ -0.98176,+ -0.81284,+ 0.72147,+ 0.63521,+ -1.1571,+ 1.74128,+ -1.03922,+ 0.14692,+ -0.1082,+ 0.64531,+ 1.98433,+ 0.856,+ 1.12631,+ 0.14133,+ 1.66429,+ -0.63884,+ -0.57479,+ -0.6772,+ -0.71798,+ -0.19529,+ 0.22579,+ 0.09013,+ 0.66192,+ -2.7275,+ -2.70068,+ 0.6808,+ 0.74142,+ 0.95724,+ -0.28153,+ -0.33733,+ 2.09067,+ -0.89051,+ -0.04374,+ -0.16546,+ -0.69762,+ -0.12612,+ -1.43585,+ -0.37017,+ -1.74231,+ 0.00518,+ -1.6207,+ 0.29356,+ 0.84215,+ 0.2579,+ 0.98549,+ 0.05179,+ -0.0244,+ 0.03393,+ -1.30044,+ 1.1122,+ 3.98255,+ -0.23778,+ -0.54982,+ -0.43563,+ -0.19685,+ 0.08299,+ -2.86001),+ "test_case_6");\ No newline at end of file