let window = Tensor::hann_window_periodic(N_FFT, true, (Kind::Float, Device::Cpu));
// This line panic
let stft_output = tensor.stft_center(
N_FFT,
HOP_LENGTH,
None,
Some(&window),
true,
"reflect",
false,
true,
false,
false,
);
thread 'tests::test_separate' (353755) panicked at ./.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tch-0.22.0/src/wrappers/tensor_generated.rs:18055:10:
called `Result::unwrap()` on an `Err` value: Torch("stft align_to_window should only be set when center = false.\nException raised from stft at /private/tmp/pytorch-20251113-4141-nqli3i/pytorch-v2.9.1/aten/src/ATen/native/SpectralOps.cpp:863 (most recent call first):\nframe #0: c10::Error::Error(c10::SourceLocation, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) + 56 (0x105746590 in libc10.dylib)\nframe #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, char const*) + 92 (0x105744548 in libc10.dylib)\nframe #2: at::native::stft(at::Tensor const&, long long, std::__1::optional<long long>, std::__1::optional<long long>, std::__1::optional<at::Tensor> const&, bool, std::__1::basic_string_view<char, std::__1::char_traits<char>>, bool, std::__1::optional<bool>, std::__1::optional<bool>, std::__1::optional<bool>) + 3180 (0x10f3e086c in libtorch_cpu.dylib)\nframe #3: at::_ops::stft_center::call(at::Tensor const&, long long, std::__1::optional<long long>, std::__1::optional<long long>, std::__1::optional<at::Tensor> const&, bool, std::__1::basic_string_view<char, std::__1::char_traits<char>>, bool, std::__1::optional<bool>, std::__1::optional<bool>, std::__1::optional<bool>) + 404 (0x10fb53c38 in libtorch_cpu.dylib)\nframe #4: at::stft(at::Tensor const&, long long, std::__1::optional<long long>, std::__1::optional<long long>, std::__1::optional<at::Tensor> const&, bool, std::__1::basic_string_view<char, std::__1::char_traits<char>>, bool, std::__1::optional<bool>, std::__1::optional<bool>, std::__1::optional<bool>) + 280 (0x10518eeb4 in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #5: atg_stft_center + 532 (0x10518ec54 in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #6: tch::wrappers::tensor_fallible_generated::_$LT$impl$u20$tch..wrappers..tensor..Tensor$GT$::f_stft_center::h3674b97593eccc6a + 724 (0x104f59738 in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #7: tch::wrappers::tensor_generated::_$LT$impl$u20$tch..wrappers..tensor..Tensor$GT$::stft_center::hd29307e7ad8c5c80 + 132 (0x104f59254 in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #8: uvr_mdxnet_kara_2::separate::hf6f31eb57b88e006 + 4900 (0x104f563d4 in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #9: uvr_mdxnet_kara_2::tests::test_separate::h14a0d41fbaac881e + 184 (0x104f62690 in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #10: uvr_mdxnet_kara_2::tests::test_separate::_$u7b$$u7b$closure$u7d$$u7d$::h28243a82a81e17df + 24 (0x104f5ff30 in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #11: core::ops::function::FnOnce::call_once::he36871a67e9a8885 + 20 (0x104f602bc in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #12: test::__rust_begin_short_backtrace::h93149138d9ae3a61 + 24 (0x104f7efbc in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #13: test::run_test::_$u7b$$u7b$closure$u7d$$u7d$::h487317312ee09dd0 + 748 (0x104f8f59c in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #14: std::sys::backtrace::__rust_begin_short_backtrace::h9e2ac0c09322548d + 132 (0x104f6e1d4 in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #15: core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h23882ec12939e9e6 + 124 (0x104f7113c in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #16: std::sys::thread::unix::Thread::new::thread_start::h96f5a914e64457ad + 52 (0x1051a1638 in uvr_mdxnet_kara_2-70570a508e3d29a7)\nframe #17: _pthread_start + 136 (0x18d5d9c08 in libsystem_pthread.dylib)\nframe #18: thread_start + 8 (0x18d5d4ba8 in libsystem_pthread.dylib)\n")
stack backtrace:
0: __rustc::rust_begin_unwind
at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/std/src/panicking.rs:698:5
1: core::panicking::panic_fmt
at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/panicking.rs:75:14
2: core::result::unwrap_failed
at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/result.rs:1855:5
3: core::result::Result<T,E>::unwrap
at /Users/danny/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:1226:23
4: tch::wrappers::tensor_generated::<impl tch::wrappers::tensor::Tensor>::stft_center
at /Users/danny/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tch-0.22.0/src/wrappers/tensor_generated.rs:18055:10
5: uvr_mdxnet_kara_2::separate
at ./src/lib.rs:159:44
6: uvr_mdxnet_kara_2::tests::test_separate
at ./src/lib.rs:207:9
7: uvr_mdxnet_kara_2::tests::test_separate::{{closure}}
at ./src/lib.rs:205:23
8: core::ops::function::FnOnce::call_once
at /Users/danny/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
9: core::ops::function::FnOnce::call_once
at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
The line above panic, which is due to
Torch("stft align_to_window should only be set when center = false.). However, there is no way to omit thealign_to_window, since it only accepts bool type. Even if I setalign_to_windowto false, the error still exits. Consider refactoring the function to acceptOption<bool>foralign_to_windowand change the passing logic to the underlying libtorch library.The full panic log is shown below: