aboutsummaryrefslogtreecommitdiff
path: root/src/armnnTfLiteParser/test
diff options
context:
space:
mode:
authorBruno Goncalves <882745+brunomorishita@users.noreply.github.com>2018-12-18 12:56:22 -0200
committerMatthew Bentham <matthew.bentham@arm.com>2019-01-17 13:05:47 +0000
commitd4ac6a41fc71b82267ef17d4fb87584226bf64c4 (patch)
treeb18882d239fa7f370cbb4f640d9b82afd53ddf9a /src/armnnTfLiteParser/test
parentb89b05f048a566a8c825f1d223966bc5a6abc3d5 (diff)
downloadarmnn-d4ac6a41fc71b82267ef17d4fb87584226bf64c4.tar.gz
Added ParseAdd method to TfLiteParser
Change-Id: I24d916eca8ef1efb70d08b5c4f5123bb56a76c3e
Diffstat (limited to 'src/armnnTfLiteParser/test')
-rw-r--r--src/armnnTfLiteParser/test/Addition.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/armnnTfLiteParser/test/Addition.cpp b/src/armnnTfLiteParser/test/Addition.cpp
new file mode 100644
index 0000000000..53a0c40337
--- /dev/null
+++ b/src/armnnTfLiteParser/test/Addition.cpp
@@ -0,0 +1,107 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include <boost/test/unit_test.hpp>
+#include "ParserFlatbuffersFixture.hpp"
+#include "../TfLiteParser.hpp"
+
+#include <string>
+#include <iostream>
+
+BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
+
+struct AddFixture : public ParserFlatbuffersFixture
+{
+ explicit AddFixture(const std::string & inputShape1,
+ const std::string & inputShape2,
+ const std::string & outputShape,
+ const std::string & activation="NONE")
+ {
+ m_JsonString = R"(
+ {
+ "version": 3,
+ "operator_codes": [ { "builtin_code": "ADD" } ],
+ "subgraphs": [ {
+ "tensors": [
+ {
+ "shape": )" + inputShape1 + R"(,
+ "type": "UINT8",
+ "buffer": 0,
+ "name": "inputTensor1",
+ "quantization": {
+ "min": [ 0.0 ],
+ "max": [ 255.0 ],
+ "scale": [ 1.0 ],
+ "zero_point": [ 0 ],
+ }
+ },
+ {
+ "shape": )" + inputShape2 + R"(,
+ "type": "UINT8",
+ "buffer": 1,
+ "name": "inputTensor2",
+ "quantization": {
+ "min": [ 0.0 ],
+ "max": [ 255.0 ],
+ "scale": [ 1.0 ],
+ "zero_point": [ 0 ],
+ }
+ },
+ {
+ "shape": )" + outputShape + R"( ,
+ "type": "UINT8",
+ "buffer": 2,
+ "name": "outputTensor",
+ "quantization": {
+ "min": [ 0.0 ],
+ "max": [ 255.0 ],
+ "scale": [ 1.0 ],
+ "zero_point": [ 0 ],
+ }
+ }
+ ],
+ "inputs": [ 0, 1 ],
+ "outputs": [ 2 ],
+ "operators": [
+ {
+ "opcode_index": 0,
+ "inputs": [ 0, 1 ],
+ "outputs": [ 2 ],
+ "builtin_options_type": "AddOptions",
+ "builtin_options": {
+ "fused_activation_function": )" + activation + R"(
+ },
+ "custom_options_format": "FLEXBUFFERS"
+ }
+ ],
+ } ],
+ "buffers" : [
+ { },
+ { }
+ ]
+ }
+ )";
+ Setup();
+ }
+};
+
+
+struct SimpleAddFixture : AddFixture
+{
+ SimpleAddFixture() : AddFixture("[ 2, 2 ]",
+ "[ 2, 2 ]",
+ "[ 2, 2 ]") {}
+};
+
+BOOST_FIXTURE_TEST_CASE(SimpleAdd, SimpleAddFixture)
+{
+ RunTest<2, uint8_t>(0,
+ {{"inputTensor1", { 0, 1, 2, 3 }},
+ {"inputTensor2", { 4, 5, 6, 7 }}},
+ {{"outputTensor", { 4, 6, 8, 10 }}});
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+