aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Bentham <matthew.bentham@arm.com>2019-01-21 15:45:51 +0000
committerAron Virginas-Tar <Aron.Virginas-Tar@arm.com>2019-01-23 10:12:51 +0000
commit4057d91322738e446c0c2ce5f3a8cf665d935763 (patch)
tree352dff895fd187ed83d0448294505a76092c4bab
parent4951d84b1174a4bb0a5d9c900740f64201f765bf (diff)
downloadarmnn-4057d91322738e446c0c2ce5f3a8cf665d935763.tar.gz
IVGCVSW-2515 Fix compilation when TfParser is disabled
Change-Id: Ia0019134f76764cd4fe6ed9dc1423b8aba411d33
-rw-r--r--CMakeLists.txt10
-rw-r--r--src/armnnTfParser/test/Mean.cpp9
-rw-r--r--src/armnnUtils/ParserPrototxtFixture.hpp20
-rw-r--r--src/armnnUtils/PrototxtConversions.cpp32
-rw-r--r--src/armnnUtils/PrototxtConversions.hpp16
-rw-r--r--src/armnnUtils/test/PrototxtConversionsTest.cpp (renamed from src/armnnUtils/test/ParsePrototxtFixtureTest.cpp)11
6 files changed, 63 insertions, 35 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 682e2cf688..82f7d11c7a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,14 +48,12 @@ list(APPEND armnnUtils_sources
src/armnnUtils/VerificationHelpers.cpp
src/armnnUtils/ParserHelper.hpp
src/armnnUtils/ParserHelper.cpp
+ src/armnnUtils/ParserPrototxtFixture.hpp
+ src/armnnUtils/PrototxtConversions.hpp
+ src/armnnUtils/PrototxtConversions.cpp
src/armnnUtils/TensorUtils.hpp
src/armnnUtils/TensorUtils.cpp
)
-if(BUILD_TF_PARSER OR BUILD_CAFFE_PARSER)
- list(APPEND armnnUtils_sources
- src/armnnUtils/ParserPrototxtFixture.hpp
- )
-endif()
add_library_ex(armnnUtils STATIC ${armnnUtils_sources})
@@ -394,7 +392,7 @@ if(BUILD_UNIT_TESTS)
src/armnn/test/UnitTests.cpp
src/armnn/test/UnitTests.hpp
src/armnn/test/UtilsTests.cpp
- src/armnnUtils/test/ParsePrototxtFixtureTest.cpp
+ src/armnnUtils/test/PrototxtConversionsTest.cpp
src/armnnUtils/test/ParserHelperTest.cpp
)
diff --git a/src/armnnTfParser/test/Mean.cpp b/src/armnnTfParser/test/Mean.cpp
index 13041629b5..d73682961f 100644
--- a/src/armnnTfParser/test/Mean.cpp
+++ b/src/armnnTfParser/test/Mean.cpp
@@ -3,9 +3,12 @@
// SPDX-License-Identifier: MIT
//
-#include <boost/test/unit_test.hpp>
#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
+
+#include <ParserPrototxtFixture.hpp>
+#include <PrototxtConversions.hpp>
+
+#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(TensorflowParser)
@@ -29,7 +32,7 @@ struct MeanFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITf
for (unsigned int i = 0; i < protobufAxis.size(); ++i)
{
- protobufAxisString.append(ConvertInt32ToOctalString(static_cast<int>(protobufAxis[i])));
+ protobufAxisString.append(armnnUtils::ConvertInt32ToOctalString(static_cast<int>(protobufAxis[i])));
}
m_Prototext = R"(node {
diff --git a/src/armnnUtils/ParserPrototxtFixture.hpp b/src/armnnUtils/ParserPrototxtFixture.hpp
index 154f6bec2a..be35e460cf 100644
--- a/src/armnnUtils/ParserPrototxtFixture.hpp
+++ b/src/armnnUtils/ParserPrototxtFixture.hpp
@@ -9,8 +9,6 @@
#include <test/TensorHelpers.hpp>
-#include <armnnOnnxParser/IOnnxParser.hpp>
-
#include <Network.hpp>
#include <VerificationHelpers.hpp>
@@ -61,9 +59,6 @@ struct ParserPrototxtFixture
void RunTest(const std::map<std::string, std::vector<float>>& inputData,
const std::map<std::string, std::vector<float>>& expectedOutputData);
- /// Converts an int value into the Protobuf octal representation
- std::string ConvertInt32ToOctalString(int value);
-
std::string m_Prototext;
std::unique_ptr<TParser, void(*)(TParser* parser)> m_Parser;
armnn::IRuntimePtr m_Runtime;
@@ -253,19 +248,4 @@ void ParserPrototxtFixture<TParser>::RunTest(const std::map<std::string, std::ve
}
}
-template<typename TParser>
-std::string ParserPrototxtFixture<TParser>::ConvertInt32ToOctalString(int value)
-{
- std::stringstream ss;
- std::string returnString;
- for (int i = 0; i < 4; ++i)
- {
- ss << "\\";
- ss << std::setw(3) << std::setfill('0') << std::oct << ((value >> (i * 8)) & 0xFF);
- }
-
- ss >> returnString;
- return returnString;
-}
-
} // namespace armnnUtils
diff --git a/src/armnnUtils/PrototxtConversions.cpp b/src/armnnUtils/PrototxtConversions.cpp
new file mode 100644
index 0000000000..1a6c053355
--- /dev/null
+++ b/src/armnnUtils/PrototxtConversions.cpp
@@ -0,0 +1,32 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "PrototxtConversions.hpp"
+
+#include <boost/format.hpp>
+
+#include <iomanip>
+#include <sstream>
+#include <string>
+
+namespace armnnUtils
+{
+
+/// Converts an int value into the Prototxt octal representation
+std::string ConvertInt32ToOctalString(int value)
+{
+ std::stringstream ss;
+ std::string returnString;
+ for (int i = 0; i < 4; ++i)
+ {
+ ss << "\\";
+ ss << std::setw(3) << std::setfill('0') << std::oct << ((value >> (i * 8)) & 0xFF);
+ }
+
+ ss >> returnString;
+ return returnString;
+}
+
+} // namespace armnnUtils
diff --git a/src/armnnUtils/PrototxtConversions.hpp b/src/armnnUtils/PrototxtConversions.hpp
new file mode 100644
index 0000000000..c90af9edff
--- /dev/null
+++ b/src/armnnUtils/PrototxtConversions.hpp
@@ -0,0 +1,16 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <string>
+
+namespace armnnUtils
+{
+
+/// Converts an int value into the Prototxt octal representation
+std::string ConvertInt32ToOctalString(int value);
+
+} // namespace armnnUtils
diff --git a/src/armnnUtils/test/ParsePrototxtFixtureTest.cpp b/src/armnnUtils/test/PrototxtConversionsTest.cpp
index 926658ed0c..e06fbe0f2e 100644
--- a/src/armnnUtils/test/ParsePrototxtFixtureTest.cpp
+++ b/src/armnnUtils/test/PrototxtConversionsTest.cpp
@@ -3,17 +3,16 @@
// SPDX-License-Identifier: MIT
//
-#include <ParserPrototxtFixture.hpp>
+#include <PrototxtConversions.hpp>
#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-BOOST_AUTO_TEST_SUITE(ParsePrototxtFixtureSuite)
+BOOST_AUTO_TEST_SUITE(PrototxtConversions)
-using Fixture = armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>;
-
-BOOST_FIXTURE_TEST_CASE(ConvertInt32ToOctalStringTest, Fixture)
+BOOST_AUTO_TEST_CASE(ConvertInt32ToOctalStringTest)
{
+ using armnnUtils::ConvertInt32ToOctalString;
+
std::string octalString = ConvertInt32ToOctalString(1);
BOOST_ASSERT(octalString.compare("\\\\001\\\\000\\\\000\\\\000"));