aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Goncalves <bruno.slackware@gmail.com>2018-12-27 16:15:38 -0200
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-02-07 08:52:40 +0000
commit8f29338c37c59a8bd00f0a545afa8cb69a0e9dbd (patch)
tree545ec2d2ce6ebf088f82d5fe42b320e96755029b
parent7205fed8ae4d6f85b350f3612cc43ee7e25176a7 (diff)
downloadarmnn-8f29338c37c59a8bd00f0a545afa8cb69a0e9dbd.tar.gz
Added TfLiteParser test for ResNetV2
Change-Id: If45696594503cd093c7d5f3b5001b20e9bb2e573
-rw-r--r--tests/CMakeLists.txt6
-rw-r--r--tests/TfLiteResNetV2-Armnn/TfLiteResNetV2-Armnn.cpp59
2 files changed, 65 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b8aa4fc16c..352c358fd5 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -188,6 +188,12 @@ if (BUILD_TF_LITE_PARSER)
ImagePreprocessor.hpp
ImagePreprocessor.cpp)
TfLiteParserTest(TfLiteInceptionV3Quantized-Armnn "${TfLiteInceptionV3Quantized-Armnn_sources}")
+
+ set(TfLiteResNetV2-Armnn_sources
+ TfLiteResNetV2-Armnn/TfLiteResNetV2-Armnn.cpp
+ ImagePreprocessor.hpp
+ ImagePreprocessor.cpp)
+ TfLiteParserTest(TfLiteResNetV2-Armnn "${TfLiteResNetV2-Armnn_sources}")
endif()
if (BUILD_ONNX_PARSER)
diff --git a/tests/TfLiteResNetV2-Armnn/TfLiteResNetV2-Armnn.cpp b/tests/TfLiteResNetV2-Armnn/TfLiteResNetV2-Armnn.cpp
new file mode 100644
index 0000000000..36fc72cdf4
--- /dev/null
+++ b/tests/TfLiteResNetV2-Armnn/TfLiteResNetV2-Armnn.cpp
@@ -0,0 +1,59 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#include "../InferenceTest.hpp"
+#include "../ImagePreprocessor.hpp"
+#include "armnnTfLiteParser/ITfLiteParser.hpp"
+
+using namespace armnnTfLiteParser;
+
+int main(int argc, char* argv[])
+{
+ int retVal = EXIT_FAILURE;
+ try
+ {
+ // Coverity fix: The following code may throw an exception of type std::length_error.
+ std::vector<ImageSet> imageSet =
+ {
+ {"Dog.jpg", 209},
+ {"Cat.jpg", 283},
+ {"shark.jpg", 3},
+
+ };
+
+ armnn::TensorShape inputTensorShape({ 1, 299, 299, 3 });
+
+ using DataType = float;
+ using DatabaseType = ImagePreprocessor<DataType>;
+ using ParserType = armnnTfLiteParser::ITfLiteParser;
+ using ModelType = InferenceModel<ParserType, DataType>;
+
+ // Coverity fix: ClassifierInferenceTestMain() may throw uncaught exceptions.
+ retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType,
+ ParserType>(
+ argc, argv,
+ "resnet_v2_101_299.tflite", // model name
+ true, // model is binary
+ "input", // input tensor name
+ "output", // output tensor name
+ { 0, 1, 2 }, // test images to test with as above
+ [&imageSet](const char* dataDir, const ModelType & model) {
+ return DatabaseType(
+ dataDir,
+ 299,
+ 299,
+ imageSet);
+ },
+ &inputTensorShape);
+ }
+ catch (const std::exception& e)
+ {
+ // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
+ // exception of type std::length_error.
+ // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
+ std::cerr << "WARNING: " << *argv << ": An error has occurred when running "
+ "the classifier inference tests: " << e.what() << std::endl;
+ }
+ return retVal;
+}