aboutsummaryrefslogtreecommitdiff
path: root/src/armnnTfParser/test/Shape.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnnTfParser/test/Shape.cpp')
-rw-r--r--src/armnnTfParser/test/Shape.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/armnnTfParser/test/Shape.cpp b/src/armnnTfParser/test/Shape.cpp
new file mode 100644
index 0000000000..7b414ecfac
--- /dev/null
+++ b/src/armnnTfParser/test/Shape.cpp
@@ -0,0 +1,94 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// See LICENSE file in the project root for full license information.
+//
+
+#include <boost/test/unit_test.hpp>
+#include "armnnTfParser/ITfParser.hpp"
+#include "ParserPrototxtFixture.hpp"
+
+BOOST_AUTO_TEST_SUITE(TensorflowParser)
+
+struct ShapeFixture : public ParserPrototxtFixture<armnnTfParser::ITfParser>
+{
+ ShapeFixture()
+ {
+ m_Prototext =
+ "node { \n"
+ " name: \"Placeholder\" \n"
+ " op: \"Placeholder\" \n"
+ " attr { \n"
+ " key: \"dtype\" \n"
+ " value { \n"
+ " type: DT_FLOAT \n"
+ " } \n"
+ " } \n"
+ " attr { \n"
+ " key: \"shape\" \n"
+ " value { \n"
+ " shape { \n"
+ " dim { \n"
+ " size: 1 \n"
+ " } \n"
+ " dim { \n"
+ " size: 1 \n"
+ " } \n"
+ " dim { \n"
+ " size: 1 \n"
+ " } \n"
+ " dim { \n"
+ " size: 4 \n"
+ " } \n"
+ " } \n"
+ " } \n"
+ " } \n"
+ "} \n"
+ "node { \n"
+ " name: \"shapeTest\" \n"
+ " op: \"Shape\" \n"
+ " input: \"Placeholder\" \n"
+ " attr { \n"
+ " key: \"T\" \n"
+ " value { \n"
+ " type: DT_FLOAT \n"
+ " } \n"
+ " } \n"
+ " attr { \n"
+ " key: \"out_type\" \n"
+ " value { \n"
+ " type: DT_INT32 \n"
+ " } \n"
+ " } \n"
+ "} \n"
+ "node { \n"
+ " name: \"Reshape\" \n"
+ " op: \"Reshape\" \n"
+ " input: \"Placeholder\" \n"
+ " input: \"shapeTest\" \n"
+ " attr { \n"
+ " key: \"T\" \n"
+ " value { \n"
+ " type: DT_FLOAT \n"
+ " } \n"
+ " } \n"
+ " attr { \n"
+ " key: \"Tshape\" \n"
+ " value { \n"
+ " type: DT_INT32 \n"
+ " } \n"
+ " } \n"
+ "} \n";
+
+ SetupSingleInputSingleOutput({1, 4}, "Placeholder", "Reshape");
+ }
+};
+
+BOOST_FIXTURE_TEST_CASE(ParseShape, ShapeFixture)
+{
+ // Note: the test's output cannot be an int32 const layer, because that cannot exist in the
+ // as ARMNN only supports u8 and float layers. For that reason I added a reshape layer
+ // which reshapes the input to its original dimensions, which is not changing it.
+ RunTest<2>({ 0.0f, 1.0f, 2.0f, 3.0f }, { 0.0f, 1.0f, 2.0f, 3.0f });
+}
+
+BOOST_AUTO_TEST_SUITE_END()