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
[Op][STFT] STFT Op core class and reference implementation (#25687)
Katarzyna Mitrus034bba32cdb9
diff --git a/src/core/include/openvino/op/ops.hpp b/src/core/include/openvino/op/ops.hppindex d62395eb5bd..9ba69496324 100644--- a/src/core/include/openvino/op/ops.hpp+++ b/src/core/include/openvino/op/ops.hpp@@ -188,6 +188,7 @@#include "openvino/op/sqrt.hpp"#include "openvino/op/squared_difference.hpp"#include "openvino/op/squeeze.hpp"+#include "openvino/op/stft.hpp"#include "openvino/op/strided_slice.hpp"#include "openvino/op/string_tensor_pack.hpp"#include "openvino/op/string_tensor_unpack.hpp"diff --git a/src/core/include/openvino/op/stft.hpp b/src/core/include/openvino/op/stft.hppnew file mode 100644index 00000000000..0a8ab80e7a4--- /dev/null+++ b/src/core/include/openvino/op/stft.hpp@@ -0,0 +1,45 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "openvino/op/op.hpp"++namespace ov {+namespace op {+namespace v15 {+/// \brief An operation STFT that computes the Short Time Fourier Transform.+/// \ingroup ov_ops_cpp_api+class OPENVINO_API STFT : public Op {+public:+ OPENVINO_OP("STFT");+ STFT() = default;++ /// \brief Constructs a STFT operation.+ ///+ /// \param data Input data+ /// \param window Window to perform STFT+ /// \param frame_size Scalar value representing the size of Fourier Transform+ /// \param frame_step The distance (number of samples) between successive window frames+ /// \param transpose_frames Flag to set output shape layout. If true the `frames` dimension is at out_shape[2],+ /// otherwise it is at out_shape[1].+ STFT(const Output<Node>& data,+ const Output<Node>& window,+ const Output<Node>& frame_size,+ const Output<Node>& frame_step,+ const bool transpose_frames);++ bool visit_attributes(AttributeVisitor& visitor) override;+ void validate_and_infer_types() override;+ std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;++ bool get_transpose_frames() const;+ void set_transpose_frames(const bool transpose_frames);++private:+ bool m_transpose_frames = false;+};+} // namespace v15+} // namespace op+} // namespace ovdiff --git a/src/core/include/openvino/opsets/opset15_tbl.hpp b/src/core/include/openvino/opsets/opset15_tbl.hppindex 43f52829552..1b46724ea67 100644--- a/src/core/include/openvino/opsets/opset15_tbl.hpp+++ b/src/core/include/openvino/opsets/opset15_tbl.hpp@@ -18,6 +18,7 @@ _OPENVINO_OP_REG(ScatterNDUpdate, ov::op::v15)_OPENVINO_OP_REG(EmbeddingBagPacked, ov::op::v15)_OPENVINO_OP_REG(EmbeddingBagOffsets, ov::op::v15)_OPENVINO_OP_REG(Col2Im, ov::op::v15)+_OPENVINO_OP_REG(STFT, ov::op::v15)_OPENVINO_OP_REG(StringTensorUnpack, ov::op::v15)_OPENVINO_OP_REG(StringTensorPack, ov::op::v15)_OPENVINO_OP_REG(BitwiseLeftShift, ov::op::v15)diff --git a/src/core/reference/include/openvino/reference/stft.hpp b/src/core/reference/include/openvino/reference/stft.hppnew file mode 100644index 00000000000..172777cb99c--- /dev/null+++ b/src/core/reference/include/openvino/reference/stft.hpp@@ -0,0 +1,20 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "openvino/core/shape.hpp"++namespace ov {+namespace reference {+void stft(const float* signal,+ const float* window,+ float* rdft_result,+ const Shape& signal_shape,+ const Shape& window_shape,+ const int64_t frame_size,+ const int64_t frame_step,+ const bool transpose_frames);+} // namespace reference+} // namespace ovdiff --git a/src/core/reference/src/op/stft.cpp b/src/core/reference/src/op/stft.cppnew file mode 100644index 00000000000..d3a93db0e1e--- /dev/null+++ b/src/core/reference/src/op/stft.cpp@@ -0,0 +1,71 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/reference/stft.hpp"++#include <vector>++#include "openvino/core/shape.hpp"+#include "openvino/reference/multiply.hpp"+#include "openvino/reference/rdft.hpp"+#include "openvino/reference/transpose.hpp"++namespace ov {+namespace reference {+void stft(const float* signal,+ const float* window,+ float* rdft_result,+ const Shape& signal_shape,+ const Shape& window_shape,+ const int64_t frame_size,+ const int64_t frame_step,+ const bool transpose_frames) {+ constexpr size_t signal_axis = 1;+ const auto batch_size = signal_shape[0];+ const auto signal_length = signal_shape[signal_axis];+ const auto num_frames = static_cast<size_t>((signal_length - frame_size) / frame_step) + 1;+ const auto frame_size_dim = static_cast<size_t>(frame_size);+ const auto frame_size_dim_shape = Shape{frame_size_dim};+ const auto frame_size_dim_shape_out = Shape{frame_size_dim, 2};+ const auto fft_out_shape = Shape{static_cast<size_t>((frame_size_dim / 2) + 1), 2};++ const auto window_length = window_shape[0] < frame_size_dim ? window_shape[0] : frame_size_dim;+ std::vector<float> pad_window(frame_size, 0);+ std::copy(window, window + window_shape[0], pad_window.begin() + (frame_size_dim - window_length) / 2);++ const auto fft_out_shape_size = shape_size(fft_out_shape);+ for (size_t batch = 0, batch_in_start = 0, batch_frames_out = 0; batch < batch_size; ++batch) {+ for (size_t frame_idx = 0; frame_idx < num_frames; ++frame_idx) {+ const auto frame_start = batch_in_start + frame_idx * frame_step;+ const auto frame_end = frame_start + frame_size;+ std::vector<float> signal_slice(signal + frame_start, signal + frame_end);+ reference::multiply(signal_slice.data(),+ pad_window.data(),+ signal_slice.data(),+ frame_size_dim_shape,+ frame_size_dim_shape,+ op::AutoBroadcastType::NUMPY);+ const auto result_idx = (batch_frames_out + frame_idx) * fft_out_shape_size;+ reference::rdft(signal_slice,+ frame_size_dim_shape,+ {0},+ frame_size_dim_shape_out,+ rdft_result + result_idx);+ }+ batch_in_start += signal_length;+ batch_frames_out += num_frames;+ }+ if (transpose_frames) {+ const auto stft_transp_out_shape = Shape{batch_size, fft_out_shape[0], num_frames, fft_out_shape[1]};+ std::vector<float> signal_t(rdft_result, rdft_result + shape_size(stft_transp_out_shape));+ transpose(reinterpret_cast<const char*>(signal_t.data()),+ reinterpret_cast<char*>(rdft_result),+ Shape{batch_size, num_frames, fft_out_shape[0], fft_out_shape[1]},+ sizeof(float),+ {0, 2, 1, 3},+ stft_transp_out_shape);+ }+}+} // namespace reference+} // namespace ovdiff --git a/src/core/shape_inference/include/stft_shape_inference.hpp b/src/core/shape_inference/include/stft_shape_inference.hppnew file mode 100644index 00000000000..9605a8fa797--- /dev/null+++ b/src/core/shape_inference/include/stft_shape_inference.hpp@@ -0,0 +1,98 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "dimension_util.hpp"+#include "openvino/op/stft.hpp"+#include "utils.hpp"++namespace ov {+namespace op {+namespace v15 {+template <class TShape, class TRShape = result_shape_t<TShape>>+std::vector<TRShape> shape_infer(const STFT* op,+ const std::vector<TShape>& input_shapes,+ const ITensorAccessor& ta = make_tensor_accessor()) {+ using TDim = typename TRShape::value_type;+ NODE_VALIDATION_CHECK(op, input_shapes.size() == 4);++ const auto& signal_shape = input_shapes[0];+ const auto& window_shape = input_shapes[1];+ const auto& frame_size_shape = input_shapes[2];+ const auto& frame_step_shape = input_shapes[3];++ NODE_SHAPE_INFER_CHECK(op,+ input_shapes,+ signal_shape.rank().compatible(2),+ "The shape of signal must be 2D [batch, signal_size].");+ NODE_SHAPE_INFER_CHECK(op,+ input_shapes,+ window_shape.rank().compatible(1),+ "The shape of window must be 1D [window_size].");+ NODE_SHAPE_INFER_CHECK(op,+ input_shapes,+ frame_size_shape.rank().compatible(0),+ "The shape of frame_size must be a scalar.");+ NODE_SHAPE_INFER_CHECK(op,+ input_shapes,+ frame_step_shape.rank().compatible(0),+ "The shape of frame_step must be a scalar.");++ const auto frame_size = get_input_const_data_as<TRShape, int64_t>(op, 2, ta);+ const auto frame_step = get_input_const_data_as<TRShape, int64_t>(op, 3, ta);++ if (signal_shape.rank().is_dynamic()) {+ return {signal_shape};+ } else if (!frame_size || !frame_step) {+ return {TRShape{signal_shape[0], -1, -1, 2}};+ }++ const auto& frame_size_val = (*frame_size)[0];+ const auto& frame_step_val = (*frame_step)[0];++ NODE_SHAPE_INFER_CHECK(op,+ input_shapes,+ 0 < frame_size_val && frame_size_val < signal_shape[1].get_interval().get_max_val(),+ "Provided frame size is ",+ frame_size_val,+ " but must be in range [1, ",+ signal_shape[1],+ "].");++ NODE_SHAPE_INFER_CHECK(op,+ input_shapes,+ 0 < frame_step_val,+ "Provided frame step is ",+ frame_step_val,+ " but must be greater than zero.");++ NODE_SHAPE_INFER_CHECK(op,+ input_shapes,+ window_shape.is_dynamic() ||+ (0 < window_shape[0].get_length() && window_shape[0].get_length() <= frame_size_val),+ "Window input dimension must be in range [1, ",+ frame_size_val,+ "].");++ const auto& batch_dim = signal_shape[0];+ const TDim frame_size_dim = TDim{frame_size_val};+ const TDim signal_frame_size_diff = signal_shape[1] - frame_size_dim;+ TDim fft_samples_dim = (frame_size_val / 2) + 1;++ // Divsion opeartor for static Dimension of PartialShape can return non static dimension and ceil instead of floor+ // for lower bound, so floor_div util is used instead+ TDim frames_dim = ov::util::dim::floor_div(signal_frame_size_diff, frame_step_val) + 1;++ std::vector<TRShape> output_shapes;+ if (op->get_transpose_frames()) {+ output_shapes.emplace_back(TRShape{batch_dim, std::move(fft_samples_dim), std::move(frames_dim), 2});+ } else {+ output_shapes.emplace_back(TRShape{batch_dim, std::move(frames_dim), std::move(fft_samples_dim), 2});+ }+ return output_shapes;+}+} // namespace v15+} // namespace op+} // namespace ovdiff --git a/src/core/src/op/stft.cpp b/src/core/src/op/stft.cppnew file mode 100644index 00000000000..ee2041429d4--- /dev/null+++ b/src/core/src/op/stft.cpp@@ -0,0 +1,82 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/stft.hpp"++#include <memory>++#include "itt.hpp"+#include "openvino/reference/stft.hpp"+#include "stft_shape_inference.hpp"++namespace ov {+namespace op {+namespace v15 {+namespace {+void check_int_input_at(const Node* op, size_t input_idx) {+ const auto& in_type = op->get_input_element_type(input_idx);+ const auto has_valid_type = in_type.is_dynamic() || in_type == element::i32 || in_type == element::i64;+ NODE_VALIDATION_CHECK(op, has_valid_type, "Expected i32 or i64 type of the input at port: ", input_idx);+}+} // namespace+STFT::STFT(const Output<Node>& data,+ const Output<Node>& window,+ const Output<Node>& frame_size,+ const Output<Node>& frame_step,+ const bool transpose_frames)+ : Op({data, window, frame_size, frame_step}),+ m_transpose_frames(transpose_frames) {+ constructor_validate_and_infer_types();+}++std::shared_ptr<Node> STFT::clone_with_new_inputs(const OutputVector& new_args) const {+ OV_OP_SCOPE(v15_STFT_clone_with_new_inputs);+ check_new_args_count(this, new_args);++ return std::make_shared<STFT>(new_args.at(0), new_args.at(1), new_args.at(2), new_args.at(3), m_transpose_frames);+}++bool STFT::visit_attributes(AttributeVisitor& visitor) {+ OV_OP_SCOPE(v15_STFT_visit_attributes);+ visitor.on_attribute("transpose_frames", m_transpose_frames);+ return true;+}++void STFT::validate_and_infer_types() {+ OV_OP_SCOPE(v15_STFT_validate_and_infer_types);+ NODE_VALIDATION_CHECK(this, get_input_size() == 4, "Expected 4 inputs to be provided.");++ auto signal_type = get_input_element_type(0);+ const auto& window_type = get_input_element_type(1);++ const auto has_valid_signal_type = signal_type.is_dynamic() || signal_type.is_real();+ NODE_VALIDATION_CHECK(this, has_valid_signal_type, "Expected floating point type of the 'signal' input.");++ const auto has_valid_window_type =+ window_type.is_dynamic() ||+ (window_type.is_real() && element::Type::merge(signal_type, window_type, signal_type));+ NODE_VALIDATION_CHECK(this,+ has_valid_window_type,+ "Expected floating point type of the 'window' input, matching the type of `signal` input.");++ check_int_input_at(this, 2);+ check_int_input_at(this, 3);++ const auto input_shapes = ov::util::get_node_input_partial_shapes(*this);+ const auto output_shapes = shape_infer(this, input_shapes);++ set_output_type(0, signal_type, output_shapes[0]);+}++bool STFT::get_transpose_frames() const {+ return m_transpose_frames;+}++void STFT::set_transpose_frames(const bool transpose_frames) {+ m_transpose_frames = transpose_frames;+}++} // namespace v15+} // namespace op+} // namespace ovdiff --git a/src/core/tests/opset.cpp b/src/core/tests/opset.cppindex e848a2642ce..dfdc785421b 100644--- a/src/core/tests/opset.cpp+++ b/src/core/tests/opset.cpp@@ -75,7 +75,7 @@ INSTANTIATE_TEST_SUITE_P(opset,OpsetTestParams{ov::get_opset12, 178},OpsetTestParams{ov::get_opset13, 186},OpsetTestParams{ov::get_opset14, 188},- OpsetTestParams{ov::get_opset15, 13}),+ OpsetTestParams{ov::get_opset15, 14}),OpsetTestNameGenerator{});class MyOpOld : public ov::op::Op {diff --git a/src/core/tests/type_prop/stft.cpp b/src/core/tests/type_prop/stft.cppnew file mode 100644index 00000000000..60fe9597032--- /dev/null+++ b/src/core/tests/type_prop/stft.cpp@@ -0,0 +1,332 @@+// Copyright (C) 2018-2023 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/stft.hpp"++#include <gtest/gtest.h>++#include "common_test_utils/test_assertions.hpp"+#include "common_test_utils/type_prop.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/shape_of.hpp"+#include "openvino/op/subtract.hpp"++namespace ov {+namespace test {++using op::v0::Constant;+using op::v0::Parameter;+using testing::HasSubstr;++class TypePropSTFTTest : public TypePropOpTest<op::v15::STFT> {+public:+ bool transform_frames = true;+};++TEST_F(TypePropSTFTTest, default_ctor) {+ const auto op = make_op();+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{4, 48});+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{7});+ const auto frame_size = Constant::create<int32_t>(element::i32, {}, {11});+ const auto frame_step = Constant::create<int32_t>(element::i32, {}, {3});++ op->set_arguments(OutputVector{signal, window, frame_size, frame_step});+ op->set_transpose_frames(true);+ op->validate_and_infer_types();++ EXPECT_EQ(op->get_output_size(), 1);+ EXPECT_EQ(op->get_input_size(), 4);+ EXPECT_EQ(op->get_output_element_type(0), element::f32);+ EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{4, 6, 13, 2}));+}++TEST_F(TypePropSTFTTest, all_inputs_as_params_static_shapes) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{4, 48});+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{7});+ const auto frame_size = std::make_shared<Parameter>(element::i64, PartialShape{});+ const auto frame_step = std::make_shared<Parameter>(element::i64, PartialShape{});++ const auto op = make_op(signal, window, frame_size, frame_step, transform_frames);+ EXPECT_EQ(op->get_output_size(), 1);+ EXPECT_EQ(op->get_output_element_type(0), element::f32);+ EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{4, -1, -1, 2}));+}++TEST_F(TypePropSTFTTest, all_inputs_as_params_f16_i32_static_shapes) {+ const auto signal = std::make_shared<Parameter>(element::f16, PartialShape{4, 48});+ const auto window = std::make_shared<Parameter>(element::f16, PartialShape{7});+ const auto frame_size = std::make_shared<Parameter>(element::i32, PartialShape{});+ const auto frame_step = std::make_shared<Parameter>(element::i32, PartialShape{});++ const auto op = make_op(signal, window, frame_size, frame_step, transform_frames);+ EXPECT_EQ(op->get_output_size(), 1);+ EXPECT_EQ(op->get_output_element_type(0), element::f16);+ EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{4, -1, -1, 2}));+}++TEST_F(TypePropSTFTTest, all_inputs_as_params_dyn_shapes) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{-1, -1});+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{-1});+ const auto frame_size = std::make_shared<Parameter>(element::i64, PartialShape::dynamic());+ const auto frame_step = std::make_shared<Parameter>(element::i64, PartialShape::dynamic());++ const auto op = make_op(signal, window, frame_size, frame_step, transform_frames);+ EXPECT_EQ(op->get_output_size(), 1);+ EXPECT_EQ(op->get_output_element_type(0), element::f32);+ EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, -1, -1, 2}));+}++TEST_F(TypePropSTFTTest, all_inputs_as_params_dyn_rank) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape::dynamic());+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape::dynamic());+ const auto frame_size = std::make_shared<Parameter>(element::i64, PartialShape::dynamic());+ const auto frame_step = std::make_shared<Parameter>(element::i64, PartialShape::dynamic());++ const auto op = make_op(signal, window, frame_size, frame_step, transform_frames);+ EXPECT_EQ(op->get_output_size(), 1);+ EXPECT_EQ(op->get_output_element_type(0), element::f32);+ EXPECT_EQ(op->get_output_partial_shape(0), PartialShape::dynamic());+}++using STFTTestParam = std::tuple<PartialShape, PartialShape, int32_t, int32_t, bool, PartialShape>;+class TypePropSTFTTestP : public TypePropSTFTTest, public testing::WithParamInterface<STFTTestParam> {+protected:+ void SetUp() override {+ std::tie(signal_shape, window_shape, frame_size_val, step_size_val, transform_frames, expected_shape) =+ GetParam();+ }+ PartialShape signal_shape, window_shape, expected_shape;+ int32_t frame_size_val, step_size_val;+};++INSTANTIATE_TEST_SUITE_P(+ type_prop_stft_shape,+ TypePropSTFTTestP,+ testing::Values(+ std::make_tuple(PartialShape{1, 48}, PartialShape{16}, 16, 16, true, PartialShape{1, 9, 3, 2}),+ std::make_tuple(PartialShape{1, 48}, PartialShape{16}, 16, 16, false, PartialShape{1, 3, 9, 2}),+ std::make_tuple(PartialShape{2, 48}, PartialShape{8}, 16, 4, true, PartialShape{2, 9, 9, 2}),+ std::make_tuple(PartialShape{2, 48}, PartialShape{5}, 9, 100, true, PartialShape{2, 5, 1, 2}),+ std::make_tuple(PartialShape{4, 48}, PartialShape{7}, 11, 3, true, PartialShape{4, 6, 13, 2}),+ std::make_tuple(PartialShape{4, 48}, PartialShape{7}, 11, 3, false, PartialShape{4, 13, 6, 2}),+ std::make_tuple(PartialShape{4, 56}, PartialShape{7}, 11, 3, true, PartialShape{4, 6, 16, 2}),+ std::make_tuple(PartialShape{4, 56}, PartialShape{7}, 11, 3, false, PartialShape{4, 16, 6, 2}),+ std::make_tuple(PartialShape{-1, 56}, PartialShape{7}, 11, 3, false, PartialShape{-1, 16, 6, 2}),+ std::make_tuple(PartialShape{-1, -1}, PartialShape{7}, 11, 3, false, PartialShape{-1, {1, -1}, 6, 2}),+ std::make_tuple(PartialShape{-1, -1}, PartialShape{7}, 11, 3, true, PartialShape{-1, 6, {1, -1}, 2}),+ std::make_tuple(PartialShape{-1, {48, 56}}, PartialShape{7}, 11, 3, true, PartialShape{-1, 6, {13, 16}, 2}),+ std::make_tuple(PartialShape{{2, 4}, -1}, PartialShape{7}, 11, 3, true, PartialShape{{2, 4}, 6, {1, -1}, 2}),+ std::make_tuple(PartialShape::dynamic(), PartialShape{7}, 11, 3, true, PartialShape::dynamic()),+ std::make_tuple(PartialShape::dynamic(), PartialShape::dynamic(), 11, 3, true, PartialShape::dynamic())),+ testing::PrintToStringParamName());++TEST_P(TypePropSTFTTestP, stft_shapes) {+ const auto signal = std::make_shared<Parameter>(element::f32, signal_shape);+ const auto window = std::make_shared<Parameter>(element::f32, window_shape);+ const auto frame_size = Constant::create<int32_t>(element::i32, {}, {frame_size_val});+ const auto frame_step = Constant::create<int32_t>(element::i32, {}, {step_size_val});++ const auto op = make_op(signal, window, frame_size, frame_step, transform_frames);+ EXPECT_EQ(op->get_output_size(), 1);+ EXPECT_EQ(op->get_output_element_type(0), element::f32);+ EXPECT_EQ(op->get_output_partial_shape(0), expected_shape);+}++TEST_F(TypePropSTFTTest, signal_incompatible_shape) {+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{7});+ const auto frame_size = std::make_shared<Parameter>(element::i64, PartialShape{});+ const auto frame_step = std::make_shared<Parameter>(element::i64, PartialShape{});+ {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{48});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("The shape of signal must be 2D [batch, signal_size]"));+ }+ {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{-1, 4, 48});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("The shape of signal must be 2D [batch, signal_size]"));+ }+}++TEST_F(TypePropSTFTTest, window_incompatible_shape) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{4, 48});+ const auto frame_size = std::make_shared<Parameter>(element::i64, PartialShape{});+ const auto frame_step = std::make_shared<Parameter>(element::i64, PartialShape{});+ {+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("The shape of window must be 1D [window_size]"));+ }+ {+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{2, 8});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("The shape of window must be 1D [window_size]"));+ }+}++TEST_F(TypePropSTFTTest, frame_size_incompatible_shape) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{4, 48});+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{7});+ const auto frame_step = std::make_shared<Parameter>(element::i64, PartialShape{});+ {+ const auto frame_size = std::make_shared<Parameter>(element::i64, PartialShape{1});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("The shape of frame_size must be a scalar"));+ }+ {+ const auto frame_size = std::make_shared<Parameter>(element::i64, PartialShape{1, 2});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("The shape of frame_size must be a scalar"));+ }+}++TEST_F(TypePropSTFTTest, frame_step_incompatible_shape) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{4, 48});+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{7});+ const auto frame_size = std::make_shared<Parameter>(element::i64, PartialShape{});+ {+ const auto frame_step = std::make_shared<Parameter>(element::i64, PartialShape{1});++ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("The shape of frame_step must be a scalar"));+ }+ {+ const auto frame_step = std::make_shared<Parameter>(element::i64, PartialShape{1, 2});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("The shape of frame_step must be a scalar"));+ }+}++TEST_F(TypePropSTFTTest, signal_incompatible_type) {+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{7});+ const auto frame_size = std::make_shared<Parameter>(element::i64, PartialShape{});+ const auto frame_step = std::make_shared<Parameter>(element::i64, PartialShape{});+ {+ const auto signal = std::make_shared<Parameter>(element::i32, PartialShape{1, 48});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Expected floating point type of the 'signal' input"));+ }+ {+ const auto signal = std::make_shared<Parameter>(element::boolean, PartialShape{1, 48});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Expected floating point type of the 'signal' input"));+ }+}++TEST_F(TypePropSTFTTest, window_incompatible_type) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{4, 48});+ const auto frame_size = std::make_shared<Parameter>(element::i64, PartialShape{});+ const auto frame_step = std::make_shared<Parameter>(element::i64, PartialShape{});+ {+ const auto window = std::make_shared<Parameter>(element::i32, PartialShape{8});+ OV_EXPECT_THROW(+ std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Expected floating point type of the 'window' input, matching the type of `signal` input"));+ }+ {+ const auto window = std::make_shared<Parameter>(element::boolean, PartialShape{8});+ OV_EXPECT_THROW(+ std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Expected floating point type of the 'window' input, matching the type of `signal` input"));+ }+ {+ // Doesn't match the type of signal input+ const auto window = std::make_shared<Parameter>(element::f16, PartialShape{8});+ OV_EXPECT_THROW(+ std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Expected floating point type of the 'window' input, matching the type of `signal` input"));+ }+}++TEST_F(TypePropSTFTTest, frame_size_incompatible_type) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{4, 48});+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{7});+ const auto frame_step = std::make_shared<Parameter>(element::i64, PartialShape{});+ {+ const auto frame_size = std::make_shared<Parameter>(element::f32, PartialShape{});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Expected i32 or i64 type of the input at port: 2"));+ }+ {+ const auto frame_size = std::make_shared<Parameter>(element::i8, PartialShape{});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Expected i32 or i64 type of the input at port: 2"));+ }+}++TEST_F(TypePropSTFTTest, frame_step_incompatible_type) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{4, 48});+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{7});+ const auto frame_size = std::make_shared<Parameter>(element::i64, PartialShape{});+ {+ const auto frame_step = std::make_shared<Parameter>(element::f32, PartialShape{});++ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Expected i32 or i64 type of the input at port: 3"));+ }+ {+ const auto frame_step = std::make_shared<Parameter>(element::i8, PartialShape{});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Expected i32 or i64 type of the input at port: 3"));+ }+}++TEST_F(TypePropSTFTTest, frame_size_incompatible_value) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{4, 48});+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{7});+ const auto frame_step = Constant::create<int32_t>(element::i32, {}, {3});+ {+ const auto frame_size = Constant::create<int32_t>(element::i32, {}, {-1});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Provided frame size is -1 but must be in range [1, 48]"));+ }+ {+ const auto frame_size = Constant::create<int32_t>(element::i32, {}, {49});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Provided frame size is 49 but must be in range [1, 48]"));+ }+}++TEST_F(TypePropSTFTTest, frame_step_incompatible_value) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{4, 48});+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{7});+ const auto frame_size = Constant::create<int32_t>(element::i32, {}, {8});+ {+ const auto frame_step = Constant::create<int32_t>(element::i32, {}, {-1});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Provided frame step is -1 but must be greater than zero"));+ }+}++TEST_F(TypePropSTFTTest, window_incompatible_dim_with_frame_size) {+ const auto signal = std::make_shared<Parameter>(element::f32, PartialShape{4, 48});+ const auto window = std::make_shared<Parameter>(element::f32, PartialShape{16});+ const auto frame_size = Constant::create<int32_t>(element::i32, {}, {8});+ const auto frame_step = Constant::create<int32_t>(element::i32, {}, {4});+ OV_EXPECT_THROW(std::ignore = make_op(signal, window, frame_size, frame_step, transform_frames),+ NodeValidationFailure,+ HasSubstr("Window input dimension must be in range [1, 8]"));+}+} // namespace test+} // namespace ovdiff --git a/src/core/tests/visitors/op/stft.cpp b/src/core/tests/visitors/op/stft.cppnew file mode 100644index 00000000000..4b8fab2d127--- /dev/null+++ b/src/core/tests/visitors/op/stft.cpp@@ -0,0 +1,33 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/stft.hpp"++#include <gtest/gtest.h>++#include "openvino/op/constant.hpp"+#include "openvino/op/parameter.hpp"+#include "visitors/visitors.hpp"++namespace ov {+namespace test {+TEST(attributes, stft) {+ NodeBuilder::opset().insert<ov::op::v15::STFT>();+ const auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{2, 48});+ const auto window = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{16});+ const auto frame_size = ov::op::v0::Constant::create<int32_t>(ov::element::i32, {}, {16});+ const auto step_size = ov::op::v0::Constant::create<int32_t>(ov::element::i32, {}, {4});++ constexpr bool transpose_frames = true;+ const auto op = std::make_shared<ov::op::v15::STFT>(data, window, frame_size, step_size, transpose_frames);++ NodeBuilder builder(op, {data, window, frame_size, step_size});+ auto g_op = ov::as_type_ptr<ov::op::v15::STFT>(builder.create());++ constexpr auto expected_attr_count = 1;+ EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);+ EXPECT_EQ(op->get_transpose_frames(), g_op->get_transpose_frames());+}+} // namespace test+} // namespace ovdiff --git a/src/plugins/template/backend/ops/ops_evaluates.hpp b/src/plugins/template/backend/ops/ops_evaluates.hppindex b19b3a4fbd2..81a7976a56f 100644--- a/src/plugins/template/backend/ops/ops_evaluates.hpp+++ b/src/plugins/template/backend/ops/ops_evaluates.hpp@@ -529,6 +529,10 @@ extern template bool evaluate_node<ov::op::v15::SliceScatter>(std::shared_ptr<ovov::TensorVector& outputs,const ov::TensorVector& inputs);+extern template bool evaluate_node<ov::op::v15::STFT>(std::shared_ptr<ov::Node> node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs);+extern template bool evaluate_node<ov::op::internal::AUGRUCell>(std::shared_ptr<ov::Node> node,ov::TensorVector& outputs,const ov::TensorVector& inputs);diff --git a/src/plugins/template/backend/ops/stft.cpp b/src/plugins/template/backend/ops/stft.cppnew file mode 100644index 00000000000..a7fdf0b8131--- /dev/null+++ b/src/plugins/template/backend/ops/stft.cpp@@ -0,0 +1,58 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/reference/stft.hpp"++#include "evaluate_node.hpp"+#include "evaluates_map.hpp"+#include "openvino/reference/fft.hpp"+#include "openvino/runtime/tensor.hpp"+#include "stft_shape_inference.hpp"++template <ov::element::Type_t ET>+bool evaluate(const std::shared_ptr<ov::op::v15::STFT>& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) {+ OPENVINO_ASSERT(outputs.size() == 1);++ const auto input_shapes = ov::util::get_tensors_partial_shapes(inputs);+ const auto output_shape =+ ov::op::v15::shape_infer(op.get(), input_shapes, make_tensor_accessor(inputs)).front().to_shape();++ outputs[0].set_shape(output_shape);++ const auto frame_size = ov::get_tensor_data_as<int64_t>(inputs[2]).front();+ const auto frame_step = ov::get_tensor_data_as<int64_t>(inputs[3]).front();++ const std::vector<float> signal_f32 = get_floats(inputs[0], inputs[0].get_shape());+ const std::vector<float> window_f32 = get_floats(inputs[1], inputs[1].get_shape());+ std::vector<float> result_f32(shape_size(output_shape), 0.f);++ ov::reference::stft(signal_f32.data(),+ window_f32.data(),+ result_f32.data(),+ inputs[0].get_shape(),+ inputs[1].get_shape(),+ frame_size,+ frame_step,+ op->get_transpose_frames());++ const auto& output_type = op->get_input_element_type(0);+ ov::reference::fft_postprocessing(outputs, output_type, result_f32);+ return true;+}++template <>+bool evaluate_node<ov::op::v15::STFT>(std::shared_ptr<ov::Node> node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs) {+ switch (node->get_input_element_type(0)) {+ case ov::element::bf16:+ return evaluate<ov::element::bf16>(ov::as_type_ptr<ov::op::v15::STFT>(node), outputs, inputs);+ case ov::element::f16:+ return evaluate<ov::element::f16>(ov::as_type_ptr<ov::op::v15::STFT>(node), outputs, inputs);+ case ov::element::f32:+ return evaluate<ov::element::f32>(ov::as_type_ptr<ov::op::v15::STFT>(node), outputs, inputs);+ default:+ OPENVINO_THROW("Unhandled data type ", node->get_input_element_type(0), " in evaluate_node()");+ }+}diff --git a/src/plugins/template/backend/opset_int_tbl.hpp b/src/plugins/template/backend/opset_int_tbl.hppindex 9c06a5a767b..6e83f974005 100644--- a/src/plugins/template/backend/opset_int_tbl.hpp+++ b/src/plugins/template/backend/opset_int_tbl.hpp@@ -169,6 +169,7 @@ _OPENVINO_OP_REG(ROIAlignRotated, ov::op::v15)_OPENVINO_OP_REG(EmbeddingBagOffsets, op::v15)_OPENVINO_OP_REG(EmbeddingBagPacked, op::v15)_OPENVINO_OP_REG(Col2Im, ov::op::v15)+_OPENVINO_OP_REG(STFT, ov::op::v15)_OPENVINO_OP_REG(StringTensorUnpack, ov::op::v15)_OPENVINO_OP_REG(StringTensorPack, ov::op::v15)_OPENVINO_OP_REG(BitwiseLeftShift, ov::op::v15)diff --git a/src/plugins/template/tests/functional/op_reference/stft.cpp b/src/plugins/template/tests/functional/op_reference/stft.cppnew file mode 100644index 00000000000..4f1153b3f91--- /dev/null+++ b/src/plugins/template/tests/functional/op_reference/stft.cpp@@ -0,0 +1,387 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/stft.hpp"++#include "base_reference_test.hpp"+#include "gtest/gtest.h"+#include "openvino/op/parameter.hpp"++namespace {+using ov::Shape;+struct STFTParams {+ STFTParams(const reference_tests::Tensor& signal,+ const reference_tests::Tensor& window,+ const reference_tests::Tensor& frame_size,+ const reference_tests::Tensor& frame_step,+ bool transpose_frames,+ const reference_tests::Tensor& expected_tensor,+ std::string name)+ : signal{signal},+ window{window},+ frame_size{frame_size},+ frame_step{frame_step},+ transpose_frames(transpose_frames),+ expected_tensor(expected_tensor),+ test_case_name{std::move(name)} {}++ reference_tests::Tensor signal;+ reference_tests::Tensor window;+ reference_tests::Tensor frame_size;+ reference_tests::Tensor frame_step;+ bool transpose_frames;++ reference_tests::Tensor expected_tensor;+ std::string test_case_name;+};++class ReferenceSTFT : public testing::TestWithParam<STFTParams>, public reference_tests::CommonReferenceTest {+public:+ void SetUp() override {+ const auto& params = GetParam();+ function = CreateFunction(params);+ inputData = {params.signal.data, params.window.data, params.frame_size.data, params.frame_step.data};+ refOutData = {params.expected_tensor.data};+ }++ static std::string getTestCaseName(const testing::TestParamInfo<STFTParams>& obj) {+ std::ostringstream name;+ name << obj.param.test_case_name;+ name << "_signal_input_type_";+ name << obj.param.signal.type;+ name << "_signal_shape_";+ name << obj.param.signal.shape;+ name << "_window_input_type_";+ name << obj.param.window.type;+ name << "_window_shape_";+ name << obj.param.window.shape;+ name << "_frame_size_input_type_";+ name << obj.param.frame_size.type;+ name << "_frame_size_shape_";+ name << obj.param.frame_size.shape;+ name << "_frame_step_input_type_";+ name << obj.param.frame_step.type;+ name << "_frame_step_shape_";+ name << obj.param.frame_step.shape;+ name << "_transpose_frames_";+ name << obj.param.transpose_frames;+ return name.str();+ }++private:+ static std::shared_ptr<ov::Model> CreateFunction(const STFTParams& params) {+ const auto in_signal = std::make_shared<ov::op::v0::Parameter>(params.signal.type, params.signal.shape);+ const auto in_window = std::make_shared<ov::op::v0::Parameter>(params.window.type, params.window.shape);+ const auto in_frame_size =+ std::make_shared<ov::op::v0::Parameter>(params.frame_size.type, params.frame_size.shape);+ const auto in_frame_step =+ std::make_shared<ov::op::v0::Parameter>(params.frame_step.type, params.frame_step.shape);++ const auto STFT = std::make_shared<ov::op::v15::STFT>(in_signal,+ in_window,+ in_frame_size,+ in_frame_step,+ params.transpose_frames);+ return std::make_shared<ov::Model>(STFT->outputs(),+ ov::ParameterVector{in_signal, in_window, in_frame_size, in_frame_step});+ }+};++template <ov::element::Type_t ET, ov::element::Type_t IT = ov::element::i64>+std::vector<STFTParams> generateSTFTParams() {+ using VT = typename ov::element_type_traits<ET>::value_type;+ using INT_T = typename ov::element_type_traits<IT>::value_type;++ const ov::Shape signal_48_shape{1, 48};+ const ov::Shape signal_2_48_shape{2, 48};+ const ov::Shape signal_256_shape{1, 256};++ reference_tests::Tensor signal_48(+ signal_48_shape,+ ET,+ std::vector<VT>{-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});++ reference_tests::Tensor signal_2_48(+ signal_2_48_shape,+ ET,+ std::vector<VT>{-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, -0.82914, 0.08771, 1.00037, -0.38109, -0.37567, -0.07447,+ 0.4335, 1.27838, -0.63468, 0.5084, 0.21612, -1.85861, -0.41932, -0.13233, -0.03957,+ 0.326, -2.04032, 0.04626, -0.67768, -1.43944, 0.5243, 0.73528, -0.65325, 0.84246,+ -0.38152, 0.06649, -1.09874, 1.58449, -2.65945, -0.09145, 0.69512, -2.03347, -0.18947,+ -0.07722, 0.8247, 1.24821, -0.40389, -1.38452, 1.36724, 1.21789, -0.46201, 0.35089,+ 0.38187, 0.56628, 0.20421, 1.4067, -1.73796, 1.04082});++ reference_tests::Tensor hann_window_5(Shape{5}, ET, std::vector<VT>{0., 0.5, 1., 0.5, 0.});+ reference_tests::Tensor hann_window_7(Shape{7}, ET, std::vector<VT>{0., 0.25, 0.75, 1., 0.75, 0.25, 0.});+ reference_tests::Tensor hann_window_8(+ Shape{8},+ ET,+ std::vector<VT>{0., 0.18826, 0.61126, 0.95048, 0.95048, 0.61126, 0.18826, 0.});+ reference_tests::Tensor hann_window_10(+ Shape{10},+ ET,+ std::vector<VT>{0., 0.11698, 0.41318, 0.75, 0.96985, 0.96985, 0.75, 0.41318, 0.11698, 0.});+ reference_tests::Tensor hann_window_16(Shape{16},+ ET,+ std::vector<VT>{0.,+ 0.04323,+ 0.16543,+ 0.34549,+ 0.55226,+ 0.75,+ 0.90451,+ 0.98907,+ 0.98907,+ 0.90451,+ 0.75,+ 0.55226,+ 0.34549,+ 0.16543,+ 0.04323,+ 0.});++ reference_tests::Tensor frame_size_8(Shape{}, IT, std::vector<INT_T>{8});+ reference_tests::Tensor frame_size_9(Shape{}, IT, std::vector<INT_T>{9});+ reference_tests::Tensor frame_size_11(Shape{}, IT, std::vector<INT_T>{11});+ reference_tests::Tensor frame_size_16(Shape{}, IT, std::vector<INT_T>{16});++ reference_tests::Tensor frame_step_2(Shape{}, IT, std::vector<INT_T>{2});+ reference_tests::Tensor frame_step_3(Shape{}, IT, std::vector<INT_T>{3});+ reference_tests::Tensor frame_step_4(Shape{}, IT, std::vector<INT_T>{4});+ reference_tests::Tensor frame_step_8(Shape{}, IT, std::vector<INT_T>{8});+ reference_tests::Tensor frame_step_16(Shape{}, IT, std::vector<INT_T>{16});+ reference_tests::Tensor frame_step_100(Shape{}, IT, std::vector<INT_T>{100});++ constexpr bool transpose_frames_true = true;+ constexpr bool transpose_frames_false = false;++ reference_tests::Tensor output_1_9_9_2_transp(+ Shape{1, 9, 9, 2},+ ET,+ std::vector<VT>{-2.52411, 0., 0.37692, 0., 0.0961, 0., -1.5093, 0., -3.6289,+ 0., -3.74213, 0., -0.70616, 0., 1.11032, 0., 1.1366, 0.,+ 1.99743, 2.45799, -1.54106, 0.09127, 0.28179, -0.45332, 1.11013, -0.7782, 1.84867,+ -0.67991, 2.6774, 1.62635, -0.28718, 1.64988, -1.1681, -0.22631, 0.26235, 0.25725,+ -2.243, -1.74288, 2.37601, 2.51525, 0.61596, -1.347, -0.93254, 0.28219, 0.39666,+ 0.60667, -1.82867, -1.87092, -0.23187, 0.65901, 1.4487, 1.18742, -0.73965, -0.24622,+ 2.91255, -0.82545, -0.64918, -4.09527, -1.77914, 1.08142, 1.05098, 1.02636, 0.03844,+ 0.45931, 2.58711, 1.18649, 2.7151, -2.88547, -0.87106, -3.27669, -1.29728, -1.50822,+ -2.56084, 2.24181, -1.50375, 3.04262, -0.32836, 0.0481, -0.57373, -1.39547, -0.92956,+ -1.32518, -1.7139, 0.02014, -2.94864, 2.71058, -1.16639, 2.97336, 1.78749, 1.94867,+ 0.87525, 0.70978, 1.77224, -2.64294, 1.56859, 2.0249, -0.08561, -0.25032, 0.47508,+ 1.29318, -0.95946, -0.61456, 2.29916, -1.85519, 0.52933, -0.27895, -0.18799, 0.98232,+ 2.10241, -2.57882, -1.11208, 2.55729, -0.09293, -3.2837, -0.54924, 2.25344, 0.88504,+ -1.03814, 1.07391, -1.06812, -3.36146, 1.49043, 2.44995, 0.58978, -1.44897, -2.97866,+ -1.59965, -0.02599, 0.25367, -0.76703, 0.00445, 1.79544, 1.39855, -1.6289, -1.02171,+ 0.17824, 1.31769, 2.44158, 4.90558, -1.15294, -0.47567, -2.17385, 2.46326, 1.82815,+ -0.44417, 0., 0.4314, 0., -0.63682, 0., -1.3278, 0., 0.24368,+ 0., -2.56606, 0., -5.47521, 0., -2.60384, 0., -2.81501, 0.});++ reference_tests::Tensor output_2_9_3_2_transp(+ Shape{2, 9, 3, 2},+ ET,+ std::vector<VT>{-2.52411, 0., -3.6289, 0., 1.1366, 0., 1.99743, 2.45799, 1.84867,+ -0.67991, 0.26235, 0.25725, -2.243, -1.74288, 0.39666, 0.60667, -0.73965, -0.24622,+ 2.91255, -0.82545, 0.03844, 0.45931, -1.29728, -1.50822, -2.56084, 2.24181, -0.92956,+ -1.32518, 1.78749, 1.94867, 0.87525, 0.70978, 0.47508, 1.29318, -0.18799, 0.98232,+ 2.10241, -2.57882, 0.88504, -1.03814, -1.44897, -2.97866, -1.59965, -0.02599, -1.02171,+ 0.17824, 2.46326, 1.82815, -0.44417, 0., 0.24368, 0., -2.81501, 0.,+ 0.23009, 0., -0.69414, 0., 2.43185, 0., -0.8824, -1.32292, -0.24572,+ -0.82491, -1.45408, 0.19868, 1.82039, 1.39297, 0.23871, 1.03274, 0.813, 0.27265,+ -0.61264, -0.76088, 0.88512, 0.11954, -0.37696, -2.37281, -1.69806, -0.27959, 0.49037,+ 0.61252, -2.19384, 2.44019, 2.42024, -0.07393, -2.01537, -2.16847, 3.35813, -0.14251,+ -2.3712, 1.26736, 0.26513, 0.28205, -1.42191, -1.20478, 1.58578, -0.88636, 2.88537,+ 1.72055, 0.30074, 1.25455, -0.75431, 0., -4.31307, 0., -0.48201, 0.});++ reference_tests::Tensor output_2_3_9_2_no_transp(+ Shape{2, 3, 9, 2},+ ET,+ std::vector<VT>{+ -2.52411, 0., 1.99743, 2.45799, -2.243, -1.74288, 2.91255, -0.82545, -2.56084, 2.24181, 0.87525,+ 0.70978, 2.10241, -2.57882, -1.59965, -0.02599, -0.44417, 0., -3.6289, 0., 1.84867, -0.67991,+ 0.39666, 0.60667, 0.03844, 0.45931, -0.92956, -1.32518, 0.47508, 1.29318, 0.88504, -1.03814, -1.02171,+ 0.17824, 0.24368, 0., 1.1366, 0., 0.26235, 0.25725, -0.73965, -0.24622, -1.29728, -1.50822,+ 1.78749, 1.94867, -0.18799, 0.98232, -1.44897, -2.97866, 2.46326, 1.82815, -2.81501, 0., 0.23009,+ 0., -0.8824, -1.32292, 1.82039, 1.39297, -0.61264, -0.76088, -1.69806, -0.27959, 2.42024, -0.07393,+ -2.3712, 1.26736, 1.58578, -0.88636, -0.75431, 0., -0.69414, 0., -0.24572, -0.82491, 0.23871,+ 1.03274, 0.88512, 0.11954, 0.49037, 0.61252, -2.01537, -2.16847, 0.26513, 0.28205, 2.88537, 1.72055,+ -4.31307, 0., 2.43185, 0., -1.45408, 0.19868, 0.813, 0.27265, -0.37696, -2.37281, -2.19384,+ 2.44019, 3.35813, -0.14251, -1.42191, -1.20478, 0.30074, 1.25455, -0.48201, 0.});++ reference_tests::Tensor output_1_9_9_2_transp_win_pad(+ Shape{1, 9, 9, 2},+ ET,+ std::vector<VT>{-2.49209, 0., 1.80228, 0., 0.11167, 0., -1.10931, 0., -1.39889,+ 0., -3.05836, 0., -0.24805, 0., 1.50095, 0., 0.1782, 0.,+ 2.38232, 0.24277, -1.66564, -1.10376, -0.17477, 0.35359, 1.11949, 0.11317, 1.30896,+ 0.13583, 2.80885, 0.67694, 0.36915, -0.59295, -1.36243, -0.87174, -0.3042, -0.11877,+ -2.12336, -0.35253, 1.21787, 2.13837, 0.23782, -0.58706, -1.05259, -0.27535, -1.06786,+ -0.30642, -2.18394, -1.1024, -0.74536, 1.19633, 1.01091, 1.52014, 0.51216, 0.27057,+ 1.81552, 0.37559, -0.45972, -2.87627, -0.10082, 0.77398, 0.7832, 0.34578, 0.73575,+ 0.52785, 1.46622, 1.17898, 1.38254, -1.74123, -0.59435, -1.82269, -0.47514, -0.35034,+ -1.41677, -0.46952, -0.39908, 3.03318, -0.2069, -1.07442, -0.42578, -0.117, -0.35883,+ -0.766, -0.91042, -0.99052, -2.21948, 2.08087, 0.25057, 1.78712, 0.05369, 0.20314,+ 0.77715, 0.66349, 1.00098, -2.54308, 0.40407, 1.43908, 0.30786, -0.36902, -0.03963,+ 0.91941, 0.61261, 0.69939, 3.11192, -2.07244, -0.03943, -1.50246, 0.57377, 0.14702,+ 0.11223, -0.75968, -1.1389, 1.66717, -0.27419, -1.52765, -0.61667, 0.73554, 0.42377,+ -0.86016, -0.51775, -0.42416, -3.88305, 1.66473, -0.0569, 1.06726, -1.10813, -0.4328,+ -0.95271, 0.53067, 0.96646, -0.77057, -0.05574, 1.01868, 1.12796, -0.60164, -0.7169,+ 0.52739, 0.51569, 0.19735, 4.39323, -0.92417, 0.08818, -0.55152, 1.39751, 0.37859,+ 1.30337, 0., -0.84619, 0., 0.2294, 0., -1.37763, 0., 0.82838,+ 0., -0.52417, 0., -4.56982, 0., -0.09405, 0., -1.47752, 0.});++ reference_tests::Tensor output_1_9_5_2_transp(+ Shape{1, 9, 5, 2},+ ET,+ std::vector<VT>{-2.49209, 0., 0.11167, 0., -1.39889, 0., -0.24805, 0., 0.1782,+ 0., 2.38232, 0.24277, -0.17477, 0.35359, 1.30896, 0.13583, 0.36915, -0.59295,+ -0.3042, -0.11877, -2.12336, -0.35253, 0.23782, -0.58706, -1.06786, -0.30642, -0.74536,+ 1.19633, 0.51216, 0.27057, 1.81552, 0.37559, -0.10082, 0.77398, 0.73575, 0.52785,+ 1.38254, -1.74123, -0.47514, -0.35034, -1.41677, -0.46952, -0.2069, -1.07442, -0.35883,+ -0.766, -2.21948, 2.08087, 0.05369, 0.20314, 0.77715, 0.66349, 0.40407, 1.43908,+ -0.03963, 0.91941, 3.11192, -2.07244, 0.57377, 0.14702, 0.11223, -0.75968, -0.27419,+ -1.52765, 0.42377, -0.86016, -3.88305, 1.66473, -1.10813, -0.4328, -0.95271, 0.53067,+ -0.05574, 1.01868, -0.7169, 0.52739, 4.39323, -0.92417, 1.39751, 0.37859, 1.30337,+ 0., 0.2294, 0., 0.82838, 0., -4.56982, 0., -1.47752, 0.});++ reference_tests::Tensor output_1_9_3_2_transp(+ Shape{1, 9, 3, 2},+ ET,+ std::vector<VT>{-2.52411, 0., -3.6289, 0., 1.1366, 0., 1.99743, 2.45799, 1.84867,+ -0.67991, 0.26235, 0.25725, -2.243, -1.74288, 0.39666, 0.60667, -0.73965, -0.24622,+ 2.91255, -0.82545, 0.03844, 0.45931, -1.29728, -1.50822, -2.56084, 2.24181, -0.92956,+ -1.32518, 1.78749, 1.94867, 0.87525, 0.70978, 0.47508, 1.29318, -0.18799, 0.98232,+ 2.10241, -2.57882, 0.88504, -1.03814, -1.44897, -2.97866, -1.59965, -0.02599, -1.02171,+ 0.17824, 2.46326, 1.82815, -0.44417, 0., 0.24368, 0., -2.81501, 0.});++ reference_tests::Tensor output_1_6_13_2_transp(+ Shape{1, 6, 13, 2},+ ET,+ std::vector<VT>{+ -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});++ reference_tests::Tensor output_1_5_1_2_transp(+ Shape{1, 5, 1, 2},+ ET,+ std::vector<VT>{-1.39417, 0., 1.6707, -0.24081, -2.10633, -0.17201, 1.92729, 1.18867, -0.79458, -2.06197});++ reference_tests::Tensor output_1_13_4_2_transp(+ Shape{1, 13, 4, 2},+ ET,+ std::vector<VT>{0.37692, 0., -1.5093, 0., -3.74213, 0., 1.11032, 0., -0.97443,+ 0.37675, 1.29346, -0.61484, 3.19854, 1.21384, -1.1273, -0.1418, 2.06069, 0.5741,+ -0.96908, 0.783, -2.19122, -1.86238, 1.24662, 0.3837, -2.37601, -2.51525, 0.93254,+ -0.28219, 1.82867, 1.87092, -1.4487, -1.18742, 1.43872, 3.93066, -1.04922, -0.61175,+ -2.32056, -1.48206, 1.28249, 2.62385, 0.18916, -3.90786, 0.97448, 1.3296, 2.63709,+ 0.82637, -0.23282, -3.6278, -1.50375, 3.04262, -0.57373, -1.39547, -1.7139, 0.02014,+ -1.16639, 2.97336, 1.88374, -2.58177, 0.05181, 0.50975, -0.1459, -0.62862, 1.2734,+ -1.07889, -1.56702, 2.76644, 0.04708, 1.07766, 1.43297, 0.30029, 0.57761, -0.09787,+ 1.11208, -2.55729, 0.54924, -2.25344, -1.07391, 1.06812, -2.44995, -0.58978, -0.58628,+ 1.41096, -1.24758, 2.10349, -0.48732, -2.3458, 1.78469, 1.94472, -0.08106, -0.29824,+ 1.40955, -1.06578, 1.98965, 2.02462, 1.00713, -1.87562, 0.4314, 0., -1.3278,+ 0., -2.56606, 0., -2.60384, 0.});++ std::vector<STFTParams> params;+ params.emplace_back(signal_48,+ hann_window_16,+ frame_size_16,+ frame_step_16,+ transpose_frames_true,+ output_1_9_3_2_transp,+ "basic_batch_1_transp");+ params.emplace_back(signal_2_48,+ hann_window_16,+ frame_size_16,+ frame_step_16,+ transpose_frames_true,+ output_2_9_3_2_transp,+ "basic_batch_2_transp");+ params.emplace_back(signal_2_48,+ hann_window_16,+ frame_size_16,+ frame_step_16,+ transpose_frames_false,+ output_2_3_9_2_no_transp,+ "basic_batch_2_no_transp");+ params.emplace_back(signal_48,+ hann_window_16,+ frame_size_16,+ frame_step_4,+ transpose_frames_true,+ output_1_9_9_2_transp,+ "step_1/4_frame_transp");+ params.emplace_back(signal_48,+ hann_window_8,+ frame_size_16,+ frame_step_8,+ transpose_frames_true,+ output_1_9_5_2_transp,+ "win_size_<_frame_size_transp");+ params.emplace_back(signal_48,+ hann_window_8,+ frame_size_16,+ frame_step_4,+ transpose_frames_true,+ output_1_9_9_2_transp_win_pad,+ "step_1/4_frame_&_win_size_<_frame_size_transp");+ params.emplace_back(signal_48,+ hann_window_7,+ frame_size_11,+ frame_step_3,+ transpose_frames_true,+ output_1_6_13_2_transp,+ "odd_sizes_transp");+ params.emplace_back(signal_48,+ hann_window_5,+ frame_size_9,+ frame_step_100,+ transpose_frames_true,+ output_1_5_1_2_transp,+ "step_>_signal_size_transp");+ return params;+}++std::vector<STFTParams> generateSTFTParams() {+ std::vector<std::vector<STFTParams>> combo_params{generateSTFTParams<ov::element::f16>(),+ generateSTFTParams<ov::element::f32>()};+ std::vector<STFTParams> test_params;+ for (auto& params : combo_params)+ std::move(params.begin(), params.end(), std::back_inserter(test_params));+ return test_params;+}+} // namespace++TEST_P(ReferenceSTFT, CompareWithRefs) {+ Exec();+}++INSTANTIATE_TEST_SUITE_P(smoke,+ ReferenceSTFT,+ ::testing::ValuesIn(generateSTFTParams()),+ ReferenceSTFT::getTestCaseName);diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cppindex 713aa073d06..d80057b270c 100644--- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp+++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp@@ -1913,6 +1913,17 @@ std::shared_ptr<ov::Model> generate(const std::shared_ptr<ov::op::v15::Col2Im> &return std::make_shared<ov::Model>(results, ov::ParameterVector{data}, "Col2ImGraph");}+std::shared_ptr<ov::Model> generate(const std::shared_ptr<ov::op::v15::STFT>& node) {+ const auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{2, 48});+ const auto window = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{16});+ const auto frame_size = ov::op::v0::Constant::create<int32_t>(ov::element::i32, {}, {16});+ const auto step_size = ov::op::v0::Constant::create<int32_t>(ov::element::i32, {}, {4});+ constexpr bool transpose_frames = true;+ const auto stft = std::make_shared<ov::op::v15::STFT>(data, window, frame_size, step_size, transpose_frames);+ ov::ResultVector results{std::make_shared<ov::op::v0::Result>(stft)};+ return std::make_shared<ov::Model>(results, ov::ParameterVector{data, window}, "STFTGraph");+}+std::shared_ptr<ov::Model> generate(const std::shared_ptr<ov::op::v15::StringTensorUnpack> &node) {const auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::string, ov::PartialShape{2});const auto StringTensorUnpackNode = std::make_shared<ov::op::v15::StringTensorUnpack>(data);