You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_inversespectrogram.cpp 2.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Tencent is pleased to support the open source community by making ncnn available.
  2. //
  3. // Copyright (C) 2024 THL A29 Limited, a Tencent company. All rights reserved.
  4. //
  5. // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
  6. // in compliance with the License. You may obtain a copy of the License at
  7. //
  8. // https://opensource.org/licenses/BSD-3-Clause
  9. //
  10. // Unless required by applicable law or agreed to in writing, software distributed
  11. // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  12. // CONDITIONS OF ANY KIND, either express or implied. See the License for the
  13. // specific language governing permissions and limitations under the License.
  14. #include "testutil.h"
  15. static int test_inversespectrogram(int frames, int freqs, int n_fft, int returns, int hoplen, int winlen, int window_type, int center, int normalized)
  16. {
  17. ncnn::Mat a = RandomMat(2, frames, freqs);
  18. ncnn::ParamDict pd;
  19. pd.set(0, n_fft);
  20. pd.set(1, returns);
  21. pd.set(2, hoplen);
  22. pd.set(3, winlen);
  23. pd.set(4, window_type);
  24. pd.set(5, center);
  25. pd.set(7, normalized);
  26. std::vector<ncnn::Mat> weights(0);
  27. int ret = test_layer("InverseSpectrogram", pd, weights, a);
  28. if (ret != 0)
  29. {
  30. fprintf(stderr, "test_inversespectrogram failed frames=%d freqs=%d n_fft=%d returns=%d hoplen=%d winlen=%d window_type=%d center=%d normalized=%d\n", frames, freqs, n_fft, returns, hoplen, winlen, window_type, center, normalized);
  31. }
  32. return ret;
  33. }
  34. static int test_inversespectrogram_0()
  35. {
  36. return 0
  37. || test_inversespectrogram(17, 1, 1, 0, 1, 1, 0, 1, 0)
  38. || test_inversespectrogram(39, 9, 17, 0, 7, 15, 0, 0, 1)
  39. || test_inversespectrogram(128, 6, 10, 0, 2, 7, 1, 1, 1)
  40. || test_inversespectrogram(255, 17, 17, 1, 14, 17, 2, 0, 0)
  41. || test_inversespectrogram(124, 28, 55, 2, 12, 55, 1, 1, 2);
  42. }
  43. int main()
  44. {
  45. SRAND(7767517);
  46. return test_inversespectrogram_0();
  47. }