From 5cbcd9e2c85485db1fe8cf7b2445550e9dc36800 Mon Sep 17 00:00:00 2001 From: Isabella Gottardi Date: Fri, 15 Oct 2021 10:17:33 +0100 Subject: MLECO-2423: [Fix] Case insensitive name clash * Fixed vww usage warnings (imageData in RunInferene and _GetImageIdx function) Change-Id: I2c37e4e4cc8c8eca841690f2df8d525ed516ecc8 --- scripts/py/gen_test_data_cpp.py | 2 +- scripts/py/templates/iofmdata.cc.template | 33 ++++++++++++++++++ scripts/py/templates/testdata.cc.template | 33 ------------------ .../vww/InferenceVisualWakeWordModelTests.cc | 39 ++++++---------------- 4 files changed, 45 insertions(+), 62 deletions(-) create mode 100644 scripts/py/templates/iofmdata.cc.template delete mode 100644 scripts/py/templates/testdata.cc.template diff --git a/scripts/py/gen_test_data_cpp.py b/scripts/py/gen_test_data_cpp.py index ea4bd6f..a58f415 100644 --- a/scripts/py/gen_test_data_cpp.py +++ b/scripts/py/gen_test_data_cpp.py @@ -85,7 +85,7 @@ def write_individual_cc_file(filename, cc_filename, header_filename, header_temp hex_line_generator = (', '.join(map(hex, sub_arr)) for sub_arr in np.array_split(fm_data, math.ceil(len(fm_data) / 20))) - env.get_template('testdata.cc.template').stream(common_template_header=hdr, + env.get_template('iofmdata.cc.template').stream(common_template_header=hdr, include_h=header_filename, var_name=array_name, fm_data=hex_line_generator, diff --git a/scripts/py/templates/iofmdata.cc.template b/scripts/py/templates/iofmdata.cc.template new file mode 100644 index 0000000..e3c1dc6 --- /dev/null +++ b/scripts/py/templates/iofmdata.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 + +{% 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/testdata.cc.template b/scripts/py/templates/testdata.cc.template deleted file mode 100644 index e3c1dc6..0000000 --- a/scripts/py/templates/testdata.cc.template +++ /dev/null @@ -1,33 +0,0 @@ -{# - 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 - -{% 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/tests/use_case/vww/InferenceVisualWakeWordModelTests.cc b/tests/use_case/vww/InferenceVisualWakeWordModelTests.cc index c109a62..3a42dde 100644 --- a/tests/use_case/vww/InferenceVisualWakeWordModelTests.cc +++ b/tests/use_case/vww/InferenceVisualWakeWordModelTests.cc @@ -15,21 +15,29 @@ * limitations under the License. */ -#include -#include #include "hal.h" -#include "InputFiles.hpp" #include "ImageUtils.hpp" #include "TestData_vww.hpp" #include "VisualWakeWordModel.hpp" #include "TensorFlowLiteMicro.hpp" +#include bool RunInference(arm::app::Model& model, const int8_t* imageData) { TfLiteTensor* inputTensor = model.GetInputTensor(0); REQUIRE(inputTensor); + const size_t copySz = inputTensor->bytes < IFM_DATA_SIZE ? + inputTensor->bytes : + IFM_DATA_SIZE; + + memcpy(inputTensor->data.data, imageData, copySz); + + if(model.IsDataSigned()){ + convertImgIoInt8(inputTensor->data.data, copySz); + } + return model.RunInference(); } @@ -54,28 +62,3 @@ void TestInference(int imageIdx,arm::app::Model& model) { CHECK(testVal == goldenVal); } } - - -/** - * @brief Given an image name, get its index - * @param[in] imageName Name of the image expected - * @return index of the image if valid and (-1) if not found - */ -static int _GetImageIdx(std::string &imageName) -{ - int imgIdx = -1; - for (uint32_t i = 0 ; i < NUMBER_OF_FILES; ++i) { - if (imageName == std::string(get_filename(i))) { - info("Image %s exists at index %u\n", get_filename(i), i); - imgIdx = static_cast(i); - break; - } - } - - if (-1 == imgIdx) { - warn("Image %s not found!\n", imageName.c_str()); - } - - return imgIdx; -} - -- cgit v1.2.1