Guillaume Wenzek 1 год назад
Родитель
Сommit
f215d99664

+ 0 - 73
ggml/examples/kaldi-native-fbank/csrc/test-log.cc

@@ -1,73 +0,0 @@
-/**
- * Copyright      2022  Xiaomi Corporation (authors: Fangjun Kuang)
- *
- * See LICENSE for clarification regarding multiple authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gtest/gtest.h"
-#include "log.h"
-
-namespace knf {
-
-#if KNF_ENABLE_CHECK
-
-TEST(Log, TestLog) {
-  KNF_LOG(TRACE) << "this is a trace message";
-  KNF_LOG(DEBUG) << "this is a debug message";
-  KNF_LOG(INFO) << "this is an info message";
-  KNF_LOG(WARNING) << "this is a warning message";
-  KNF_LOG(ERROR) << "this is an error message";
-
-  ASSERT_THROW(KNF_LOG(FATAL) << "This will crash the program",
-               std::runtime_error);
-
-  // For debug build
-
-  KNF_DLOG(TRACE) << "this is a trace message for debug build";
-  KNF_DLOG(DEBUG) << "this is a trace message for debug build";
-  KNF_DLOG(INFO) << "this is a trace message for debug build";
-  KNF_DLOG(ERROR) << "this is an error message for debug build";
-  KNF_DLOG(WARNING) << "this is a trace message for debug build";
-
-#if !defined(NDEBUG)
-  ASSERT_THROW(KNF_DLOG(FATAL) << "this is a trace message for debug build",
-               std::runtime_error);
-#endif
-}
-
-TEST(Log, TestCheck) {
-  KNF_CHECK_EQ(1, 1) << "ok";
-  KNF_CHECK_LE(1, 3) << "ok";
-  KNF_CHECK_LT(1, 2) << "ok";
-  KNF_CHECK_GT(2, 1) << "ok";
-  KNF_CHECK_GE(2, 1) << "ok";
-
-  ASSERT_THROW(KNF_CHECK_EQ(2, 1) << "bad things happened", std::runtime_error);
-
-  // for debug build
-  KNF_DCHECK_EQ(1, 1) << "ok";
-  KNF_DCHECK_LE(1, 3) << "ok";
-  KNF_DCHECK_LT(1, 2) << "ok";
-  KNF_DCHECK_GT(2, 1) << "ok";
-  KNF_DCHECK_GE(2, 1) << "ok";
-
-#if !defined(NDEBUG)
-  ASSERT_THROW(KNF_CHECK_EQ(2, 1) << "bad things happened", std::runtime_error);
-#endif
-}
-
-#endif
-
-}  // namespace knf

+ 0 - 48
ggml/examples/kaldi-native-fbank/csrc/test-online-fbank.cc

@@ -1,48 +0,0 @@
-/**
- * Copyright (c)  2022  Xiaomi Corporation (authors: Fangjun Kuang)
- *
- * See LICENSE for clarification regarding multiple authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <iostream>
-
-#include "online-feature.h"
-
-int main() {
-  knf::FbankOptions opts;
-  opts.frame_opts.dither = 0;
-  opts.mel_opts.num_bins = 10;
-
-  knf::OnlineFbank fbank(opts);
-  for (int32_t i = 0; i < 1600; ++i) {
-    float s = (i * i - i / 2) / 32767.;
-    fbank.AcceptWaveform(16000, &s, 1);
-  }
-
-  std::ostringstream os;
-
-  int32_t n = fbank.NumFramesReady();
-  for (int32_t i = 0; i != n; ++i) {
-    const float *frame = fbank.GetFrame(i);
-    for (int32_t k = 0; k != opts.mel_opts.num_bins; ++k) {
-      os << frame[k] << ", ";
-    }
-    os << "\n";
-  }
-
-  std::cout << os.str() << "\n";
-
-  return 0;
-}

+ 0 - 59
ggml/examples/kaldi-native-fbank/csrc/test-online-feature.cc

@@ -1,59 +0,0 @@
-/**
- * Copyright (c)  2022  Xiaomi Corporation (authors: Fangjun Kuang)
- *
- * See LICENSE for clarification regarding multiple authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gtest/gtest.h"
-#include "online-feature.h"
-namespace knf {
-
-// TEST(RecyclingVector, TestUnlimited) {
-//   RecyclingVector v(-1);
-//   constexpr int32_t N = 100;
-//   for (int32_t i = 0; i != N; ++i) {
-//     std::unique_ptr<float[]> p(new float[3]{i, i + 1, i + 2});
-//     v.PushBack(std::move(p));
-//   }
-//   ASSERT_EQ(v.Size(), N);
-
-//   for (int32_t i = 0; i != N; ++i) {
-//     const float *t = v.At(i);
-//     for (int32_t k = 0; k != 3; ++k) {
-//       EXPECT_EQ(t[k], (i + k));
-//     }
-//   }
-// }
-
-// TEST(RecyclingVector, Testlimited) {
-//   constexpr int32_t K = 3;
-//   constexpr int32_t N = 10;
-//   RecyclingVector v(K);
-//   for (int32_t i = 0; i != N; ++i) {
-//     std::unique_ptr<float[]> p(new float[3]{i, i + 1, i + 2});
-//     v.PushBack(std::move(p));
-//   }
-
-//   ASSERT_EQ(v.Size(), N);
-
-//   for (int32_t i = N - K; i != N; ++i) {
-//     const float *t = v.At(i);
-
-//     for (int32_t k = 0; k != 3; ++k) {
-//       EXPECT_EQ(t[k], (i + k));
-//     }
-//   }
-// }
-}  // namespace knf

+ 0 - 52
ggml/examples/kaldi-native-fbank/csrc/test-rfft.cc

@@ -1,52 +0,0 @@
-/**
- * Copyright      2022  Xiaomi Corporation (authors: Fangjun Kuang)
- *
- * See LICENSE for clarification regarding multiple authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gtest/gtest.h"
-#include "rfft.h"
-
-namespace knf {
-
-#if 0
->>> import torch
->>> a = torch.tensor([1., -1, 3, 8, 20, 6, 0, 2])
->>> torch.fft.rfft(a)
-tensor([ 39.0000+0.0000j, -28.1924-2.2929j,  18.0000+5.0000j,  -9.8076+3.7071j,
-          9.0000+0.0000j])
-#endif
-
-TEST(Rfft, TestRfft) {
-  knf::Rfft fft(8);
-  for (int32_t i = 0; i != 10; ++i) {
-    std::vector<float> d = {1, -1, 3, 8, 20, 6, 0, 2};
-    fft.Compute(d.data());
-
-    EXPECT_EQ(d[0], 39);
-    EXPECT_EQ(d[1], 9);
-
-    EXPECT_NEAR(d[2], -28.1924, 1e-3);
-    EXPECT_NEAR(-d[3], -2.2929, 1e-3);
-
-    EXPECT_NEAR(d[4], 18, 1e-3);
-    EXPECT_NEAR(-d[5], 5, 1e-3);
-
-    EXPECT_NEAR(d[6], -9.8076, 1e-3);
-    EXPECT_NEAR(-d[7], 3.7071, 1e-3);
-  }
-}
-
-}  // namespace knf