aboutsummaryrefslogtreecommitdiff
path: root/applications/baremetal/main.cpp
diff options
context:
space:
mode:
authorAnton Moberg <anton.moberg@arm.com>2021-03-17 10:19:26 +0100
committerAnton Moberg <anton.moberg@arm.com>2021-03-18 10:00:04 +0100
commit456566daf2be5b34fd0659854d2807e8bc3b461b (patch)
tree17bbe8e2cf6ca6867236159fe9a7b23ffe876c1f /applications/baremetal/main.cpp
parentbd59c79d70d9cb2e8bd5fd4b13204cf6df6fcd62 (diff)
downloadethos-u-core-platform-456566daf2be5b34fd0659854d2807e8bc3b461b.tar.gz
Smaller networks - keyword_spotting_cnn_small_int8
Added: Baremetal folder for baremetal applications Added: Baremetal application 'keyword_spotting_cnn_small_int8' as an executable test. Run with ctest -R keyword_spotting_cnn_small_int8 Model taken from ML-zoo, run through vela, and hexdumped to C header format. Change-Id: I053d88a4319cb58020027d6007e83fd519a2af6e
Diffstat (limited to 'applications/baremetal/main.cpp')
-rw-r--r--applications/baremetal/main.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/applications/baremetal/main.cpp b/applications/baremetal/main.cpp
new file mode 100644
index 0000000..e1e01de
--- /dev/null
+++ b/applications/baremetal/main.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2021 Arm Limited. All rights reserved.
+ *
+ * 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
+ *
+ * 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.
+ */
+
+/****************************************************************************
+ * Includes
+ ****************************************************************************/
+
+// NPU driver
+#include "ethosu_driver.h"
+// Inference process
+#include "inference_process.hpp"
+// System includes
+#include <stdio.h>
+#include <vector>
+
+// Model data
+#include "input.h"
+#include "model.h"
+#include "output.h"
+
+using namespace std;
+
+/****************************************************************************
+ * InferenceJob
+ ****************************************************************************/
+
+#ifndef TENSOR_ARENA_SIZE
+#define TENSOR_ARENA_SIZE 2000000
+#endif
+
+__attribute__((section(".bss.tensor_arena"), aligned(16))) uint8_t TFLuTensorArena[TENSOR_ARENA_SIZE];
+
+InferenceProcess::InferenceProcess inferenceProcess(TFLuTensorArena, TENSOR_ARENA_SIZE);
+
+uint8_t outputData[176] __attribute__((aligned(16), section("output_data_sec")));
+
+int runInference() {
+ // Load inference data
+ vector<InferenceProcess::DataPtr> input;
+ input.push_back(InferenceProcess::DataPtr(inputData, sizeof(inputData)));
+
+ vector<InferenceProcess::DataPtr> output;
+ output.push_back(InferenceProcess::DataPtr(outputData, sizeof(outputData)));
+
+ vector<InferenceProcess::DataPtr> expected;
+ expected.push_back(InferenceProcess::DataPtr(expectedOutputData, sizeof(expectedOutputData)));
+
+ // Create job
+ InferenceProcess::InferenceJob job(string(modelName),
+ InferenceProcess::DataPtr(networkModelData, sizeof(networkModelData)),
+ input,
+ output,
+ expected,
+ 512,
+ std::vector<uint8_t>(4),
+ false);
+
+ // Run job
+ bool failed = inferenceProcess.runJob(job);
+ printf("Status of executed job: ");
+ printf(failed ? "Failed\n" : "Success\n");
+
+ return failed;
+}
+
+int main() {
+ int ret = runInference();
+ return ret;
+} \ No newline at end of file