aboutsummaryrefslogtreecommitdiff
path: root/src/armnnUtils/test/PrototxtConversionsTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnnUtils/test/PrototxtConversionsTest.cpp')
-rw-r--r--src/armnnUtils/test/PrototxtConversionsTest.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/armnnUtils/test/PrototxtConversionsTest.cpp b/src/armnnUtils/test/PrototxtConversionsTest.cpp
index e06fbe0f2e..f263a52340 100644
--- a/src/armnnUtils/test/PrototxtConversionsTest.cpp
+++ b/src/armnnUtils/test/PrototxtConversionsTest.cpp
@@ -4,6 +4,7 @@
//
#include <PrototxtConversions.hpp>
+#include "armnn/Tensor.hpp"
#include <boost/test/unit_test.hpp>
@@ -38,4 +39,100 @@ BOOST_AUTO_TEST_CASE(ConvertInt32ToOctalStringTest)
BOOST_ASSERT(octalString.compare("\\\\000\\\\000\\\\000\\\\377"));
}
+BOOST_AUTO_TEST_CASE(ConvertTensorShapeToStringTest)
+{
+ using armnnUtils::ConvertTensorShapeToString;
+ using armnn::TensorShape;
+
+ auto createAndConvert = [](std::initializer_list<unsigned int> dims) -> std::string
+ {
+ auto shape = TensorShape{dims};
+ return ConvertTensorShapeToString(shape);
+ };
+
+ auto output_string = createAndConvert({5});
+ BOOST_ASSERT(output_string.compare(
+ "dim {\n"
+ "size: 5\n"
+ "}"));
+
+ output_string = createAndConvert({4, 5});
+ BOOST_ASSERT(output_string.compare(
+ "dim {\n"
+ "size: 4\n"
+ "}\n"
+ "dim {\n"
+ "size: 5\n"
+ "}"
+ ));
+
+ output_string = createAndConvert({3, 4, 5});
+ BOOST_ASSERT(output_string.compare(
+ "dim {\n"
+ "size: 3\n"
+ "}\n"
+ "dim {\n"
+ "size: 4\n"
+ "}\n"
+ "dim {\n"
+ "size: 5\n"
+ "}"
+ ));
+
+ output_string = createAndConvert({2, 3, 4, 5});
+ BOOST_ASSERT(output_string.compare(
+ "dim {\n"
+ "size: 2\n"
+ "}\n"
+ "dim {\n"
+ "size: 3\n"
+ "}\n"
+ "dim {\n"
+ "size: 4\n"
+ "}\n"
+ "dim {\n"
+ "size: 5\n"
+ "}"
+ ));
+
+ output_string = createAndConvert({1, 2, 3, 4, 5});
+ BOOST_ASSERT(output_string.compare(
+ "dim {\n"
+ "size: 1\n"
+ "}\n"
+ "dim {\n"
+ "size: 2\n"
+ "}\n"
+ "dim {\n"
+ "size: 3\n"
+ "}\n"
+ "dim {\n"
+ "size: 4\n"
+ "}\n"
+ "dim {\n"
+ "size: 5\n"
+ "}"
+ ));
+
+ output_string = createAndConvert({0xffffffff, 0xffffffff});
+ BOOST_ASSERT(output_string.compare(
+ "dim {\n"
+ "size: 4294967295\n"
+ "}\n"
+ "dim {\n"
+ "size: 4294967295\n"
+ "}"
+ ));
+
+ output_string = createAndConvert({1, 0});
+ BOOST_ASSERT(output_string.compare(
+ "dim {\n"
+ "size: 1\n"
+ "}\n"
+ "dim {\n"
+ "size: 0\n"
+ "}"
+ ));
+}
+
BOOST_AUTO_TEST_SUITE_END()