Opensource ML embedded evaluation kit

Change-Id: I12e807f19f5cacad7cef82572b6dd48252fd61fd
diff --git a/scripts/py/templates/AudioClips.cc.template b/scripts/py/templates/AudioClips.cc.template
new file mode 100644
index 0000000..edf46bc
--- /dev/null
+++ b/scripts/py/templates/AudioClips.cc.template
@@ -0,0 +1,62 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#include "InputFiles.hpp"
+
+static const char *audio_clip_filenames[] = {
+{% for name in clip_names %}
+    "{{name}}",
+{% endfor %}
+};
+
+static const int16_t *audio_clip_arrays[] = {
+    {{ var_names|join(',\n\t') }}
+};
+
+
+static const size_t audio_clip_sizes[NUMBER_OF_FILES] = {
+    {{ clip_sizes|join(',\n\t') }}
+};
+
+
+const char* get_filename(const uint32_t idx)
+{
+    if (idx < NUMBER_OF_FILES) {
+        return audio_clip_filenames[idx];
+    }
+    return nullptr;
+}
+
+
+const int16_t* get_audio_array(const uint32_t idx)
+{
+    if (idx < NUMBER_OF_FILES) {
+        return audio_clip_arrays[idx];
+    }
+    return nullptr;
+}
+
+
+uint32_t get_audio_array_size(const uint32_t idx)
+{
+    if (idx < NUMBER_OF_FILES) {
+        return audio_clip_sizes[idx];
+    }
+    return 0;
+}
+
diff --git a/scripts/py/templates/AudioClips.hpp.template b/scripts/py/templates/AudioClips.hpp.template
new file mode 100644
index 0000000..eb0beda
--- /dev/null
+++ b/scripts/py/templates/AudioClips.hpp.template
@@ -0,0 +1,34 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#ifndef GENERATED_AUDIOCLIPS_H
+#define GENERATED_AUDIOCLIPS_H
+
+#include <cstdint>
+#include <stddef.h>
+
+#define NUMBER_OF_FILES  ({{clips_count}}U)
+{% for var_name, size in varname_size %}
+extern const int16_t {{var_name}}[{{size}}];
+{% endfor %}
+
+const char* get_filename(const uint32_t idx);
+const int16_t* get_audio_array(const uint32_t idx);
+uint32_t get_audio_array_size(const uint32_t idx);
+
+#endif /* GENERATED_AUDIOCLIPS_H */
diff --git a/scripts/py/templates/Images.cc.template b/scripts/py/templates/Images.cc.template
new file mode 100644
index 0000000..6e86f98
--- /dev/null
+++ b/scripts/py/templates/Images.cc.template
@@ -0,0 +1,47 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#include "InputFiles.hpp"
+
+static const char *img_filenames[] = {
+{% for name in img_names %}
+    "{{name}}",
+{% endfor %}
+};
+
+static const uint8_t *img_arrays[] = {
+    {{ var_names|join(',\n\t') }}
+};
+
+const char* get_filename(const uint32_t idx)
+{
+    if (idx < NUMBER_OF_FILES) {
+        return img_filenames[idx];
+    }
+    return nullptr;
+}
+
+
+const uint8_t* get_img_array(const uint32_t idx)
+{
+    if (idx < NUMBER_OF_FILES) {
+        return img_arrays[idx];
+    }
+    return nullptr;
+}
+
diff --git a/scripts/py/templates/Images.hpp.template b/scripts/py/templates/Images.hpp.template
new file mode 100644
index 0000000..89ce39e
--- /dev/null
+++ b/scripts/py/templates/Images.hpp.template
@@ -0,0 +1,34 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#ifndef GENERATED_IMAGES_H
+#define GENERATED_IMAGES_H
+
+#include <cstdint>
+
+#define NUMBER_OF_FILES  ({{imgs_count}}U)
+#define IMAGE_DATA_SIZE  ({{img_size}}U)
+
+{% for var_name in var_names %}
+extern const uint8_t {{var_name}}[IMAGE_DATA_SIZE];
+{% endfor %}
+
+const char* get_filename(const uint32_t idx);
+const uint8_t* get_img_array(const uint32_t idx);
+
+#endif /* GENERATED_IMAGES_H */
diff --git a/scripts/py/templates/Labels.cc.template b/scripts/py/templates/Labels.cc.template
new file mode 100644
index 0000000..f1ec1b5
--- /dev/null
+++ b/scripts/py/templates/Labels.cc.template
@@ -0,0 +1,54 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#include "BufAttributes.hpp"
+
+#include <vector>
+#include <string>
+
+{% for namespace in namespaces %}
+namespace {{namespace}} {
+{% endfor %}
+
+static const char * labelsVec[] LABELS_ATTRIBUTE = {
+{% for label in labels %}
+    "{{label}}",
+{% endfor %}
+};
+
+bool GetLabelsVector(std::vector<std::string>& labels)
+{
+    constexpr size_t labelsSz = {{labelsSize}};
+    labels.clear();
+
+    if (!labelsSz) {
+        return false;
+    }
+
+    labels.reserve(labelsSz);
+
+    for (size_t i = 0; i < labelsSz; ++i) {
+        labels.emplace_back(labelsVec[i]);
+    }
+
+    return true;
+}
+
+{% for namespace in namespaces %}
+} /* namespace {{name_space}} */
+{% endfor %}
diff --git a/scripts/py/templates/Labels.hpp.template b/scripts/py/templates/Labels.hpp.template
new file mode 100644
index 0000000..c16a983
--- /dev/null
+++ b/scripts/py/templates/Labels.hpp.template
@@ -0,0 +1,41 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#ifndef {{filename}}_HPP
+#define {{filename}}_HPP
+
+#include <string>
+#include <vector>
+
+{% for namespace in namespaces %}
+namespace {{namespace}} {
+{% endfor %}
+
+/**
+ * @brief       Gets the label vector corresponding to the model
+ * @param[out]  labels   Vector of strings.
+ * @return      true if successful, false otherwise.
+ */
+extern bool GetLabelsVector(std::vector<std::string>& labels);
+
+
+{% for namespace in namespaces %}
+} /* namespace {{namespace}} */
+{% endfor %}
+
+#endif /* {{filename}}_HPP */
diff --git a/scripts/py/templates/TestData.cc.template b/scripts/py/templates/TestData.cc.template
new file mode 100644
index 0000000..1acd14d
--- /dev/null
+++ b/scripts/py/templates/TestData.cc.template
@@ -0,0 +1,51 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#include "{{include_h}}"
+
+{% for namespace in namespaces %}
+namespace {{namespace}} {
+{% endfor %}
+
+static const {{data_type}} *ifm_arrays[] = {
+    {{ ifm_var_names|join(',\n\t') }}
+};
+
+static const {{data_type}} *ofm_arrays[] = {
+    {{ ofm_var_names|join(',\n\t') }}
+};
+
+const {{data_type}}* get_ifm_data_array(const uint32_t idx)
+{
+    if (idx < NUMBER_OF_FM_FILES) {
+        return ifm_arrays[idx];
+    }
+    return nullptr;
+}
+
+const {{data_type}}* get_ofm_data_array(const uint32_t idx)
+{
+    if (idx < NUMBER_OF_FM_FILES) {
+        return ofm_arrays[idx];
+    }
+    return nullptr;
+}
+
+{% for namespace in namespaces %}
+} /* namespace {{namespace}} */
+{% endfor %}
diff --git a/scripts/py/templates/TestData.hpp.template b/scripts/py/templates/TestData.hpp.template
new file mode 100644
index 0000000..cdedd48
--- /dev/null
+++ b/scripts/py/templates/TestData.hpp.template
@@ -0,0 +1,47 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#ifndef GENERATED_TEST_DATA_H
+#define GENERATED_TEST_DATA_H
+
+#include <cstdint>
+
+{% for namespace in namespaces %}
+namespace {{namespace}} {
+{% endfor %}
+
+#define NUMBER_OF_FM_FILES  ({{fm_count}}U)
+#define IFM_DATA_SIZE  ({{ifm_var_size}}U)
+#define OFM_DATA_SIZE  ({{ofm_var_size}}U)
+
+{% for ifm_var_name in ifm_var_names %}
+extern const {{data_type}} {{ifm_var_name}}[IFM_DATA_SIZE];
+{% endfor %}
+
+{% for ofm_var_name in ofm_var_names %}
+extern const {{data_type}} {{ofm_var_name}}[OFM_DATA_SIZE];
+{% endfor %}
+
+const {{data_type}}* get_ifm_data_array(const uint32_t idx);
+const {{data_type}}* get_ofm_data_array(const uint32_t idx);
+
+{% for namespace in namespaces %}
+} /* namespace {{namespace}} */
+{% endfor %}
+
+#endif /* GENERATED_TEST_DATA_H */
diff --git a/scripts/py/templates/audio.cc.template b/scripts/py/templates/audio.cc.template
new file mode 100644
index 0000000..f1e29ef
--- /dev/null
+++ b/scripts/py/templates/audio.cc.template
@@ -0,0 +1,25 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#include "InputFiles.hpp"
+#include "BufAttributes.hpp"
+#include <cstdint>
+
+const int16_t {{var_name}} [{{size}}] IFM_BUF_ATTRIBUTE = {
+    {{audio_data|join(',\n\t')}}
+};
\ No newline at end of file
diff --git a/scripts/py/templates/default.hpp.template b/scripts/py/templates/default.hpp.template
new file mode 100644
index 0000000..acba891
--- /dev/null
+++ b/scripts/py/templates/default.hpp.template
@@ -0,0 +1,28 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#ifndef DEFAULT_GENERATED_INPUT_H
+#define DEFAULT_GENERATED_INPUT_H
+
+#include <cstdint>
+
+#define NUMBER_OF_FILES  (0U)
+
+const char* get_filename(const uint32_t idx);
+
+#endif /* DEFAULT_GENERATED_INPUT_H */
diff --git a/scripts/py/templates/header_template.txt b/scripts/py/templates/header_template.txt
new file mode 100644
index 0000000..0dac4be
--- /dev/null
+++ b/scripts/py/templates/header_template.txt
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) {{year}}, Arm Limited and affiliates.
+ * 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.
+ */
+
+/*********************    Autogenerated file. DO NOT EDIT *******************
+ * Generated from {{script_name}} tool {% if file_name %}and {{file_name}}{% endif %} file.
+ * Date: {{gen_time}}
+ ***************************************************************************/
diff --git a/scripts/py/templates/image.cc.template b/scripts/py/templates/image.cc.template
new file mode 100644
index 0000000..010daa1
--- /dev/null
+++ b/scripts/py/templates/image.cc.template
@@ -0,0 +1,25 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#include "InputFiles.hpp"
+#include "BufAttributes.hpp"
+#include <cstdint>
+
+const uint8_t {{var_name}}[] IFM_BUF_ATTRIBUTE = {
+    {{img_data|join(',\n\t')}}
+};
diff --git a/scripts/py/templates/testdata.cc.template b/scripts/py/templates/testdata.cc.template
new file mode 100644
index 0000000..e3c1dc6
--- /dev/null
+++ b/scripts/py/templates/testdata.cc.template
@@ -0,0 +1,33 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#include "{{include_h}}"
+#include "BufAttributes.hpp"
+#include <cstdint>
+
+{% for namespace in namespaces %}
+namespace {{namespace}} {
+{% endfor %}
+
+const {{data_type}} {{var_name}} [{{size}}] IFM_BUF_ATTRIBUTE = {
+    {{fm_data|join(',\n\t')}}
+};
+
+{% for namespace in namespaces %}
+} /* namespace {{namespace}} */
+{% endfor %}
diff --git a/scripts/py/templates/tflite.cc.template b/scripts/py/templates/tflite.cc.template
new file mode 100644
index 0000000..97bdec5
--- /dev/null
+++ b/scripts/py/templates/tflite.cc.template
@@ -0,0 +1,49 @@
+{#
+ 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
+
+     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.
+#}
+{{common_template_header}}
+
+#include "Model.hpp"
+{% for header in additional_headers %}
+#include "{{header}}"
+{% endfor %}
+
+{% for namespace in namespaces %}
+namespace {{namespace}} {
+{% endfor %}
+
+{% for expression in expressions %}
+{{expression}};
+{% endfor %}
+
+static const uint8_t nn_model[] MODEL_TFLITE_ATTRIBUTE =
+{% for model_hex_line in model_data %}
+{{model_hex_line}}
+{% endfor %}
+
+const uint8_t * GetModelPointer()
+{
+    return nn_model;
+}
+
+size_t GetModelLen()
+{
+    return sizeof(nn_model);
+}
+
+{% for namespace in namespaces %}
+} /* namespace {{namespace}} */
+{% endfor %}