summaryrefslogtreecommitdiff
path: root/tests/use_case
diff options
context:
space:
mode:
authorLiam Barry <liam.barry@arm.com>2023-09-27 12:48:35 +0100
committerNina Drozd <nina.drozd@arm.com>2023-10-04 09:35:11 +0100
commitf30d7413b2ba6625dc0f86ca540694a2a349dd54 (patch)
tree4338d35657fb29093f51bc0c9ad7cc3ed7f68f3b /tests/use_case
parent9263b519eef9aea86dcd795b16acd1ae53e19b9c (diff)
downloadml-embedded-evaluation-kit-f30d7413b2ba6625dc0f86ca540694a2a349dd54.tar.gz
MLECO-4365: Add CI Test for insufficient tensor arena and update common tests.
Previously, execution path following failed tensor allocation was not covered by tests. Minor amendment added to make ~Model virtual. During testing it was noticed that intentional errors simulated in certain common tests would result in misleading output for subsequent tests as the error messages appear in the console output of the next failing test. Documentation and print statements added until a solution is found. Change-Id: Iaf3e0f32ce9e0505921251cd41f73030108d2cb1 Signed-off-by: Liam Barry <liam.barry@arm.com>
Diffstat (limited to 'tests/use_case')
-rw-r--r--tests/use_case/inference_runner/InferenceRunnerTests.cc18
-rw-r--r--tests/use_case/inference_runner/InferenceTestInferenceRunner.cc50
2 files changed, 68 insertions, 0 deletions
diff --git a/tests/use_case/inference_runner/InferenceRunnerTests.cc b/tests/use_case/inference_runner/InferenceRunnerTests.cc
new file mode 100644
index 0000000..400bd9c
--- /dev/null
+++ b/tests/use_case/inference_runner/InferenceRunnerTests.cc
@@ -0,0 +1,18 @@
+/*
+ * SPDX-FileCopyrightText: Copyright 2023 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.
+ * 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.
+ */
+#define CATCH_CONFIG_MAIN
+#include <catch.hpp>
diff --git a/tests/use_case/inference_runner/InferenceTestInferenceRunner.cc b/tests/use_case/inference_runner/InferenceTestInferenceRunner.cc
new file mode 100644
index 0000000..7988ae1
--- /dev/null
+++ b/tests/use_case/inference_runner/InferenceTestInferenceRunner.cc
@@ -0,0 +1,50 @@
+/*
+ * SPDX-FileCopyrightText: Copyright 2023 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.
+ * 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 "BufAttributes.hpp"
+#include "TensorFlowLiteMicro.hpp"
+#include "TestModel.hpp" /* Model class for running inference. */
+
+#include <catch.hpp>
+#include <random>
+
+namespace arm {
+namespace app {
+ static uint8_t tensorArena[ACTIVATION_BUF_SZ] ACTIVATION_BUF_ATTRIBUTE;
+ namespace inference_runner {
+ extern uint8_t* GetModelPointer();
+ extern size_t GetModelLen();
+ } /* namespace inference_runner */
+} /* namespace app */
+} /* namespace arm */
+
+TEST_CASE("Testing Init failure due to insufficient tensor arena inf runner", "[inf runner]")
+{
+ /* Note: Errors or warnings generated by this test will appear in output of any subsequent
+ * failing tests causing misleading output. Give warning until solution is found */
+ printf("Insufficient tensor arena test output:\n");
+ arm::app::TestModel model{};
+ REQUIRE_FALSE(model.IsInited());
+ size_t insufficientTensorArenaSz = 1000;
+ REQUIRE_FALSE(model.Init(arm::app::tensorArena,
+ insufficientTensorArenaSz,
+ arm::app::inference_runner::GetModelPointer(),
+ arm::app::inference_runner::GetModelLen()));
+
+ printf("End of insufficient tensor arena test output. \nERROR messages above this line are "
+ "expected and can be ignored.\n\n");
+ REQUIRE_FALSE(model.IsInited());
+}