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
// Copyright (C) 2018-2026 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <vector>
// clang-format off
#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
#endif
#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
#endif
// clang-format on
#include "common_test_utils/file_utils.hpp"
#include "common_test_utils/test_case.hpp"
#include "common_test_utils/test_control.hpp"
#include "common_test_utils/test_tools.hpp"
#include "onnx_utils.hpp"
using namespace ov;
using namespace ov::frontend::onnx::tests;
static std::string s_manifest = onnx_backend_manifest("${MANIFEST}");
static std::string s_device = backend_name_to_device("${BACKEND_NAME}");
namespace {
const std::vector<float> stft_window_16{1.0f,
0.96194196f,
0.8535616f,
0.6913578f,
0.5000232f,
0.308685f,
0.1464712f,
0.038075745f,
0.0f,
0.03804031f,
0.1464057f,
0.3085994f,
0.49993038f,
0.6912722f,
0.853496f,
0.96190655f};
} // namespace
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft) {
auto model = convert_model("dft.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(Shape{3, 5, 2}, {0.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f, 3.0f, 0.0f, 4.0f, 0.0f,
5.0f, 0.0f, 6.0f, 0.0f, 7.0f, 0.0f, 8.0f, 0.0f, 9.0f, 0.0f,
10.0f, 0.0f, 11.0f, 0.0f, 12.0f, 0.0f, 13.0f, 0.0f, 14.0f, 0.0f});
test_case.add_expected_output<float>(
Shape{3, 5, 2},
{10.0f, 0.0f, -2.5f, 3.440955f, -2.5f, 0.812299f, -2.5f, -0.812299f, -2.5f, -3.440955f,
35.0f, 0.0f, -2.5f, 3.440955f, -2.5f, 0.812299f, -2.5f, -0.812299f, -2.5f, -3.440955f,
60.0f, 0.0f, -2.5f, 3.440955f, -2.5f, 0.812299f, -2.5f, -0.812299f, -2.5f, -3.440955f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_only_real) {
auto model = convert_model("dft_only_real.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(
Shape{3, 5, 1},
{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f});
test_case.add_expected_output<float>(
Shape{3, 5, 2},
{10.0f, 0.0f, -2.5f, 3.440955f, -2.5f, 0.812299f, -2.5f, -0.812299f, -2.5f, -3.440955f,
35.0f, 0.0f, -2.5f, 3.440955f, -2.5f, 0.812299f, -2.5f, -0.812299f, -2.5f, -3.440955f,
60.0f, 0.0f, -2.5f, 3.440955f, -2.5f, 0.812299f, -2.5f, -0.812299f, -2.5f, -3.440955f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_onesided) {
auto model = convert_model("dft_onesided.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(Shape{2, 4}, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f});
test_case.add_expected_output<float>(Shape{2, 3, 2},
{6.0f, 0.0f, -2.0f, 2.0f, -2.0f, 0.0f, 22.0f, 0.0f, -2.0f, 2.0f, -2.0f, 0.0f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_onesided_skip_convert_to_complex) {
auto model = convert_model("dft_onesided_skip_convert_to_complex.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(Shape{2, 4, 1}, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f});
test_case.add_expected_output<float>(Shape{2, 3, 1, 2},
{6.0f, 0.0f, -2.0f, 2.0f, -2.0f, 0.0f, 22.0f, 0.0f, -2.0f, 2.0f, -2.0f, 0.0f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_length_provided) {
auto model = convert_model("dft_length_provided.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(Shape{3, 5, 2}, {0.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f, 3.0f, 0.0f, 4.0f, 0.0f,
5.0f, 0.0f, 6.0f, 0.0f, 7.0f, 0.0f, 8.0f, 0.0f, 9.0f, 0.0f,
10.0f, 0.0f, 11.0f, 0.0f, 12.0f, 0.0f, 13.0f, 0.0f, 14.0f, 0.0f});
test_case.add_expected_output<float>(Shape{1, 5, 2}, {0.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f, 3.0f, 0.0f, 4.0f, 0.0f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_scalar_length_provided) {
auto model = convert_model("dft_scalar_length_provided.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(Shape{3, 5, 2}, {0.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f, 3.0f, 0.0f, 4.0f, 0.0f,
5.0f, 0.0f, 6.0f, 0.0f, 7.0f, 0.0f, 8.0f, 0.0f, 9.0f, 0.0f,
10.0f, 0.0f, 11.0f, 0.0f, 12.0f, 0.0f, 13.0f, 0.0f, 14.0f, 0.0f});
test_case.add_expected_output<float>(Shape{1, 5, 2}, {0.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f, 3.0f, 0.0f, 4.0f, 0.0f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_length_provided_onesided) {
auto model = convert_model("dft_length_provided_onesided.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(Shape{4, 3}, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f});
test_case.add_expected_output<float>(Shape{1, 3, 2}, {0.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_inverse) {
auto model = convert_model("dft_inverse.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(Shape{3, 5, 2}, {0.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f, 3.0f, 0.0f, 4.0f, 0.0f,
5.0f, 0.0f, 6.0f, 0.0f, 7.0f, 0.0f, 8.0f, 0.0f, 9.0f, 0.0f,
10.0f, 0.0f, 11.0f, 0.0f, 12.0f, 0.0f, 13.0f, 0.0f, 14.0f, 0.0f});
test_case.add_expected_output<float>(
Shape{3, 5, 2},
{2.0f, 0.0f, -0.5f, -0.688191f, -0.5f, -0.16246f, -0.5f, 0.16246f, -0.5f, 0.688191f,
7.0f, 0.0f, -0.5f, -0.688191f, -0.5f, -0.16246f, -0.5f, 0.16246f, -0.5f, 0.688191f,
12.0f, 0.0f, -0.5f, -0.688191f, -0.5f, -0.16246f, -0.5f, 0.16246f, -0.5f, 0.688191f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_inverse_only_real) {
auto model = convert_model("dft_inverse_only_real.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(
Shape{3, 5, 1},
{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f});
test_case.add_expected_output<float>(
Shape{3, 5, 2},
{2.0f, 0.0f, -0.5f, -0.688191f, -0.5f, -0.16246f, -0.5f, 0.16246f, -0.5f, 0.688191f,
7.0f, 0.0f, -0.5f, -0.688191f, -0.5f, -0.16246f, -0.5f, 0.16246f, -0.5f, 0.688191f,
12.0f, 0.0f, -0.5f, -0.688191f, -0.5f, -0.16246f, -0.5f, 0.16246f, -0.5f, 0.688191f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_inverse_onesided) {
auto model = convert_model("dft_inverse_onesided.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(Shape{2, 3, 2},
{6.0f, 0.0f, -2.0f, 2.0f, -2.0f, 0.0f, 22.0f, 0.0f, -2.0f, 2.0f, -2.0f, 0.0f});
test_case.add_expected_output<float>(Shape{2, 4}, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_inverse_onesided_real_input) {
auto model = convert_model("dft_inverse_onesided_real_input.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(Shape{2, 3, 1}, {1.0f, 0.0f, -1.0f, 0.5f, -0.5f, 0.0f});
test_case.add_expected_output<float>(Shape{2, 3, 1}, {0.75f, -0.25f, -0.5f, 0.25f, 0.25f, -0.5f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_inverse_length_provided) {
auto model = convert_model("dft_inverse_length_provided.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(Shape{3, 5, 2}, {0.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f, 3.0f, 0.0f, 4.0f, 0.0f,
5.0f, 0.0f, 6.0f, 0.0f, 7.0f, 0.0f, 8.0f, 0.0f, 9.0f, 0.0f,
10.0f, 0.0f, 11.0f, 0.0f, 12.0f, 0.0f, 13.0f, 0.0f, 14.0f, 0.0f});
test_case.add_expected_output<float>(Shape{1, 5, 2}, {0.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f, 3.0f, 0.0f, 4.0f, 0.0f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dft_inverse_length_provided_onesided) {
auto model = convert_model("dft_inverse_length_provided_onesided.onnx");
auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>(Shape{1, 3, 2}, {0.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f});
test_case.add_expected_output<float>(Shape{4, 3},
{0.0f, 0.25f, 0.5f, 0.0f, 0.25f, 0.5f, 0.0f, 0.25f, 0.5f, 0.0f, 0.25f, 0.5f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_onesided_real_input_no_window_default_length) {
auto model = convert_model("stft_onesided_real_input_no_window_default_length.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{1, 128, 1};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_expected_output<float>(
Shape{1, 1, 65, 2},
{8128.0f, 0.0f, -64.0f, 2607.071f, -64.0f, 1302.7499f, -64.0f, 867.62683f, -64.0f, 649.8029f,
-64.0f, 518.8983f, -64.0f, 431.45294f, -64.0f, 368.8411f, -64.0f, 321.74973f, -64.0f, 285.00494f,
-64.0f, 255.50232f, -64.0f, 231.26628f, -64.0f, 210.97972f, -64.0f, 193.73076f, -64.0f, 178.86801f,
-64.0f, 165.91376f, -64.0f, 154.50967f, -64.0f, 144.38168f, -64.0f, 135.31664f, -64.0f, 127.146164f,
-64.0f, 119.73558f, -64.0f, 112.9758f, -64.0f, 106.77755f, -64.0f, 101.06705f, -64.0f, 95.78277f,
-64.0f, 90.87302f, -64.0f, 86.294014f, -64.0f, 82.00842f, -64.0f, 77.98422f, -64.0f, 74.19379f,
-64.0f, 70.61312f, -64.0f, 67.221306f, -64.0f, 64.0f, -64.0f, 60.933064f, -64.0f, 58.006218f,
-64.0f, 55.20678f, -64.0f, 52.52344f, -64.0f, 49.94609f, -64.0f, 47.465633f, -64.0f, 45.073887f,
-64.0f, 42.76343f, -64.0f, 40.527554f, -64.0f, 38.360123f, -64.0f, 36.25555f, -64.0f, 34.208714f,
-64.0f, 32.214893f, -64.0f, 30.269745f, -64.0f, 28.36925f, -64.0f, 26.509668f, -64.0f, 24.687525f,
-64.0f, 22.899567f, -64.0f, 21.142744f, -64.0f, 19.414188f, -64.0f, 17.711185f, -64.0f, 16.031166f,
-64.0f, 14.37168f, -64.0f, 12.7303915f, -64.0f, 11.105054f, -64.0f, 9.493504f, -64.0f, 7.893647f,
-64.0f, 6.3034496f, -64.0f, 4.7209234f, -64.0f, 3.1441183f, -64.0f, 1.5711118f, -64.0f, 0.0f});
test_case.run_with_tolerance_as_fp(2e-2f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_no_onesided_real_input_no_window_default_length) {
auto model = convert_model("stft_no_onesided_real_input_no_window_default_length.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{1, 128, 1};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_expected_output<float>(
Shape{1, 1, 128, 2},
{8128.0f, 0.0f, -64.0f, 2607.071f, -64.0f, 1302.7499f, -64.0f, 867.62683f, -64.0f, 649.8029f,
-64.0f, 518.8983f, -64.0f, 431.45294f, -64.0f, 368.8411f, -64.0f, 321.74973f, -64.0f, 285.00494f,
-64.0f, 255.50232f, -64.0f, 231.26628f, -64.0f, 210.97972f, -64.0f, 193.73076f, -64.0f, 178.86801f,
-64.0f, 165.91376f, -64.0f, 154.50967f, -64.0f, 144.38168f, -64.0f, 135.31664f, -64.0f, 127.146164f,
-64.0f, 119.73558f, -64.0f, 112.9758f, -64.0f, 106.77755f, -64.0f, 101.06705f, -64.0f, 95.78277f,
-64.0f, 90.87302f, -64.0f, 86.294014f, -64.0f, 82.00842f, -64.0f, 77.98422f, -64.0f, 74.19379f,
-64.0f, 70.61312f, -64.0f, 67.221306f, -64.0f, 64.0f, -64.0f, 60.933064f, -64.0f, 58.006218f,
-64.0f, 55.20678f, -64.0f, 52.52344f, -64.0f, 49.94609f, -64.0f, 47.465633f, -64.0f, 45.073887f,
-64.0f, 42.76343f, -64.0f, 40.527554f, -64.0f, 38.360123f, -64.0f, 36.25555f, -64.0f, 34.208714f,
-64.0f, 32.214893f, -64.0f, 30.269745f, -64.0f, 28.36925f, -64.0f, 26.509668f, -64.0f, 24.687525f,
-64.0f, 22.899567f, -64.0f, 21.142744f, -64.0f, 19.414188f, -64.0f, 17.711185f, -64.0f, 16.031166f,
-64.0f, 14.37168f, -64.0f, 12.7303915f, -64.0f, 11.105054f, -64.0f, 9.493504f, -64.0f, 7.893647f,
-64.0f, 6.3034496f, -64.0f, 4.7209234f, -64.0f, 3.1441183f, -64.0f, 1.5711118f, -64.0f, 0.0f,
-64.0f, -1.5711118f, -64.0f, -3.1441183f, -64.0f, -4.7209234f, -64.0f, -6.3034496f, -64.0f, -7.893647f,
-64.0f, -9.493504f, -64.0f, -11.105054f, -64.0f, -12.7303915f, -64.0f, -14.37168f, -64.0f, -16.031166f,
-64.0f, -17.711185f, -64.0f, -19.414188f, -64.0f, -21.142744f, -64.0f, -22.899567f, -64.0f, -24.687525f,
-64.0f, -26.509668f, -64.0f, -28.36925f, -64.0f, -30.269745f, -64.0f, -32.214893f, -64.0f, -34.208714f,
-64.0f, -36.25555f, -64.0f, -38.360123f, -64.0f, -40.527554f, -64.0f, -42.76343f, -64.0f, -45.073887f,
-64.0f, -47.465633f, -64.0f, -49.94609f, -64.0f, -52.52344f, -64.0f, -55.20678f, -64.0f, -58.006218f,
-64.0f, -60.933064f, -64.0f, -64.0f, -64.0f, -67.221306f, -64.0f, -70.61312f, -64.0f, -74.19379f,
-64.0f, -77.98422f, -64.0f, -82.00842f, -64.0f, -86.294014f, -64.0f, -90.87302f, -64.0f, -95.78277f,
-64.0f, -101.06705f, -64.0f, -106.77755f, -64.0f, -112.9758f, -64.0f, -119.73558f, -64.0f, -127.146164f,
-64.0f, -135.31664f, -64.0f, -144.38168f, -64.0f, -154.50967f, -64.0f, -165.91376f, -64.0f, -178.86801f,
-64.0f, -193.73076f, -64.0f, -210.97972f, -64.0f, -231.26628f, -64.0f, -255.50232f, -64.0f, -285.00494f,
-64.0f, -321.74973f, -64.0f, -368.8411f, -64.0f, -431.45294f, -64.0f, -518.8983f, -64.0f, -649.8029f,
-64.0f, -867.62683f, -64.0f, -1302.7499f, -64.0f, -2607.071f});
test_case.run_with_tolerance_as_fp(2e-2f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_no_onesided_complex_input_no_window_default_length) {
auto model = convert_model("stft_no_onesided_complex_input_no_window_default_length.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{1, 128, 2};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_expected_output<float>(
Shape{1, 1, 128, 2},
{16256.0f, 16384.0f, -5342.142f, 5086.142f, -2733.4998f, 2477.4998f, -1863.2537f, 1607.2537f,
-1427.6058f, 1171.6058f, -1165.7966f, 909.7966f, -990.9059f, 734.9059f, -865.6822f, 609.6822f,
-771.49945f, 515.49945f, -698.0099f, 442.0099f, -639.00464f, 383.00464f, -590.5326f, 334.53256f,
-549.9595f, 293.95944f, -515.46155f, 259.46152f, -485.73602f, 229.73604f, -459.8275f, 203.82751f,
-437.01935f, 181.01933f, -416.76337f, 160.76337f, -398.63327f, 142.63326f, -382.29233f, 126.29233f,
-367.47116f, 111.47115f, -353.9516f, 97.9516f, -341.55508f, 85.5551f, -330.1341f, 74.13409f,
-319.56555f, 63.565536f, -309.74603f, 53.746037f, -300.588f, 44.58802f, -292.01685f, 36.01684f,
-283.96844f, 27.96845f, -276.38757f, 20.387571f, -269.22623f, 13.226237f, -262.4426f, 6.4426045f,
-256.0f, 0.0f, -249.86613f, -6.133869f, -244.01244f, -11.987562f, -238.41356f, -17.586441f,
-233.04689f, -22.953115f, -227.89218f, -28.10782f, -222.93127f, -33.06873f, -218.14777f, -37.85223f,
-213.52687f, -42.473133f, -209.0551f, -46.944893f, -204.72025f, -51.27975f, -200.51111f, -55.488895f,
-196.41742f, -59.582573f, -192.42978f, -63.570213f, -188.53949f, -67.46051f, -184.7385f, -71.261505f,
-181.01933f, -74.98067f, -177.37505f, -78.624954f, -173.79913f, -82.20087f, -170.28549f, -85.71451f,
-166.82837f, -89.17162f, -163.42236f, -92.57763f, -160.06233f, -95.93767f, -156.74336f, -99.25664f,
-153.46078f, -102.539215f, -150.21011f, -105.789894f, -146.987f, -109.01299f, -143.7873f, -112.21271f,
-140.6069f, -115.3931f, -137.44185f, -118.55815f, -134.28824f, -121.71176f, -131.14223f, -124.85777f,
-128.0f, -128.0f, -124.85777f, -131.14223f, -121.71176f, -134.28824f, -118.55815f, -137.44185f,
-115.3931f, -140.6069f, -112.21271f, -143.7873f, -109.01299f, -146.987f, -105.789894f, -150.21011f,
-102.539215f, -153.46078f, -99.25664f, -156.74336f, -95.93767f, -160.06233f, -92.57763f, -163.42236f,
-89.17162f, -166.82837f, -85.71451f, -170.28549f, -82.20087f, -173.79913f, -78.624954f, -177.37505f,
-74.98067f, -181.01933f, -71.261505f, -184.7385f, -67.46051f, -188.53949f, -63.570213f, -192.42978f,
-59.582573f, -196.41742f, -55.488895f, -200.51111f, -51.27975f, -204.72025f, -46.944893f, -209.0551f,
-42.473133f, -213.52687f, -37.85223f, -218.14777f, -33.06873f, -222.93127f, -28.10782f, -227.89218f,
-22.953115f, -233.04689f, -17.586441f, -238.41356f, -11.987562f, -244.01244f, -6.133869f, -249.86613f,
0.0f, -256.0f, 6.4426045f, -262.4426f, 13.226237f, -269.22623f, 20.387571f, -276.38757f,
27.96845f, -283.96844f, 36.01684f, -292.01685f, 44.58802f, -300.588f, 53.746037f, -309.74603f,
63.565536f, -319.56555f, 74.13409f, -330.1341f, 85.5551f, -341.55508f, 97.9516f, -353.9516f,
111.47115f, -367.47116f, 126.29233f, -382.29233f, 142.63326f, -398.63327f, 160.76337f, -416.76337f,
181.01933f, -437.01935f, 203.82751f, -459.8275f, 229.73604f, -485.73602f, 259.46152f, -515.46155f,
293.95944f, -549.9595f, 334.53256f, -590.5326f, 383.00464f, -639.00464f, 442.0099f, -698.0099f,
515.49945f, -771.49945f, 609.6822f, -865.6822f, 734.9059f, -990.9059f, 909.7966f, -1165.7966f,
1171.6058f, -1427.6058f, 1607.2537f, -1863.2537f, 2477.4998f, -2733.4998f, 5086.142f, -5342.142f});
test_case.run_with_tolerance_as_fp(5e-2f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_no_onesided_complex_input_no_window_default_length_2) {
auto model = convert_model("stft_no_onesided_complex_input_no_window_default_length_2.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{2, 64, 2};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_expected_output<float>(
Shape{2, 1, 64, 2},
{4032.0f, 4096.0f, -1366.7499f, 1238.7499f, -713.8029f, 585.8029f, -495.45294f, 367.45294f,
-385.74973f, 257.74973f, -319.50232f, 191.50232f, -274.97974f, 146.97972f, -242.86801f, 114.86802f,
-218.50967f, 90.50967f, -199.31664f, 71.31663f, -183.73558f, 55.735577f, -170.77754f, 42.77755f,
-159.78278f, 31.782768f, -150.294f, 22.29401f, -141.98422f, 13.984225f, -134.61311f, 6.6131186f,
-128.0f, 0.0f, -122.00622f, -5.993781f, -116.523445f, -11.476558f, -111.46564f, -16.534365f,
-106.763435f, -21.236567f, -102.36012f, -25.639875f, -98.20871f, -29.791286f, -94.269745f, -33.730255f,
-90.50967f, -37.490334f, -86.89957f, -41.100433f, -83.414185f, -44.58581f, -80.031166f, -47.968834f,
-76.73039f, -51.269608f, -73.4935f, -54.506496f, -70.30345f, -57.69655f, -67.14412f, -60.85588f,
-64.0f, -64.0f, -60.85588f, -67.14412f, -57.69655f, -70.30345f, -54.506496f, -73.4935f,
-51.269608f, -76.73039f, -47.968834f, -80.031166f, -44.58581f, -83.414185f, -41.100433f, -86.89957f,
-37.490334f, -90.50967f, -33.730255f, -94.269745f, -29.791286f, -98.20871f, -25.639875f, -102.36012f,
-21.236567f, -106.763435f, -16.534365f, -111.46564f, -11.476558f, -116.523445f, -5.993781f, -122.00622f,
0.0f, -128.0f, 6.6131186f, -134.61311f, 13.984225f, -141.98422f, 22.29401f, -150.294f,
31.782768f, -159.78278f, 42.77755f, -170.77754f, 55.735577f, -183.73558f, 71.31663f, -199.31664f,
90.50967f, -218.50967f, 114.86802f, -242.86801f, 146.97972f, -274.97974f, 191.50232f, -319.50232f,
257.74973f, -385.74973f, 367.45294f, -495.45294f, 585.8029f, -713.8029f, 1238.7499f, -1366.7499f,
12224.0f, 12288.0f, -1366.7499f, 1238.7499f, -713.8029f, 585.8029f, -495.45294f, 367.45294f,
-385.74973f, 257.74973f, -319.50232f, 191.50232f, -274.97974f, 146.97972f, -242.86801f, 114.86802f,
-218.50967f, 90.50967f, -199.31664f, 71.31663f, -183.73558f, 55.735577f, -170.77754f, 42.77755f,
-159.78278f, 31.782768f, -150.294f, 22.29401f, -141.98422f, 13.984225f, -134.61311f, 6.6131186f,
-128.0f, 0.0f, -122.00622f, -5.993781f, -116.523445f, -11.476558f, -111.46564f, -16.534365f,
-106.763435f, -21.236567f, -102.36012f, -25.639875f, -98.20871f, -29.791286f, -94.269745f, -33.730255f,
-90.50967f, -37.490334f, -86.89957f, -41.100433f, -83.414185f, -44.58581f, -80.031166f, -47.968834f,
-76.73039f, -51.269608f, -73.4935f, -54.506496f, -70.30345f, -57.69655f, -67.14412f, -60.85588f,
-64.0f, -64.0f, -60.85588f, -67.14412f, -57.69655f, -70.30345f, -54.506496f, -73.4935f,
-51.269608f, -76.73039f, -47.968834f, -80.031166f, -44.58581f, -83.414185f, -41.100433f, -86.89957f,
-37.490334f, -90.50967f, -33.730255f, -94.269745f, -29.791286f, -98.20871f, -25.639875f, -102.36012f,
-21.236567f, -106.763435f, -16.534365f, -111.46564f, -11.476558f, -116.523445f, -5.993781f, -122.00622f,
0.0f, -128.0f, 6.6131186f, -134.61311f, 13.984225f, -141.98422f, 22.29401f, -150.294f,
31.782768f, -159.78278f, 42.77755f, -170.77754f, 55.735577f, -183.73558f, 71.31663f, -199.31664f,
90.50967f, -218.50967f, 114.86802f, -242.86801f, 146.97972f, -274.97974f, 191.50232f, -319.50232f,
257.74973f, -385.74973f, 367.45294f, -495.45294f, 585.8029f, -713.8029f, 1238.7499f, -1366.7499f});
test_case.run_with_tolerance_as_fp(5e-2f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_no_onesided_complex_input_no_window_no_default_length) {
auto model = convert_model("stft_no_onesided_complex_input_no_window_no_default_length.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{4, 32, 2};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_expected_output<float>(
Shape{4, 2, 24, 2},
{552.0f, 576.0f, -206.2981f, 158.2981f, -113.56922f, 65.56922f, -81.941124f, 33.941124f,
-65.56922f, 17.56922f, -55.27741f, 7.277409f, -48.0f, 0.0f, -42.415848f, -5.584152f,
-37.856407f, -10.143594f, -33.941124f, -14.058874f, -30.43078f, -17.56922f, -27.15966f, -20.84034f,
-24.0f, -24.0f, -20.84034f, -27.15966f, -17.56922f, -30.43078f, -14.058874f, -33.941124f,
-10.143594f, -37.856407f, -5.584152f, -42.415848f, 0.0f, -48.0f, 7.277409f, -55.27741f,
17.56922f, -65.56922f, 33.941124f, -81.941124f, 65.56922f, -113.56922f, 158.2981f, -206.2981f,
936.0f, 960.0f, -206.2981f, 158.2981f, -113.56922f, 65.56922f, -81.941124f, 33.941124f,
-65.56922f, 17.56922f, -55.27741f, 7.277409f, -48.0f, 0.0f, -42.415848f, -5.584152f,
-37.856407f, -10.143594f, -33.941124f, -14.058874f, -30.43078f, -17.56922f, -27.15966f, -20.84034f,
-24.0f, -24.0f, -20.84034f, -27.15966f, -17.56922f, -30.43078f, -14.058874f, -33.941124f,
-10.143594f, -37.856407f, -5.584152f, -42.415848f, 0.0f, -48.0f, 7.277409f, -55.27741f,
17.56922f, -65.56922f, 33.941124f, -81.941124f, 65.56922f, -113.56922f, 158.2981f, -206.2981f,
2088.0f, 2112.0f, -206.2981f, 158.2981f, -113.56922f, 65.56922f, -81.941124f, 33.941124f,
-65.56922f, 17.56922f, -55.27741f, 7.277409f, -48.0f, 0.0f, -42.415848f, -5.584152f,
-37.856407f, -10.143594f, -33.941124f, -14.058874f, -30.43078f, -17.56922f, -27.15966f, -20.84034f,
-24.0f, -24.0f, -20.84034f, -27.15966f, -17.56922f, -30.43078f, -14.058874f, -33.941124f,
-10.143594f, -37.856407f, -5.584152f, -42.415848f, 0.0f, -48.0f, 7.277409f, -55.27741f,
17.56922f, -65.56922f, 33.941124f, -81.941124f, 65.56922f, -113.56922f, 158.2981f, -206.2981f,
2472.0f, 2496.0f, -206.2981f, 158.2981f, -113.56922f, 65.56922f, -81.941124f, 33.941124f,
-65.56922f, 17.56922f, -55.27741f, 7.277409f, -48.0f, 0.0f, -42.415848f, -5.584152f,
-37.856407f, -10.143594f, -33.941124f, -14.058874f, -30.43078f, -17.56922f, -27.15966f, -20.84034f,
-24.0f, -24.0f, -20.84034f, -27.15966f, -17.56922f, -30.43078f, -14.058874f, -33.941124f,
-10.143594f, -37.856407f, -5.584152f, -42.415848f, 0.0f, -48.0f, 7.277409f, -55.27741f,
17.56922f, -65.56922f, 33.941124f, -81.941124f, 65.56922f, -113.56922f, 158.2981f, -206.2981f,
3624.0f, 3648.0f, -206.2981f, 158.2981f, -113.56922f, 65.56922f, -81.941124f, 33.941124f,
-65.56922f, 17.56922f, -55.27741f, 7.277409f, -48.0f, 0.0f, -42.415848f, -5.584152f,
-37.856407f, -10.143594f, -33.941124f, -14.058874f, -30.43078f, -17.56922f, -27.15966f, -20.84034f,
-24.0f, -24.0f, -20.84034f, -27.15966f, -17.56922f, -30.43078f, -14.058874f, -33.941124f,
-10.143594f, -37.856407f, -5.584152f, -42.415848f, 0.0f, -48.0f, 7.277409f, -55.27741f,
17.56922f, -65.56922f, 33.941124f, -81.941124f, 65.56922f, -113.56922f, 158.2981f, -206.2981f,
4008.0f, 4032.0f, -206.2981f, 158.2981f, -113.56922f, 65.56922f, -81.941124f, 33.941124f,
-65.56922f, 17.56922f, -55.27741f, 7.277409f, -48.0f, 0.0f, -42.415848f, -5.584152f,
-37.856407f, -10.143594f, -33.941124f, -14.058874f, -30.43078f, -17.56922f, -27.15966f, -20.84034f,
-24.0f, -24.0f, -20.84034f, -27.15966f, -17.56922f, -30.43078f, -14.058874f, -33.941124f,
-10.143594f, -37.856407f, -5.584152f, -42.415848f, 0.0f, -48.0f, 7.277409f, -55.27741f,
17.56922f, -65.56922f, 33.941124f, -81.941124f, 65.56922f, -113.56922f, 158.2981f, -206.2981f,
5160.0f, 5184.0f, -206.2981f, 158.2981f, -113.56922f, 65.56922f, -81.941124f, 33.941124f,
-65.56922f, 17.56922f, -55.27741f, 7.277409f, -48.0f, 0.0f, -42.415848f, -5.584152f,
-37.856407f, -10.143594f, -33.941124f, -14.058874f, -30.43078f, -17.56922f, -27.15966f, -20.84034f,
-24.0f, -24.0f, -20.84034f, -27.15966f, -17.56922f, -30.43078f, -14.058874f, -33.941124f,
-10.143594f, -37.856407f, -5.584152f, -42.415848f, 0.0f, -48.0f, 7.277409f, -55.27741f,
17.56922f, -65.56922f, 33.941124f, -81.941124f, 65.56922f, -113.56922f, 158.2981f, -206.2981f,
5544.0f, 5568.0f, -206.2981f, 158.2981f, -113.56922f, 65.56922f, -81.941124f, 33.941124f,
-65.56922f, 17.56922f, -55.27741f, 7.277409f, -48.0f, 0.0f, -42.415848f, -5.584152f,
-37.856407f, -10.143594f, -33.941124f, -14.058874f, -30.43078f, -17.56922f, -27.15966f, -20.84034f,
-24.0f, -24.0f, -20.84034f, -27.15966f, -17.56922f, -30.43078f, -14.058874f, -33.941124f,
-10.143594f, -37.856407f, -5.584152f, -42.415848f, 0.0f, -48.0f, 7.277409f, -55.27741f,
17.56922f, -65.56922f, 33.941124f, -81.941124f, 65.56922f, -113.56922f, 158.2981f, -206.2981f});
test_case.run_with_tolerance_as_fp(1e-2f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_no_onesided_complex_input_given_window_default_length) {
auto model = convert_model("stft_no_onesided_complex_input_given_window_default_length.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{3, 32, 2};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<float>(Shape{8},
{1.0f, 0.8535616f, 0.5000232f, 0.1464712f, 0.0f, 0.1464057f, 0.49993038f, 0.853496f});
test_case.add_expected_output<float>(
Shape{3, 7, 8, 2},
{23.998209f, 27.998096f, -3.6551387f, 21.654558f, -17.65585f, 1.6573805f, -11.656438f, -4.3427963f,
-7.9996943f, -7.9996753f, -4.342819f, -11.656415f, 1.657334f, -17.655802f, 19.654396f, -1.6553476f,
55.997314f, 59.9972f, 12.346159f, 37.65289f, -17.655478f, 1.6577513f, -11.656253f, -4.3426094f,
-7.9995418f, -7.9995227f, -4.3426323f, -11.65623f, 1.6577048f, -17.65543f, 35.652725f, 14.34595f,
87.996414f, 91.99631f, 28.347458f, 53.65122f, -17.655106f, 1.6581223f, -11.656068f, -4.3424225f,
-7.999389f, -7.99937f, -4.3424454f, -11.656045f, 1.6580758f, -17.655058f, 51.65106f, 30.347248f,
119.99552f, 123.99541f, 44.348755f, 69.64955f, -17.654734f, 1.6584934f, -11.655883f, -4.3422356f,
-7.9992366f, -7.9992175f, -4.3422585f, -11.65586f, 1.6584469f, -17.654686f, 67.64938f, 46.348545f,
151.99463f, 155.99452f, 60.35005f, 85.64788f, -17.654362f, 1.6588643f, -11.655698f, -4.3420486f,
-7.999084f, -7.999065f, -4.3420715f, -11.655675f, 1.6588178f, -17.654314f, 83.64772f, 62.349846f,
183.99373f, 187.99362f, 76.35135f, 101.64621f, -17.65399f, 1.6592352f, -11.655513f, -4.3418617f,
-7.9989314f, -7.9989123f, -4.3418846f, -11.65549f, 1.6591887f, -17.653942f, 99.64605f, 78.35114f,
215.99283f, 219.99272f, 92.352646f, 117.64454f, -17.653618f, 1.6596063f, -11.655329f, -4.341675f,
-7.998779f, -7.9987597f, -4.3416977f, -11.655305f, 1.6595598f, -17.65357f, 115.64438f, 94.35244f,
279.99106f, 283.99094f, 124.35525f, 149.6412f, -17.652874f, 1.6603482f, -11.654959f, -4.341301f,
-7.9984736f, -7.9984546f, -4.341324f, -11.654935f, 1.6603017f, -17.652826f, 147.64104f, 126.355034f,
311.99014f, 315.99005f, 140.35654f, 165.63953f, -17.652502f, 1.6607193f, -11.654774f, -4.341114f,
-7.998321f, -7.998302f, -4.341137f, -11.65475f, 1.6606728f, -17.652454f, 163.63937f, 142.35634f,
343.98926f, 347.98914f, 156.35783f, 181.63786f, -17.65213f, 1.6610903f, -11.654589f, -4.340927f,
-7.9981685f, -7.9981494f, -4.34095f, -11.654565f, 1.6610438f, -17.652082f, 179.6377f, 158.35764f,
375.98837f, 379.98825f, 172.35915f, 197.63618f, -17.651758f, 1.6614611f, -11.654404f, -4.34074f,
-7.998016f, -7.997997f, -4.340763f, -11.65438f, 1.6614146f, -17.65171f, 195.63603f, 174.35893f,
407.98746f, 411.98737f, 188.36044f, 213.63452f, -17.651386f, 1.6618322f, -11.654219f, -4.3405533f,
-7.9978633f, -7.997844f, -4.340576f, -11.654196f, 1.6617857f, -17.651339f, 211.63435f, 190.36023f,
439.98657f, 443.98645f, 204.36174f, 229.63286f, -17.651014f, 1.6622032f, -11.654034f, -4.3403664f,
-7.9977107f, -7.9976916f, -4.3403893f, -11.654011f, 1.6621567f, -17.650967f, 227.63269f, 206.36153f,
471.98566f, 475.98557f, 220.36304f, 245.63118f, -17.650642f, 1.662574f, -11.653849f, -4.3401794f,
-7.997558f, -7.997539f, -4.3402023f, -11.653826f, 1.6625277f, -17.650595f, 243.63101f, 222.36282f,
535.9839f, 539.98376f, 252.36563f, 277.62784f, -17.649899f, 1.6633161f, -11.653479f, -4.3398056f,
-7.997253f, -7.997234f, -4.3398285f, -11.653456f, 1.6632696f, -17.64985f, 275.6277f, 254.36542f,
567.983f, 571.98285f, 268.3669f, 293.62616f, -17.649527f, 1.663687f, -11.653294f, -4.3396187f,
-7.9971004f, -7.9970813f, -4.3396416f, -11.653271f, 1.6636405f, -17.649479f, 291.626f, 270.36673f,
599.9821f, 603.982f, 284.36823f, 309.6245f, -17.649155f, 1.664058f, -11.65311f, -4.339432f,
-7.996948f, -7.9969287f, -4.3394547f, -11.653086f, 1.6640115f, -17.649107f, 307.62433f, 286.368f,
631.9812f, 635.9811f, 300.36954f, 325.62283f, -17.648783f, 1.6644291f, -11.652925f, -4.339245f,
-7.996795f, -7.996776f, -4.3392677f, -11.652901f, 1.6643825f, -17.648735f, 323.62268f, 302.36932f,
663.9803f, 667.98016f, 316.37082f, 341.62115f, -17.64841f, 1.6648f, -11.65274f, -4.339058f,
-7.9966426f, -7.9966235f, -4.3390813f, -11.652716f, 1.6647534f, -17.648363f, 339.621f, 318.3706f,
695.97943f, 699.9793f, 332.37213f, 357.6195f, -17.648039f, 1.665171f, -11.6525545f, -4.338871f,
-7.99649f, -7.996471f, -4.3388944f, -11.652531f, 1.6651244f, -17.647991f, 355.61932f, 334.37192f,
727.9785f, 731.9784f, 348.3734f, 373.61783f, -17.647667f, 1.665542f, -11.6523695f, -4.338684f,
-7.9963374f, -7.9963183f, -4.3387074f, -11.652346f, 1.6654955f, -17.64762f, 371.61765f, 350.3732f});
test_case.run_with_tolerance_as_fp(1e-3f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_no_onesided_complex_input_given_window_no_default_length) {
auto model = convert_model("stft_no_onesided_complex_input_given_window_no_default_length.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{2, 48, 2};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<float>(Shape{10},
{1.0f,
0.90451396f,
0.6545261f,
0.345518f,
0.095513284f,
0.0f,
0.095458746f,
0.34542978f,
0.654438f,
0.9044596f});
test_case.add_expected_output<float>(
Shape{2, 4, 10, 2},
{39.99715f, 44.997005f, -3.826806f, 36.325737f, -26.390974f, 6.393208f, -17.885399f, -2.1136048f,
-13.440596f, -6.558717f, -9.9997015f, -9.999686f, -6.5587335f, -13.440578f, -2.113629f, -17.885376f,
6.3931537f, -26.39092f, 33.825535f, -1.3270694f, 159.99373f, 164.99359f, 56.177994f, 96.31941f,
-26.389673f, 6.3945208f, -17.884817f, -2.1130202f, -13.440192f, -6.5583134f, -9.999345f, -9.9993305f,
-6.55833f, -13.440175f, -2.1130445f, -17.884794f, 6.3944664f, -26.389618f, 93.819214f, 58.67773f,
279.9903f, 284.99017f, 116.18279f, 156.3131f, -26.388372f, 6.3958335f, -17.884237f, -2.1124356f,
-13.439788f, -6.5579104f, -9.998989f, -9.998974f, -6.557927f, -13.439772f, -2.11246f, -17.884212f,
6.395779f, -26.388317f, 153.8129f, 118.682526f, 399.98688f, 404.98676f, 176.18759f, 216.30678f,
-26.387072f, 6.3971457f, -17.883656f, -2.111851f, -13.439384f, -6.5575075f, -9.998633f, -9.998618f,
-6.557524f, -13.439368f, -2.1118753f, -17.88363f, 6.397092f, -26.387016f, 213.80656f, 178.68733f,
519.98346f, 524.98334f, 236.1924f, 276.30045f, -26.38577f, 6.3984585f, -17.883074f, -2.1112664f,
-13.438981f, -6.557104f, -9.998277f, -9.998261f, -6.5571213f, -13.438965f, -2.1112907f, -17.883049f,
6.3984046f, -26.385715f, 273.80026f, 238.69212f, 639.98004f, 644.9799f, 296.1972f, 336.29413f,
-26.384468f, 6.399771f, -17.882492f, -2.1106818f, -13.438578f, -6.556701f, -9.99792f, -9.997906f,
-6.556718f, -13.438561f, -2.110706f, -17.882467f, 6.399717f, -26.384415f, 333.7939f, 298.69693f,
759.9766f, 764.9765f, 356.202f, 396.2878f, -26.383167f, 6.401084f, -17.88191f, -2.1100972f,
-13.438174f, -6.5562983f, -9.997564f, -9.997549f, -6.556315f, -13.438158f, -2.1101215f, -17.881886f,
6.4010296f, -26.383114f, 393.7876f, 358.70172f, 879.9732f, 884.9731f, 416.2068f, 456.2815f,
-26.381866f, 6.4023967f, -17.881329f, -2.1095126f, -13.437771f, -6.555895f, -9.997208f, -9.997193f,
-6.555912f, -13.437754f, -2.109537f, -17.881304f, 6.4023423f, -26.381811f, 453.78128f, 418.7065f});
test_case.run_with_tolerance_as_fp(1e-3f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_onesided_real_input_given_window_no_default_length) {
auto model = convert_model("stft_onesided_real_input_given_window_no_default_length.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{2, 32, 1};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<float>(Shape{16}, stft_window_16);
test_case.add_expected_output<float>(
Shape{2, 3, 9, 2},
{55.996273f, 0.0f, 23.999104f, 24.93398f, -7.99869f, 22.70421f, -7.999475f, 12.814739f,
-7.999694f, 8.329526f, -7.999781f, 5.5011215f, -7.999824f, 3.3910275f, -7.9998474f, 1.6240749f,
-7.999859f, 0.0f, 119.99441f, 0.0f, 55.998657f, 24.931015f, -7.9980354f, 22.704208f,
-7.9992137f, 12.814741f, -7.999542f, 8.329527f, -7.9996705f, 5.5011196f, -7.999737f, 3.3910284f,
-7.999769f, 1.6240768f, -7.9997787f, 0.0f, 183.99254f, 0.0f, 87.998215f, 24.928047f,
-7.9973803f, 22.70421f, -7.9989514f, 12.814744f, -7.9993896f, 8.329525f, -7.999561f, 5.5011206f,
-7.999648f, 3.3910275f, -7.9996986f, 1.6240759f, -7.99971f, 0.0f, 311.98883f, 0.0f,
151.99731f, 24.922113f, -7.9960704f, 22.704214f, -7.998431f, 12.814743f, -7.9990845f, 8.329521f,
-7.999341f, 5.5011144f, -7.999474f, 3.3910275f, -7.999542f, 1.6240788f, -7.9995728f, 0.0f,
375.98694f, 0.0f, 183.99686f, 24.919151f, -7.9954133f, 22.704203f, -7.9981623f, 12.814751f,
-7.998932f, 8.329529f, -7.9992285f, 5.501122f, -7.9993834f, 3.3910313f, -7.9994736f, 1.6240854f,
-7.9994965f, 0.0f, 439.98508f, 0.0f, 215.9964f, 24.916183f, -7.99476f, 22.704206f,
-7.9979024f, 12.814749f, -7.9987793f, 8.329529f, -7.999122f, 5.5011153f, -7.9992967f, 3.391035f,
-7.999382f, 1.6240807f, -7.99942f, 0.0f});
test_case.run_with_tolerance_as_fp(1e-3f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_2D_onesided_real_input_given_window_no_default_length) {
auto model = convert_model("stft_2D_onesided_real_input_given_window_no_default_length.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{2, 32};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<float>(Shape{16}, stft_window_16);
test_case.add_expected_output<float>(
Shape{2, 3, 9, 2},
{55.996273f, 0.0f, 23.999104f, 24.93398f, -7.99869f, 22.70421f, -7.999475f, 12.814739f,
-7.999694f, 8.329526f, -7.999781f, 5.5011215f, -7.999824f, 3.3910275f, -7.9998474f, 1.6240749f,
-7.999859f, 0.0f, 119.99441f, 0.0f, 55.998657f, 24.931015f, -7.9980354f, 22.704208f,
-7.9992137f, 12.814741f, -7.999542f, 8.329527f, -7.9996705f, 5.5011196f, -7.999737f, 3.3910284f,
-7.999769f, 1.6240768f, -7.9997787f, 0.0f, 183.99254f, 0.0f, 87.998215f, 24.928047f,
-7.9973803f, 22.70421f, -7.9989514f, 12.814744f, -7.9993896f, 8.329525f, -7.999561f, 5.5011206f,
-7.999648f, 3.3910275f, -7.9996986f, 1.6240759f, -7.99971f, 0.0f, 311.98883f, 0.0f,
151.99731f, 24.922113f, -7.9960704f, 22.704214f, -7.998431f, 12.814743f, -7.9990845f, 8.329521f,
-7.999341f, 5.5011144f, -7.999474f, 3.3910275f, -7.999542f, 1.6240788f, -7.9995728f, 0.0f,
375.98694f, 0.0f, 183.99686f, 24.919151f, -7.9954133f, 22.704203f, -7.9981623f, 12.814751f,
-7.998932f, 8.329529f, -7.9992285f, 5.501122f, -7.9993834f, 3.3910313f, -7.9994736f, 1.6240854f,
-7.9994965f, 0.0f, 439.98508f, 0.0f, 215.9964f, 24.916183f, -7.99476f, 22.704206f,
-7.9979024f, 12.814749f, -7.9987793f, 8.329529f, -7.999122f, 5.5011153f, -7.9992967f, 3.391035f,
-7.999382f, 1.6240807f, -7.99942f, 0.0f});
test_case.run_with_tolerance_as_fp(1e-3f);
}
namespace {
const std::vector<float> stft_window_16_expected{
55.996273f, 0.0f, 23.999104f, 24.93398f, -7.99869f, 22.70421f, -7.999475f, 12.814739f, -7.999694f,
8.329526f, -7.999781f, 5.5011215f, -7.999824f, 3.3910275f, -7.9998474f, 1.6240749f, -7.999859f, 0.0f,
119.99441f, 0.0f, 55.998657f, 24.931015f, -7.9980354f, 22.704208f, -7.9992137f, 12.814741f, -7.999542f,
8.329527f, -7.9996705f, 5.5011196f, -7.999737f, 3.3910284f, -7.999769f, 1.6240768f, -7.9997787f, 0.0f,
183.99254f, 0.0f, 87.998215f, 24.928047f, -7.9973803f, 22.70421f, -7.9989514f, 12.814744f, -7.9993896f,
8.329525f, -7.999561f, 5.5011206f, -7.999648f, 3.3910275f, -7.9996986f, 1.6240759f, -7.99971f, 0.0f,
311.98883f, 0.0f, 151.99731f, 24.922113f, -7.9960704f, 22.704214f, -7.998431f, 12.814743f, -7.9990845f,
8.329521f, -7.999341f, 5.5011144f, -7.999474f, 3.3910275f, -7.999542f, 1.6240788f, -7.9995728f, 0.0f,
375.98694f, 0.0f, 183.99686f, 24.919151f, -7.9954133f, 22.704203f, -7.9981623f, 12.814751f, -7.998932f,
8.329529f, -7.9992285f, 5.501122f, -7.9993834f, 3.3910313f, -7.9994736f, 1.6240854f, -7.9994965f, 0.0f,
439.98508f, 0.0f, 215.9964f, 24.916183f, -7.99476f, 22.704206f, -7.9979024f, 12.814749f, -7.9987793f,
8.329529f, -7.999122f, 5.5011153f, -7.9992967f, 3.391035f, -7.999382f, 1.6240807f, -7.99942f, 0.0f};
} // namespace
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_non_const_frame_step) {
auto model = convert_model("stft_non_const_frame_step.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{2, 32, 1};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<int64_t>(Shape{1}, {8});
test_case.add_input<float>(Shape{16}, stft_window_16);
test_case.add_expected_output<float>(Shape{2, 3, 9, 2}, stft_window_16_expected);
test_case.run_with_tolerance_as_fp(1e-3f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_runtime_frame_length) {
auto model = convert_model("stft_runtime_frame_length.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{1, 20, 1};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<int64_t>(Shape{}, {6});
test_case.add_input<int64_t>(Shape{}, {8});
test_case.add_expected_output<float>(
Shape{1, 3, 8, 2},
{28.0f, 0.0f, -4.0f, 9.656855f, -4.0f, 4.0f, -4.0f, 1.6568543f, -4.0f, 0.0f, -4.0f, -1.6568543f,
-4.0f, -4.0f, -4.0f, -9.656855f, 76.0f, 0.0f, -4.0f, 9.656855f, -4.0f, 4.0f, -4.0f, 1.6568543f,
-4.0f, 0.0f, -4.0f, -1.6568543f, -4.0f, -4.0f, -4.0f, -9.656855f, 124.0f, 0.0f, -4.0f, 9.656855f,
-4.0f, 4.0f, -4.0f, 1.6568543f, -4.0f, 0.0f, -4.0f, -1.6568543f, -4.0f, -4.0f, -4.0f, -9.656855f});
test_case.run_with_tolerance_as_fp(1e-4f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<int64_t>(Shape{}, {5});
test_case.add_input<int64_t>(Shape{}, {4});
test_case.add_expected_output<float>(
Shape{1, 4, 4, 2},
{6.0f, 0.0f, -2.0f, 2.0f, -2.0f, 0.0f, -2.0f, -2.0f, 26.0f, 0.0f, -2.0f, 2.0f, -2.0f, 0.0f, -2.0f, -2.0f,
46.0f, 0.0f, -2.0f, 2.0f, -2.0f, 0.0f, -2.0f, -2.0f, 66.0f, 0.0f, -2.0f, 2.0f, -2.0f, 0.0f, -2.0f, -2.0f});
test_case.run_with_tolerance_as_fp(1e-4f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_dynamic_signal_shape) {
auto model = convert_model("stft_dynamic_signal_shape.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{2, 32, 1};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<float>(Shape{16}, stft_window_16);
test_case.add_expected_output<float>(Shape{2, 3, 9, 2}, stft_window_16_expected);
test_case.run_with_tolerance_as_fp(1e-3f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_complex_dynamic_signal_shape) {
auto model = convert_model("stft_complex_dynamic_signal_shape.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{2, 32, 2};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<float>(Shape{16}, stft_window_16);
test_case.add_expected_output<float>(
Shape{2, 3, 16, 2},
{111.992546f, 119.99231f, -1.8693811f, 101.86612f, -61.4058f, 29.411123f, -41.628433f, 9.630561f,
-32.658443f, 0.6596847f, -27.001806f, -4.9973054f, -22.781706f, -9.217583f, -19.247847f, -12.751536f,
-15.99971f, -15.999701f, -12.751545f, -19.247837f, -9.217593f, -22.781694f, -4.997319f, -27.001793f,
0.6596657f, -32.658424f, 9.630528f, -41.6284f, 29.411041f, -61.40572f, 97.8658f, 2.1301923f,
239.98882f, 247.98859f, 62.135654f, 165.85928f, -61.40449f, 29.412434f, -41.62791f, 9.631088f,
-32.65814f, 0.6599904f, -27.001585f, -4.9970865f, -22.781532f, -9.217405f, -19.247698f, -12.751381f,
-15.999564f, -15.999556f, -12.7513895f, -19.247688f, -9.217417f, -22.78152f, -4.9971004f, -27.001572f,
0.65997136f, -32.65812f, 9.631056f, -41.62788f, 29.412352f, -61.404408f, 161.85898f, 66.13523f,
367.98508f, 375.98486f, 126.14069f, 229.85246f, -61.40318f, 29.413744f, -41.62739f, 9.631615f,
-32.657833f, 0.660296f, -27.001364f, -4.9968677f, -22.781359f, -9.217229f, -19.24755f, -12.751225f,
-15.999419f, -15.99941f, -12.751234f, -19.24754f, -9.21724f, -22.781347f, -4.996881f, -27.00135f,
0.660277f, -32.657814f, 9.631582f, -41.627357f, 29.413662f, -61.403095f, 225.85214f, 130.14026f,
623.97766f, 631.9774f, 254.15077f, 357.8388f, -61.40056f, 29.416363f, -41.62635f, 9.632668f,
-32.657223f, 0.6609073f, -27.000921f, -4.9964294f, -22.78101f, -9.216876f, -19.247253f, -12.750915f,
-15.999128f, -15.999119f, -12.750923f, -19.247244f, -9.2168865f, -22.780998f, -4.9964433f, -27.000908f,
0.6608883f, -32.657204f, 9.632635f, -41.626316f, 29.41628f, -61.400475f, 353.8385f, 258.15033f,
751.97394f, 759.9737f, 318.1558f, 421.83197f, -61.399246f, 29.417673f, -41.625828f, 9.633194f,
-32.656918f, 0.661213f, -27.0007f, -4.99621f, -22.780836f, -9.216699f, -19.247105f, -12.750759f,
-15.998982f, -15.998974f, -12.750768f, -19.247095f, -9.21671f, -22.780825f, -4.996224f, -27.000687f,
0.66119397f, -32.6569f, 9.633162f, -41.625797f, 29.417591f, -61.399162f, 417.83167f, 322.15536f,
879.97015f, 887.97f, 382.16083f, 485.82516f, -61.397934f, 29.418983f, -41.62531f, 9.633721f,
-32.656616f, 0.66151863f, -27.00048f, -4.995991f, -22.78066f, -9.216522f, -19.246956f, -12.750604f,
-15.998837f, -15.998828f, -12.750612f, -19.246946f, -9.216533f, -22.780651f, -4.996005f, -27.000465f,
0.6614996f, -32.656597f, 9.633688f, -41.625275f, 29.418901f, -61.397854f, 481.82483f, 386.1604f});
test_case.run_with_tolerance_as_fp(1e-3f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_no_onesided_dynamic_last_dim_real_input) {
auto model = convert_model("stft_no_onesided_dynamic_last_dim.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{2, 32, 1};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<float>(Shape{16}, stft_window_16);
test_case.add_expected_output<float>(
Shape{2, 3, 16, 2},
{55.996273f, 0.0f, 23.999105f, 24.93398f, -7.9986897f, 22.70421f, -7.999476f, 12.81474f,
-7.9996943f, 8.329527f, -7.999781f, 5.5011215f, -7.999825f, 3.3910282f, -7.999848f, 1.624075f,
-7.999855f, 0.0f, -7.999848f, -1.624075f, -7.999825f, -3.3910282f, -7.999781f, -5.5011215f,
-7.9996943f, -8.329527f, -7.999476f, -12.81474f, -7.9986897f, -22.70421f, 23.999105f, -24.93398f,
119.99441f, 0.0f, 55.998657f, 24.931015f, -7.9980345f, 22.70421f, -7.999214f, 12.814741f,
-7.9995418f, 8.329527f, -7.9996715f, 5.501121f, -7.9997373f, 3.391029f, -7.999772f, 1.6240768f,
-7.999782f, 0.0f, -7.999772f, -1.6240768f, -7.9997373f, -3.391029f, -7.9996715f, -5.501121f,
-7.9995418f, -8.329527f, -7.999214f, -12.814741f, -7.9980345f, -22.70421f, 55.998657f, -24.931015f,
183.99254f, 0.0f, 87.99821f, 24.92805f, -7.9973793f, 22.70421f, -7.998952f, 12.814743f,
-7.999389f, 8.329528f, -7.9995613f, 5.5011206f, -7.9996495f, 3.3910296f, -7.999696f, 1.6240786f,
-7.9997096f, 0.0f, -7.999696f, -1.6240786f, -7.9996495f, -3.3910296f, -7.9995613f, -5.5011206f,
-7.999389f, -8.329528f, -7.998952f, -12.814743f, -7.9973793f, -22.70421f, 87.99821f, -24.92805f,
311.98883f, 0.0f, 151.99731f, 24.922117f, -7.996069f, 22.70421f, -7.9984283f, 12.814746f,
-7.999084f, 8.329528f, -7.999341f, 5.5011196f, -7.999474f, 3.3910308f, -7.999544f, 1.6240822f,
-7.999564f, 0.0f, -7.999544f, -1.6240822f, -7.999474f, -3.3910308f, -7.999341f, -5.5011196f,
-7.999084f, -8.329528f, -7.9984283f, -12.814746f, -7.996069f, -22.70421f, 151.99731f, -24.922117f,
375.98697f, 0.0f, 183.99687f, 24.919151f, -7.995414f, 22.704208f, -7.9981666f, 12.814748f,
-7.9989314f, 8.329528f, -7.9992313f, 5.501119f, -7.9993863f, 3.3910315f, -7.9994683f, 1.624084f,
-7.999491f, 0.0f, -7.9994683f, -1.624084f, -7.9993863f, -3.3910315f, -7.9992313f, -5.501119f,
-7.9989314f, -8.329528f, -7.9981666f, -12.814748f, -7.995414f, -22.704208f, 183.99687f, -24.919151f,
439.98508f, 0.0f, 215.99641f, 24.916185f, -7.9947586f, 22.704208f, -7.997905f, 12.814749f,
-7.998779f, 8.329529f, -7.999121f, 5.5011187f, -7.9992986f, 3.391032f, -7.999392f, 1.6240858f,
-7.9994187f, 0.0f, -7.999392f, -1.6240858f, -7.9992986f, -3.391032f, -7.999121f, -5.5011187f,
-7.998779f, -8.329529f, -7.997905f, -12.814749f, -7.9947586f, -22.704208f, 215.99641f, -24.916185f});
test_case.run_with_tolerance_as_fp(1e-3f);
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_proper_exception_if_non_scalar_frame_length) {
try {
convert_model("stft_non_const_frame_length.onnx");
FAIL() << "Unknown error during STFT import";
} catch (const std::runtime_error& exc) {
std::string msg{exc.what()};
EXPECT_TRUE(msg.find("frame_length input must be a scalar or Shape{1}.") != std::string::npos);
}
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_proper_exception_if_float_frame_step) {
OV_EXPECT_THROW(convert_model("stft_float_frame_step.onnx"),
ov::Exception,
testing::HasSubstr("frame_step input must be of integer type."));
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_proper_exception_if_float_frame_length) {
OV_EXPECT_THROW(convert_model("stft_float_frame_length.onnx"),
ov::Exception,
testing::HasSubstr("frame_length input must be of integer type."));
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_runtime_frame_length_with_window) {
auto model = convert_model("stft_runtime_frame_length_with_window.onnx");
auto test_case = ov::test::TestCase(model, s_device);
const Shape signal_shape{2, 32, 1};
std::vector<float> signal(ov::shape_size(signal_shape));
std::iota(std::begin(signal), std::end(signal), 0.f);
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<int64_t>(Shape{}, {8});
test_case.add_input<float>(Shape{16}, stft_window_16);
test_case.add_input<int64_t>(Shape{}, {16});
test_case.add_expected_output<float>(Shape{2, 3, 9, 2}, stft_window_16_expected);
test_case.run_with_tolerance_as_fp(1e-3f);
// ONNX requires window length == frame_length
test_case.add_input<float>(signal_shape, signal);
test_case.add_input<int64_t>(Shape{}, {8});
test_case.add_input<float>(Shape{16}, stft_window_16);
test_case.add_input<int64_t>(Shape{}, {32});
EXPECT_ANY_THROW(test_case.run());
}
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_stft_proper_exception_if_complex_signal_and_onesided) {
try {
convert_model("stft_onesided_complex_input.onnx");
FAIL() << "Unknown error during STFT import";
} catch (const std::runtime_error& exc) {
std::string msg{exc.what()};
EXPECT_TRUE(msg.find("If attribute onesided==1, signal input can NOT be complex.") != std::string::npos);
}
}