aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrancis Murtagh <francis.murtagh@arm.com>2020-06-29 11:50:01 +0100
committerColm Donelan <colm.donelan@arm.com>2020-06-30 11:29:07 +0000
commit532a29d12d72f54549d8b71edd485c17af65698a (patch)
tree6748cc16706f52f413f7b2163a41d4807387cdf8 /src
parent3b90af6bb79639d3813f21f3c3017503ee0c66af (diff)
downloadarmnn-532a29d12d72f54549d8b71edd485c17af65698a.tar.gz
IVGCVSW-4487 Remove boost::filesystem
* Replace filesystem::path * Replace filesystem::exists * Replace filesystem::is_directory * Replace filesystem::directory_iterator * Replace filesystem::filesystem_error exception * Replace filesystem::temp_directory_path * Replace filesystem::unique path * Replace filesystem::ofstream with std::ofstream * Replace filesystem::remove * Replace filesystem::is_regular_file * Replace boost::optional with armnn::Optional in touched files * Remove some superfluous includes * Update build guides, GlobalConfig.cmake and CMakeLists.txt * Remove redundant armnnUtils::Filesystem::Remove function. * Remove redundant armnnUtils::Filesystem::GetFileSize function. Temporarily adding back Boost::filesystem to enable Boost::dll. Signed-off-by: Francis Murtagh <francis.murtagh@arm.com> Signed-off-by: Colm Donelan <Colm.Donelan@arm.com> Change-Id: Ifa46d4a0097d2612ddacd8e9736c0b36e365fb11
Diffstat (limited to 'src')
-rw-r--r--src/armnn/test/CsvReaderTest.cpp15
-rw-r--r--src/armnn/test/ModelAccuracyCheckerTest.cpp2
-rw-r--r--src/armnnDeserializer/Deserializer.cpp1
-rw-r--r--src/armnnQuantizer/CommandLineProcessor.cpp17
-rw-r--r--src/armnnQuantizer/QuantizationDataSet.cpp8
-rw-r--r--src/armnnQuantizer/test/QuantizationDataSetTests.cpp34
-rwxr-xr-xsrc/armnnTfLiteParser/CMakeLists.txt2
-rw-r--r--src/armnnTfLiteParser/TfLiteParser.cpp8
-rw-r--r--src/armnnTfLiteParser/test/LoadModel.cpp6
-rw-r--r--src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp1
-rw-r--r--src/armnnUtils/Filesystem.cpp53
-rw-r--r--src/armnnUtils/Filesystem.hpp5
-rw-r--r--src/armnnUtils/ModelAccuracyChecker.cpp1
-rw-r--r--src/backends/backendsCommon/DynamicBackendUtils.cpp13
-rw-r--r--src/backends/backendsCommon/test/DynamicBackendTests.hpp41
-rw-r--r--src/dynamic/README.md1
-rw-r--r--src/dynamic/sample/CMakeLists.txt2
-rw-r--r--src/profiling/test/FileOnlyProfilingDecoratorTests.cpp29
-rw-r--r--src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp10
-rw-r--r--src/timelineDecoder/CMakeLists.txt3
-rw-r--r--src/timelineDecoder/JSONTimelineDecoder.cpp3
-rw-r--r--src/timelineDecoder/JSONTimelineDecoder.hpp6
-rw-r--r--src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp8
23 files changed, 104 insertions, 165 deletions
diff --git a/src/armnn/test/CsvReaderTest.cpp b/src/armnn/test/CsvReaderTest.cpp
index 8491ad778d..96185c8408 100644
--- a/src/armnn/test/CsvReaderTest.cpp
+++ b/src/armnn/test/CsvReaderTest.cpp
@@ -3,13 +3,13 @@
// SPDX-License-Identifier: MIT
//
#include "CsvReader.hpp"
+#include "armnn/Optional.hpp"
+#include <Filesystem.hpp>
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <string>
-#include <boost/filesystem.hpp>
-#include <boost/optional.hpp>
using namespace armnnUtils;
@@ -29,11 +29,10 @@ struct TestHelper {
std::string CreateTempCsvFile()
{
- boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
- boost::filesystem::path p{fileDir / boost::filesystem::unique_path("%%%%-%%%%-%%%%.csv")};
+ fs::path p = armnnUtils::Filesystem::NamedTempFile("Armnn-CreateTempCsvFileTest-TempFile.csv");
try
{
- boost::filesystem::ofstream ofs{p};
+ std::ofstream ofs{p};
ofs << "airplane, bicycle , bird , \"m,o,n,k,e,y\"\n";
ofs << "banana, shoe, \"ice\"";
ofs.close();
@@ -63,17 +62,17 @@ struct TestHelper {
{
try
{
- boost::filesystem::remove(*m_CsvFile);
+ fs::remove(m_CsvFile.value());
}
catch (std::exception &e)
{
- std::cerr << "Unable to delete file [" << *m_CsvFile << "] : " << e.what() << std::endl;
+ std::cerr << "Unable to delete file [" << m_CsvFile.value() << "] : " << e.what() << std::endl;
BOOST_TEST(false);
}
}
}
- boost::optional<boost::filesystem::path> m_CsvFile;
+ armnn::Optional<fs::path> m_CsvFile;
};
}
diff --git a/src/armnn/test/ModelAccuracyCheckerTest.cpp b/src/armnn/test/ModelAccuracyCheckerTest.cpp
index 1bffa9c57c..c6c93edc3c 100644
--- a/src/armnn/test/ModelAccuracyCheckerTest.cpp
+++ b/src/armnn/test/ModelAccuracyCheckerTest.cpp
@@ -6,8 +6,6 @@
#include <boost/test/unit_test.hpp>
-#include <boost/filesystem.hpp>
-#include <boost/optional.hpp>
#include <boost/variant.hpp>
#include <iostream>
#include <string>
diff --git a/src/armnnDeserializer/Deserializer.cpp b/src/armnnDeserializer/Deserializer.cpp
index b9579d563d..f59c757f4b 100644
--- a/src/armnnDeserializer/Deserializer.cpp
+++ b/src/armnnDeserializer/Deserializer.cpp
@@ -19,7 +19,6 @@
#include <ParserHelper.hpp>
#include <VerificationHelpers.hpp>
-#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <boost/numeric/conversion/cast.hpp>
diff --git a/src/armnnQuantizer/CommandLineProcessor.cpp b/src/armnnQuantizer/CommandLineProcessor.cpp
index 0cccb66f63..ace4a506fb 100644
--- a/src/armnnQuantizer/CommandLineProcessor.cpp
+++ b/src/armnnQuantizer/CommandLineProcessor.cpp
@@ -4,12 +4,9 @@
//
#include "CommandLineProcessor.hpp"
-
-#define BOOST_FILESYSTEM_NO_DEPRECATED
+#include <Filesystem.hpp>
#include <boost/program_options.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
namespace armnnQuantizer
{
@@ -27,13 +24,13 @@ bool ValidateOutputDirectory(std::string& dir)
dir += "/";
}
- if (!boost::filesystem::exists(dir))
+ if (!fs::exists(dir))
{
std::cerr << "Output directory [" << dir << "] does not exist" << std::endl;
return false;
}
- if (!boost::filesystem::is_directory(dir))
+ if (!fs::is_directory(dir))
{
std::cerr << "Given output directory [" << dir << "] is not a directory" << std::endl;
return false;
@@ -44,13 +41,13 @@ bool ValidateOutputDirectory(std::string& dir)
bool ValidateProvidedFile(const std::string& inputFileName)
{
- if (!boost::filesystem::exists(inputFileName))
+ if (!fs::exists(inputFileName))
{
std::cerr << "Provided file [" << inputFileName << "] does not exist" << std::endl;
return false;
}
- if (boost::filesystem::is_directory(inputFileName))
+ if (fs::is_directory(inputFileName))
{
std::cerr << "Given file [" << inputFileName << "] is a directory" << std::endl;
return false;
@@ -154,7 +151,7 @@ bool CommandLineProcessor::ProcessCommandLine(int argc, char* argv[])
}
else
{
- boost::filesystem::path csvFilePath(m_CsvFileName);
+ fs::path csvFilePath(m_CsvFileName);
m_CsvFileDirectory = csvFilePath.parent_path().c_str();
}
@@ -170,7 +167,7 @@ bool CommandLineProcessor::ProcessCommandLine(int argc, char* argv[])
std::string output(m_OutputDirectory);
output.append(m_OutputFileName);
- if (boost::filesystem::exists(output))
+ if (fs::exists(output))
{
std::cerr << "Output file [" << output << "] already exists" << std::endl;
return false;
diff --git a/src/armnnQuantizer/QuantizationDataSet.cpp b/src/armnnQuantizer/QuantizationDataSet.cpp
index 7042d74d00..819b437a55 100644
--- a/src/armnnQuantizer/QuantizationDataSet.cpp
+++ b/src/armnnQuantizer/QuantizationDataSet.cpp
@@ -6,12 +6,8 @@
#include "QuantizationDataSet.hpp"
#include "CsvReader.hpp"
-#define BOOST_FILESYSTEM_NO_DEPRECATED
-
#include <armnn/utility/IgnoreUnused.hpp>
-
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
+#include <Filesystem.hpp>
namespace armnnQuantizer
{
@@ -105,7 +101,7 @@ std::string GetFileNameFromCsvRow(std::vector<armnnUtils::CsvRow> csvRows, unsig
{
std::string fileName = csvRows[rowIndex].values[2];
- if (!boost::filesystem::exists(fileName))
+ if (!fs::exists(fileName))
{
throw armnn::ParseException("File [ " + fileName + "] provided on CSV row " + std::to_string(rowIndex) +
" does not exist.");
diff --git a/src/armnnQuantizer/test/QuantizationDataSetTests.cpp b/src/armnnQuantizer/test/QuantizationDataSetTests.cpp
index 2b46aae26e..9e71f68e53 100644
--- a/src/armnnQuantizer/test/QuantizationDataSetTests.cpp
+++ b/src/armnnQuantizer/test/QuantizationDataSetTests.cpp
@@ -6,18 +6,14 @@
#include <boost/test/unit_test.hpp>
#include "../QuantizationDataSet.hpp"
+
+#include <armnn/Optional.hpp>
+#include <Filesystem.hpp>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
-#define BOOST_FILESYSTEM_NO_DEPRECATED
-
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/fstream.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/optional/optional.hpp>
-
using namespace armnnQuantizer;
@@ -36,20 +32,20 @@ struct CsvTestHelper {
std::string CreateTempCsvFile(std::map<int, std::vector<float>> csvData)
{
- boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
- boost::filesystem::path p{fileDir / boost::filesystem::unique_path("%%%%-%%%%-%%%%.csv")};
+ fs::path fileDir = fs::temp_directory_path();
+ fs::path p = armnnUtils::Filesystem::NamedTempFile("Armnn-QuantizationCreateTempCsvFileTest-TempFile.csv");
- boost::filesystem::path tensorInput1{fileDir / boost::filesystem::unique_path("input_0_0.raw")};
- boost::filesystem::path tensorInput2{fileDir / boost::filesystem::unique_path("input_1_0.raw")};
- boost::filesystem::path tensorInput3{fileDir / boost::filesystem::unique_path("input_2_0.raw")};
+ fs::path tensorInput1{fileDir / "input_0_0.raw"};
+ fs::path tensorInput2{fileDir / "input_1_0.raw"};
+ fs::path tensorInput3{fileDir / "input_2_0.raw"};
try
{
- boost::filesystem::ofstream ofs{p};
+ std::ofstream ofs{p};
- boost::filesystem::ofstream ofs1{tensorInput1};
- boost::filesystem::ofstream ofs2{tensorInput2};
- boost::filesystem::ofstream ofs3{tensorInput3};
+ std::ofstream ofs1{tensorInput1};
+ std::ofstream ofs2{tensorInput2};
+ std::ofstream ofs3{tensorInput3};
for(auto entry : csvData.at(0))
@@ -95,17 +91,17 @@ struct CsvTestHelper {
{
try
{
- boost::filesystem::remove(*m_CsvFile);
+ fs::remove(m_CsvFile.value());
}
catch (std::exception &e)
{
- std::cerr << "Unable to delete file [" << *m_CsvFile << "] : " << e.what() << std::endl;
+ std::cerr << "Unable to delete file [" << m_CsvFile.value() << "] : " << e.what() << std::endl;
BOOST_TEST(false);
}
}
}
- boost::optional<boost::filesystem::path> m_CsvFile;
+ armnn::Optional<fs::path> m_CsvFile;
};
diff --git a/src/armnnTfLiteParser/CMakeLists.txt b/src/armnnTfLiteParser/CMakeLists.txt
index 97c55a1d08..d14cb75c49 100755
--- a/src/armnnTfLiteParser/CMakeLists.txt
+++ b/src/armnnTfLiteParser/CMakeLists.txt
@@ -18,7 +18,7 @@ if(BUILD_TF_LITE_PARSER)
target_include_directories(armnnTfLiteParser PRIVATE ../armnnUtils)
target_include_directories(armnnTfLiteParser SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}")
- target_link_libraries(armnnTfLiteParser ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
+ target_link_libraries(armnnTfLiteParser ${Boost_THREAD_LIBRARY})
# If user has explicitly specified flatbuffers lib then use that,
# otherwise search for it based on FLATBUFFERS_BUILD_DIR
diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp
index 7f68199368..bad2504f18 100644
--- a/src/armnnTfLiteParser/TfLiteParser.cpp
+++ b/src/armnnTfLiteParser/TfLiteParser.cpp
@@ -15,6 +15,7 @@
// armnnUtils:
#include <armnnUtils/Permute.hpp>
+#include <Filesystem.hpp>
#include <ParserHelper.hpp>
#include <VerificationHelpers.hpp>
@@ -26,7 +27,6 @@
#include <boost/format.hpp>
#include <boost/numeric/conversion/cast.hpp>
-#include <boost/filesystem.hpp>
#include <fstream>
#include <algorithm>
@@ -2868,9 +2868,9 @@ TfLiteParser::ModelPtr TfLiteParser::LoadModelFromFile(const char * fileName)
throw InvalidArgumentException(boost::str(boost::format("Invalid (null) file name %1%") %
CHECK_LOCATION().AsString()));
}
- boost::system::error_code errorCode;
- boost::filesystem::path pathToFile(fileName);
- if (!boost::filesystem::exists(pathToFile, errorCode))
+ std::error_code errorCode;
+ fs::path pathToFile(fileName);
+ if (!fs::exists(pathToFile, errorCode))
{
std::string locationString = CHECK_LOCATION().AsString();
std::string msg = boost::str(boost::format("Cannot find the file (%1%) errorCode: %2% %3%") %
diff --git a/src/armnnTfLiteParser/test/LoadModel.cpp b/src/armnnTfLiteParser/test/LoadModel.cpp
index 9ae3412a11..9777333495 100644
--- a/src/armnnTfLiteParser/test/LoadModel.cpp
+++ b/src/armnnTfLiteParser/test/LoadModel.cpp
@@ -6,6 +6,8 @@
#include "ParserFlatbuffersFixture.hpp"
#include "../TfLiteParser.hpp"
+#include <Filesystem.hpp>
+
using armnnTfLiteParser::TfLiteParser;
using ModelPtr = TfLiteParser::ModelPtr;
using SubgraphPtr = TfLiteParser::SubgraphPtr;
@@ -196,8 +198,8 @@ BOOST_FIXTURE_TEST_CASE(LoadModelFromBinary, LoadModelFixture)
BOOST_FIXTURE_TEST_CASE(LoadModelFromFile, LoadModelFixture)
{
- using namespace boost::filesystem;
- std::string fname = unique_path(temp_directory_path() / "%%%%-%%%%-%%%%.tflite").string();
+ using namespace fs;
+ fs::path fname = armnnUtils::Filesystem::NamedTempFile("Armnn-tfLite-LoadModelFromFile-TempFile.csv");
bool saved = flatbuffers::SaveFile(fname.c_str(),
reinterpret_cast<char *>(m_GraphBinary.data()),
m_GraphBinary.size(), true);
diff --git a/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp b/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp
index 56811b5b6d..891e0be499 100644
--- a/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp
+++ b/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp
@@ -19,7 +19,6 @@
#include <test/TensorHelpers.hpp>
-#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include "flatbuffers/idl.h"
diff --git a/src/armnnUtils/Filesystem.cpp b/src/armnnUtils/Filesystem.cpp
index 4a2e2ed393..ac9a414ae4 100644
--- a/src/armnnUtils/Filesystem.cpp
+++ b/src/armnnUtils/Filesystem.cpp
@@ -5,51 +5,30 @@
#include "Filesystem.hpp"
-#if defined(__unix__)
-#include <sys/stat.h>
-#include <stdio.h>
-#elif defined(_MSC_VER)
-#include "WindowsWrapper.hpp"
-#endif
-
namespace armnnUtils
{
namespace Filesystem
{
-long long GetFileSize(const char* path)
+/**
+ * @brief Construct a temporary file name.
+ *
+ * Given a specified file name construct a path to that file in the
+ * system temporary directory. If the file already exists it is deleted. This
+ * could throw filesystem_error exceptions.
+ *
+ * @param fileName the file name required in the temporary directory.
+ * @return path consisting of system temporary directory and file name.
+ */
+fs::path NamedTempFile(const char* fileName)
{
-#if defined(__ANDROID__)
- struct stat statusBuffer;
- if (stat(path, & statusBuffer) != 0)
- {
- return -1;
- }
- return statusBuffer.st_size;
-#elif defined(__unix__)
- struct stat statusBuffer;
- if (stat(path, & statusBuffer) != 0)
- {
- return -1;
- }
- return static_cast<long long>(statusBuffer.st_size);
-#elif defined(_MSC_VER)
- WIN32_FILE_ATTRIBUTE_DATA attr;
- if (::GetFileAttributesEx(path, GetFileExInfoStandard, &attr) == 0)
+ fs::path tmpDir = fs::temp_directory_path();
+ fs::path namedTempFile{tmpDir / fileName};
+ if (fs::exists(namedTempFile))
{
- return -1;
+ fs::remove(namedTempFile);
}
- return attr.nFileSizeLow;
-#endif
-}
-
-bool Remove(const char* path)
-{
-#if defined(__unix__)
- return remove(path) == 0;
-#elif defined(_MSC_VER)
- return ::DeleteFile(path);
-#endif
+ return namedTempFile;
}
}
diff --git a/src/armnnUtils/Filesystem.hpp b/src/armnnUtils/Filesystem.hpp
index 1b12502b40..869b0c1b5e 100644
--- a/src/armnnUtils/Filesystem.hpp
+++ b/src/armnnUtils/Filesystem.hpp
@@ -13,9 +13,8 @@ namespace armnnUtils
namespace Filesystem
{
-long long GetFileSize(const char* path);
-
-bool Remove(const char* path);
+/// Returns a path to a file in the system temporary folder. If the file existed it will be deleted.
+fs::path NamedTempFile(const char* fileName);
}
}
diff --git a/src/armnnUtils/ModelAccuracyChecker.cpp b/src/armnnUtils/ModelAccuracyChecker.cpp
index d197dc86ba..418737c0f6 100644
--- a/src/armnnUtils/ModelAccuracyChecker.cpp
+++ b/src/armnnUtils/ModelAccuracyChecker.cpp
@@ -7,7 +7,6 @@
#include <armnn/Logging.hpp>
-#include <boost/filesystem.hpp>
#include <map>
#include <vector>
diff --git a/src/backends/backendsCommon/DynamicBackendUtils.cpp b/src/backends/backendsCommon/DynamicBackendUtils.cpp
index 5b675ba476..1abea114bd 100644
--- a/src/backends/backendsCommon/DynamicBackendUtils.cpp
+++ b/src/backends/backendsCommon/DynamicBackendUtils.cpp
@@ -6,8 +6,7 @@
#include <armnn/Logging.hpp>
#include <backendsCommon/DynamicBackendUtils.hpp>
#include "armnn/utility/StringUtils.hpp"
-
-#include <boost/filesystem.hpp>
+#include <Filesystem.hpp>
#include <regex>
@@ -149,21 +148,21 @@ bool DynamicBackendUtils::IsPathValid(const std::string& path)
return false;
}
- boost::filesystem::path boostPath(path);
+ fs::path fsPath(path);
- if (!boost::filesystem::exists(boostPath))
+ if (!fs::exists(fsPath))
{
ARMNN_LOG(warning) << "WARNING: The given backend path \"" << path << "\" does not exist";
return false;
}
- if (!boost::filesystem::is_directory(boostPath))
+ if (!fs::is_directory(fsPath))
{
ARMNN_LOG(warning) << "WARNING: The given backend path \"" << path << "\" is not a directory";
return false;
}
- if (!boostPath.is_absolute())
+ if (!fsPath.is_absolute())
{
ARMNN_LOG(warning) << "WARNING: The given backend path \"" << path << "\" is not absolute";
return false;
@@ -179,7 +178,7 @@ std::vector<std::string> DynamicBackendUtils::GetSharedObjects(const std::vector
for (const std::string& backendPath : backendPaths)
{
- using namespace boost::filesystem;
+ using namespace fs;
// Check if the path is valid. In case of error, IsValidPath will log an error message
if (!IsPathValid(backendPath))
diff --git a/src/backends/backendsCommon/test/DynamicBackendTests.hpp b/src/backends/backendsCommon/test/DynamicBackendTests.hpp
index a2a6df0432..79f208d784 100644
--- a/src/backends/backendsCommon/test/DynamicBackendTests.hpp
+++ b/src/backends/backendsCommon/test/DynamicBackendTests.hpp
@@ -11,6 +11,7 @@
#include <armnn/utility/PolymorphicDowncast.hpp>
#include <backendsCommon/CpuTensorHandle.hpp>
#include <backendsCommon/DynamicBackendUtils.hpp>
+#include <Filesystem.hpp>
#include <reference/workloads/RefConvolution2dWorkload.hpp>
#include <Runtime.hpp>
@@ -18,7 +19,6 @@
#include <memory>
#include <boost/test/unit_test.hpp>
-#include <boost/filesystem.hpp>
#include <boost/dll.hpp>
static std::string g_TestBaseDir = "src/backends/backendsCommon/test/";
@@ -104,9 +104,9 @@ private:
std::string GetBasePath(const std::string& basePath)
{
- using namespace boost::filesystem;
+ using namespace fs;
- path programLocation = boost::dll::program_location().parent_path();
+ path programLocation = boost::dll::program_location().parent_path().c_str();
path sharedObjectPath = programLocation.append(basePath);
BOOST_CHECK_MESSAGE(exists(sharedObjectPath), "Base path for shared objects does not exist: " +
sharedObjectPath.string());
@@ -125,7 +125,7 @@ std::string GetDynamicBackendsBasePath()
std::string GetTestSubDirectory(const std::string& subdir)
{
- using namespace boost::filesystem;
+ using namespace fs;
std::string testDynamicBackendsBaseDir = GetTestDirectoryBasePath();
path testDynamicBackendsBasePath(testDynamicBackendsBaseDir);
@@ -137,7 +137,7 @@ std::string GetTestSubDirectory(const std::string& subdir)
std::string GetTestSubDirectory(const std::string& basePath, const std::string& subdir)
{
- using namespace boost::filesystem;
+ using namespace fs;
path testDynamicBackendsBasePath(basePath);
path testDynamicBackendsSubDir = testDynamicBackendsBasePath.append(subdir);
@@ -148,7 +148,7 @@ std::string GetTestSubDirectory(const std::string& basePath, const std::string&
std::string GetTestFilePath(const std::string& directory, const std::string& fileName)
{
- using namespace boost::filesystem;
+ using namespace fs;
path directoryPath(directory);
path fileNamePath = directoryPath.append(fileName);
@@ -346,7 +346,7 @@ void CreateValidDynamicBackendObjectTestImpl()
std::string testSubDirectory = GetTestSubDirectory(g_TestDynamicBackendSubDir);
// We expect this path to exists so we can load a valid dynamic backend.
- BOOST_CHECK_MESSAGE(boost::filesystem::exists(testSubDirectory),
+ BOOST_CHECK_MESSAGE(fs::exists(testSubDirectory),
"Base path for shared objects does not exist: " + testSubDirectory);
std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestValidTestDynamicBackendFileName);
@@ -560,7 +560,7 @@ void CreateDynamicBackendObjectInvalidInterface7TestImpl()
void GetBackendPathsTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
// The test covers four directories:
// <unit test path>/src/backends/backendsCommon/test/
@@ -640,7 +640,7 @@ void GetBackendPathsTestImpl()
void GetBackendPathsOverrideTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
std::string subDir1 = GetTestSubDirectory(g_TestDynamicBackendsSubDir1);
std::string subDir4 = GetTestSubDirectory(g_TestDynamicBackendsSubDir4);
@@ -661,7 +661,7 @@ void GetBackendPathsOverrideTestImpl()
void GetSharedObjectsTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
// The test covers four directories:
// <unit test path>/src/backends/backendsCommon/test/
@@ -752,7 +752,7 @@ void GetSharedObjectsTestImpl()
void CreateDynamicBackendsTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
// The test covers four directories:
// <unit test path>/src/backends/backendsCommon/test/
@@ -839,7 +839,7 @@ void CreateDynamicBackendsAllInvalidTestImpl()
void CreateDynamicBackendsMixedTypesTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
std::string testDynamicBackendsSubDir5 = GetTestSubDirectory(g_TestDynamicBackendsSubDir5);
std::string testDynamicBackendsSubDir6 = GetTestSubDirectory(g_TestDynamicBackendsSubDir6);
@@ -873,7 +873,7 @@ void CreateDynamicBackendsMixedTypesTestImpl()
void RegisterSingleDynamicBackendTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
// Register one valid dynamic backend
@@ -920,7 +920,7 @@ void RegisterSingleDynamicBackendTestImpl()
void RegisterMultipleDynamicBackendsTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
// Register many valid dynamic backends
@@ -996,7 +996,7 @@ void RegisterMultipleDynamicBackendsTestImpl()
void RegisterMultipleInvalidDynamicBackendsTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
// Try to register many invalid dynamic backends
@@ -1056,7 +1056,7 @@ void RegisterMultipleInvalidDynamicBackendsTestImpl()
void RegisterMixedDynamicBackendsTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
// The test covers five directories:
// <unit test path>/src/backends/backendsCommon/test/
@@ -1226,7 +1226,7 @@ void RuntimeEmptyTestImpl()
void RuntimeDynamicBackendsTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
// Swapping the backend registry storage for testing
TestBackendRegistry testBackendRegistry;
@@ -1267,7 +1267,7 @@ void RuntimeDynamicBackendsTestImpl()
void RuntimeDuplicateDynamicBackendsTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
// Swapping the backend registry storage for testing
TestBackendRegistry testBackendRegistry;
@@ -1308,7 +1308,7 @@ void RuntimeDuplicateDynamicBackendsTestImpl()
void RuntimeInvalidDynamicBackendsTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
// Swapping the backend registry storage for testing
TestBackendRegistry testBackendRegistry;
@@ -1357,7 +1357,7 @@ void RuntimeInvalidOverridePathTestImpl()
void CreateReferenceDynamicBackendTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
+ using namespace fs;
// Swapping the backend registry storage for testing
TestBackendRegistry testBackendRegistry;
@@ -1520,7 +1520,6 @@ void CreateSampleDynamicBackendTestImpl()
void SampleDynamicBackendEndToEndTestImpl()
{
using namespace armnn;
- using namespace boost::filesystem;
// Create runtime in which test will run
IRuntime::CreationOptions options;
IRuntimePtr runtime(IRuntime::Create(options));
diff --git a/src/dynamic/README.md b/src/dynamic/README.md
index 36a238a7ba..39ed18895d 100644
--- a/src/dynamic/README.md
+++ b/src/dynamic/README.md
@@ -31,7 +31,6 @@ mkdir build
cd build
cmake -DBOOST_ROOT=${BOOST_PATH} \
-DBoost_SYSTEM_LIBRARY=${BOOST_PATH}/lib/libboost_system.a \
- -DBoost_FILESYSTEM_LIBRARY=${BOOST_PATH}/lib/libboost_filesystem.a \
-DARMNN_PATH=${ARMNN_PATH}/libarmnn.so ..
```
diff --git a/src/dynamic/sample/CMakeLists.txt b/src/dynamic/sample/CMakeLists.txt
index 452ca94139..a6c290667c 100644
--- a/src/dynamic/sample/CMakeLists.txt
+++ b/src/dynamic/sample/CMakeLists.txt
@@ -38,5 +38,5 @@ target_include_directories(Arm_SampleDynamic_backend PRIVATE ${PROJECT_SOURCE_DI
target_include_directories(Arm_SampleDynamic_backend PRIVATE ${PROJECT_SOURCE_DIR}/../../../src/profiling)
target_include_directories(Arm_SampleDynamic_backend PRIVATE ${PROJECT_SOURCE_DIR}/../../../profiling/common/include)
target_include_directories(Arm_SampleDynamic_backend PRIVATE ${Boost_INCLUDE_DIRS})
-target_link_libraries(Arm_SampleDynamic_backend ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
+target_link_libraries(Arm_SampleDynamic_backend ${Boost_SYSTEM_LIBRARY})
target_link_libraries(Arm_SampleDynamic_backend ${ARMNN_PATH})
diff --git a/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
index e968d67cf5..79da17a1af 100644
--- a/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
+++ b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
@@ -11,7 +11,6 @@
#include <Runtime.hpp>
#include "TestTimelinePacketHandler.hpp"
-#include <boost/filesystem.hpp>
#include <boost/numeric/conversion/cast.hpp>
#include <boost/test/unit_test.hpp>
@@ -37,18 +36,6 @@ class FileOnlyHelperService : public ProfilingService
BOOST_AUTO_TEST_SUITE(FileOnlyProfilingDecoratorTests)
-std::string UniqueFileName()
-{
- std::time_t t = std::time(nullptr);
- char mbstr[100];
- std::strftime(mbstr, sizeof(mbstr), "%Y_%m_%d_%H_%M_%S_", std::localtime(&t));
- std::stringstream ss;
- ss << mbstr;
- ss << t;
- ss << ".bin";
- return ss.str();
-}
-
BOOST_AUTO_TEST_CASE(TestFileOnlyProfiling)
{
// This test requires at least one backend registry to be enabled
@@ -58,10 +45,8 @@ BOOST_AUTO_TEST_CASE(TestFileOnlyProfiling)
return;
}
- // Create a temporary file name.
- fs::path tempPath = fs::temp_directory_path();
- fs::path tempFile = UniqueFileName();
- tempPath = tempPath / tempFile;
+ // Enable m_FileOnly but also provide ILocalPacketHandler which should consume the packets.
+ // This won't dump anything to file.
armnn::Runtime::CreationOptions creationOptions;
creationOptions.m_ProfilingOptions.m_EnableProfiling = true;
creationOptions.m_ProfilingOptions.m_FileOnly = true;
@@ -180,9 +165,7 @@ BOOST_AUTO_TEST_CASE(DumpOutgoingValidFileEndToEnd)
}
// Create a temporary file name.
- fs::path tempPath = fs::temp_directory_path();
- fs::path tempFile = UniqueFileName();
- tempPath = tempPath / tempFile;
+ fs::path tempPath = armnnUtils::Filesystem::NamedTempFile("DumpOutgoingValidFileEndToEnd_CaptureFile.txt");
armnn::Runtime::CreationOptions options;
options.m_ProfilingOptions.m_EnableProfiling = true;
options.m_ProfilingOptions.m_FileOnly = true;
@@ -195,7 +178,7 @@ BOOST_AUTO_TEST_CASE(DumpOutgoingValidFileEndToEnd)
options.m_ProfilingOptions.m_LocalPacketHandlers.push_back(localPacketHandlerPtr);
// Make sure the file does not exist at this point
- BOOST_CHECK(armnnUtils::Filesystem::GetFileSize(tempPath.string().c_str()) == -1);
+ BOOST_CHECK(!fs::exists(tempPath));
armnn::Runtime runtime(options);
// ensure the GUID generator is reset to zero
@@ -255,12 +238,12 @@ BOOST_AUTO_TEST_CASE(DumpOutgoingValidFileEndToEnd)
GetProfilingService(&runtime).ResetExternalProfilingOptions(options.m_ProfilingOptions, true);
// The output file size should be greater than 0.
- BOOST_CHECK(armnnUtils::Filesystem::GetFileSize(tempPath.string().c_str()) > 0);
+ BOOST_CHECK(fs::file_size(tempPath) > 0);
// NOTE: would be an interesting exercise to take this file and decode it
// Delete the tmp file.
- BOOST_CHECK(armnnUtils::Filesystem::Remove(tempPath.string().c_str()));
+ BOOST_CHECK(fs::remove(tempPath));
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
index c36867815f..6784ddabcb 100644
--- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
+++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
@@ -4,13 +4,13 @@
//
#include "../ProfilingConnectionDumpToFileDecorator.hpp"
+#include <Filesystem.hpp>
#include <Runtime.hpp>
#include <armnn/utility/IgnoreUnused.hpp>
#include <fstream>
#include <sstream>
-#include <boost/filesystem.hpp>
#include <boost/numeric/conversion/cast.hpp>
#include <boost/test/unit_test.hpp>
@@ -96,8 +96,7 @@ BOOST_AUTO_TEST_CASE(DumpIncomingInvalidFileIgnoreErrors)
BOOST_AUTO_TEST_CASE(DumpIncomingValidFile)
{
- boost::filesystem::path fileName =
- boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
+ fs::path fileName = armnnUtils::Filesystem::NamedTempFile("Armnn-DumpIncomingValidFileTest-TempFile");
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
options.m_IncomingCaptureFile = fileName.string();
@@ -118,6 +117,7 @@ BOOST_AUTO_TEST_CASE(DumpIncomingValidFile)
constexpr unsigned int bytesToSkip = 2u * sizeof(uint32_t); // skip header and packet length
int diff = std::strncmp(data.data() + bytesToSkip, packetData, g_DataLength);
BOOST_CHECK(diff == 0);
+ fs::remove(fileName);
}
BOOST_AUTO_TEST_CASE(DumpOutgoingInvalidFile)
@@ -144,8 +144,7 @@ BOOST_AUTO_TEST_CASE(DumpOutgoingInvalidFileIgnoreErrors)
BOOST_AUTO_TEST_CASE(DumpOutgoingValidFile)
{
- boost::filesystem::path fileName =
- boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
+ fs::path fileName = armnnUtils::Filesystem::NamedTempFile("Armnn-DumpOutgoingValidFileTest-TempFile");
armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
options.m_IncomingCaptureFile = "";
@@ -164,6 +163,7 @@ BOOST_AUTO_TEST_CASE(DumpOutgoingValidFile)
// check if the data read back from the dump file matches the original
int diff = std::strncmp(data.data(), g_Data.data(), g_DataLength);
BOOST_CHECK(diff == 0);
+ fs::remove(fileName);
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/timelineDecoder/CMakeLists.txt b/src/timelineDecoder/CMakeLists.txt
index 4702577197..695aa5cbe8 100644
--- a/src/timelineDecoder/CMakeLists.txt
+++ b/src/timelineDecoder/CMakeLists.txt
@@ -17,7 +17,8 @@ if(BUILD_TIMELINE_DECODER)
TimelineDirectoryCaptureCommandHandler.hpp)
include_directories(${PROJECT_SOURCE_DIR}/src/profiling
- ${PROJECT_SOURCE_DIR}/profiling/common/include)
+ ${PROJECT_SOURCE_DIR}/profiling/common/include
+ ${PROJECT_SOURCE_DIR}/src/armnnUtils)
if(BUILD_UNIT_TESTS)
target_include_directories(UnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src/timelineDecoder)
diff --git a/src/timelineDecoder/JSONTimelineDecoder.cpp b/src/timelineDecoder/JSONTimelineDecoder.cpp
index 84472d8c99..a0392149ed 100644
--- a/src/timelineDecoder/JSONTimelineDecoder.cpp
+++ b/src/timelineDecoder/JSONTimelineDecoder.cpp
@@ -8,7 +8,6 @@
#include <string>
#include <fstream>
-#include <boost/filesystem/fstream.hpp>
namespace armnn
{
@@ -246,7 +245,7 @@ void JSONTimelineDecoder::JSONEntity::SetParent(JSONEntity& parent)
void JSONTimelineDecoder::PrintJSON(JSONTimelineDecoder::JSONEntity& rootEntity)
{
std::string jsonString = GetJSONString(rootEntity);
- boost::filesystem::ofstream ofs{this->outputJSONFile};
+ std::ofstream ofs{this->outputJSONFile};
ofs << jsonString;
ofs.close();
}
diff --git a/src/timelineDecoder/JSONTimelineDecoder.hpp b/src/timelineDecoder/JSONTimelineDecoder.hpp
index 38d698387a..4d6fcecebd 100644
--- a/src/timelineDecoder/JSONTimelineDecoder.hpp
+++ b/src/timelineDecoder/JSONTimelineDecoder.hpp
@@ -7,10 +7,9 @@
#include <armnn/profiling/ITimelineDecoder.hpp>
+#include <Filesystem.hpp>
#include <map>
#include <vector>
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem.hpp>
namespace armnn
{
@@ -65,8 +64,7 @@ public:
private:
Model m_Model;
- boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
- boost::filesystem::path p{fileDir / boost::filesystem::unique_path("output.json")};
+ fs::path p = armnnUtils::Filesystem::NamedTempFile("output.json");
std::string outputJSONFile = p.string();
diff --git a/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp b/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
index 2d78564a2a..82414192f2 100644
--- a/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
+++ b/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
@@ -6,12 +6,12 @@
#include <JSONTimelineDecoder.hpp>
#include <TimelineCaptureCommandHandler.hpp>
#include <TimelineDecoder.hpp>
+#include <Filesystem.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test_suite.hpp>
#include <fstream>
-#include <boost/filesystem.hpp>
BOOST_AUTO_TEST_SUITE(JSONTimelineDecoderTests)
@@ -797,10 +797,8 @@ BOOST_AUTO_TEST_CASE(JSONTimelineDecoderTestJSON)
timelineDecoder.PrintJSON(rootEntity);
- boost::filesystem::ifstream inFile;
- boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
- boost::filesystem::path p{fileDir / boost::filesystem::unique_path("output.json")};
-
+ fs::ifstream inFile;
+ fs::path p{fs::temp_directory_path() / "output.json"};
inFile.open(p); //open the input file
std::stringstream strStream;