summaryrefslogtreecommitdiff
path: root/tests/use_case/noise_reduction/InferenceTestRNNoise.cc
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2022-12-19 16:37:33 +0000
committerKshitij Sisodia <kshitij.sisodia@arm.com>2022-12-19 17:05:29 +0000
commit2ea46232a15aaf7600f1b92314612f4aa2fc6cd2 (patch)
tree7c05c514c3bbe932a067067b719d46ff16e5c2e7 /tests/use_case/noise_reduction/InferenceTestRNNoise.cc
parent9a97134ee00125c7a406cbf57c3ba8360df8f980 (diff)
downloadml-embedded-evaluation-kit-2ea46232a15aaf7600f1b92314612f4aa2fc6cd2.tar.gz
MLECO-3611: Formatting fixes for generated files.
Template files updated for generated files to adhere to coding guidelines and clang format configuration. There will still be unavoidable violations, but most of the others have been fixed. Change-Id: Ia03db40f8c62a369f2b07fe02eea65e41993a523 Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
Diffstat (limited to 'tests/use_case/noise_reduction/InferenceTestRNNoise.cc')
-rw-r--r--tests/use_case/noise_reduction/InferenceTestRNNoise.cc54
1 files changed, 25 insertions, 29 deletions
diff --git a/tests/use_case/noise_reduction/InferenceTestRNNoise.cc b/tests/use_case/noise_reduction/InferenceTestRNNoise.cc
index 3cdaee1..17ce9ac 100644
--- a/tests/use_case/noise_reduction/InferenceTestRNNoise.cc
+++ b/tests/use_case/noise_reduction/InferenceTestRNNoise.cc
@@ -1,6 +1,6 @@
/*
- * SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <open-source-office@arm.com>
- * SPDX-License-Identifier: Apache-2.0
+ * SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates
+ * <open-source-office@arm.com> SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "TensorFlowLiteMicro.hpp"
+#include "BufAttributes.hpp"
#include "RNNoiseModel.hpp"
+#include "TensorFlowLiteMicro.hpp"
#include "TestData_noise_reduction.hpp"
-#include "BufAttributes.hpp"
#include <catch.hpp>
#include <random>
@@ -50,15 +50,13 @@ namespace noise_reduction {
{
std::random_device rndDevice;
std::mt19937 mersenneGen{rndDevice()};
- std::uniform_int_distribution<short> dist {-128, 127};
+ std::uniform_int_distribution<short> dist{-128, 127};
- auto gen = [&dist, &mersenneGen](){
- return dist(mersenneGen);
- };
+ auto gen = [&dist, &mersenneGen]() { return dist(mersenneGen); };
std::vector<std::vector<int8_t>> randomInput{NUMBER_OF_IFM_FILES};
for (size_t i = 0; i < model.GetNumInputs(); ++i) {
- TfLiteTensor *inputTensor = model.GetInputTensor(i);
+ TfLiteTensor* inputTensor = model.GetInputTensor(i);
REQUIRE(inputTensor);
randomInput[i].resize(inputTensor->bytes);
std::generate(std::begin(randomInput[i]), std::end(randomInput[i]), gen);
@@ -82,8 +80,10 @@ namespace noise_reduction {
REQUIRE(RunInferenceRandom(model));
}
- template<typename T>
- void TestInference(const std::vector<std::vector<T>> input_goldenFV, const std::vector<std::vector<T>> output_goldenFV, arm::app::Model& model)
+ template <typename T>
+ void TestInference(const std::vector<std::vector<T>> input_goldenFV,
+ const std::vector<std::vector<T>> output_goldenFV,
+ arm::app::Model& model)
{
for (size_t i = 0; i < model.GetNumInputs(); ++i) {
TfLiteTensor* inputTensor = model.GetInputTensor(i);
@@ -93,41 +93,37 @@ namespace noise_reduction {
REQUIRE(RunInference(model, input_goldenFV));
for (size_t i = 0; i < model.GetNumOutputs(); ++i) {
- TfLiteTensor *outputTensor = model.GetOutputTensor(i);
+ TfLiteTensor* outputTensor = model.GetOutputTensor(i);
REQUIRE(outputTensor);
auto tensorData = tflite::GetTensorData<T>(outputTensor);
REQUIRE(tensorData);
for (size_t j = 0; j < outputTensor->bytes; j++) {
- REQUIRE(static_cast<int>(tensorData[j]) == static_cast<int>((output_goldenFV[i][j])));
+ REQUIRE(static_cast<int>(tensorData[j]) ==
+ static_cast<int>((output_goldenFV[i][j])));
}
}
}
TEST_CASE("Running inference with Tflu and RNNoise Int8", "[RNNoise]")
{
- std::vector<std::vector<int8_t>> goldenInputFV {NUMBER_OF_IFM_FILES};
- std::vector<std::vector<int8_t>> goldenOutputFV {NUMBER_OF_OFM_FILES};
+ std::vector<std::vector<int8_t>> goldenInputFV{NUMBER_OF_IFM_FILES};
+ std::vector<std::vector<int8_t>> goldenOutputFV{NUMBER_OF_OFM_FILES};
- std::array<size_t, NUMBER_OF_IFM_FILES> inputSizes = {IFM_0_DATA_SIZE,
- IFM_1_DATA_SIZE,
- IFM_2_DATA_SIZE,
- IFM_3_DATA_SIZE};
+ std::array<size_t, NUMBER_OF_IFM_FILES> inputSizes = {
+ IFM_0_DATA_SIZE, IFM_1_DATA_SIZE, IFM_2_DATA_SIZE, IFM_3_DATA_SIZE};
- std::array<size_t, NUMBER_OF_OFM_FILES> outputSizes = {OFM_0_DATA_SIZE,
- OFM_1_DATA_SIZE,
- OFM_2_DATA_SIZE,
- OFM_3_DATA_SIZE,
- OFM_4_DATA_SIZE};
+ std::array<size_t, NUMBER_OF_OFM_FILES> outputSizes = {
+ OFM_0_DATA_SIZE, OFM_1_DATA_SIZE, OFM_2_DATA_SIZE, OFM_3_DATA_SIZE, OFM_4_DATA_SIZE};
- for (uint32_t i = 0 ; i < NUMBER_OF_IFM_FILES; ++i) {
+ for (uint32_t i = 0; i < NUMBER_OF_IFM_FILES; ++i) {
goldenInputFV[i].resize(inputSizes[i]);
- std::memcpy(goldenInputFV[i].data(), get_ifm_data_array(i), inputSizes[i]);
+ std::memcpy(goldenInputFV[i].data(), GetIfmDataArray(i), inputSizes[i]);
}
- for (uint32_t i = 0 ; i < NUMBER_OF_OFM_FILES; ++i) {
+ for (uint32_t i = 0; i < NUMBER_OF_OFM_FILES; ++i) {
goldenOutputFV[i].resize(outputSizes[i]);
- std::memcpy(goldenOutputFV[i].data(), get_ofm_data_array(i), outputSizes[i]);
+ std::memcpy(goldenOutputFV[i].data(), GetOfmDataArray(i), outputSizes[i]);
}
DYNAMIC_SECTION("Executing inference with re-init")
@@ -146,4 +142,4 @@ namespace noise_reduction {
}
} /* namespace noise_reduction */
-} /* namespace test */
+} /* namespace test */