IVGCVSW-4487 Remove boost::filesystem
authorFrancis Murtagh <francis.murtagh@arm.com>
Mon, 29 Jun 2020 10:50:01 +0000 (11:50 +0100)
committerColm Donelan <colm.donelan@arm.com>
Tue, 30 Jun 2020 11:29:07 +0000 (11:29 +0000)
 * 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

35 files changed:
BuildGuideAndroidNDK.md
BuildGuideCrossCompilation.md
CMakeLists.txt
cmake/GlobalConfig.cmake
src/armnn/test/CsvReaderTest.cpp
src/armnn/test/ModelAccuracyCheckerTest.cpp
src/armnnDeserializer/Deserializer.cpp
src/armnnQuantizer/CommandLineProcessor.cpp
src/armnnQuantizer/QuantizationDataSet.cpp
src/armnnQuantizer/test/QuantizationDataSetTests.cpp
src/armnnTfLiteParser/CMakeLists.txt
src/armnnTfLiteParser/TfLiteParser.cpp
src/armnnTfLiteParser/test/LoadModel.cpp
src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp
src/armnnUtils/Filesystem.cpp
src/armnnUtils/Filesystem.hpp
src/armnnUtils/ModelAccuracyChecker.cpp
src/backends/backendsCommon/DynamicBackendUtils.cpp
src/backends/backendsCommon/test/DynamicBackendTests.hpp
src/dynamic/README.md
src/dynamic/sample/CMakeLists.txt
src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
src/timelineDecoder/CMakeLists.txt
src/timelineDecoder/JSONTimelineDecoder.cpp
src/timelineDecoder/JSONTimelineDecoder.hpp
src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
tests/CMakeLists.txt
tests/ExecuteNetwork/ExecuteNetwork.cpp
tests/ImageCSVFileGenerator/ImageCSVFileGenerator.cpp
tests/ImageTensorGenerator/ImageTensorGenerator.cpp
tests/InferenceModel.hpp
tests/InferenceTest.cpp
tests/InferenceTest.inl
tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp

index 7084456..79de1fc 100644 (file)
@@ -54,7 +54,7 @@ All downloaded or generated files will be saved inside the `~/armnn-devenv` dire
        cd ~/armnn-devenv/boost/boost_1_64_0
        ./bootstrap.sh --prefix=$HOME/armnn-devenv/boost/install
        ./b2 install --user-config=$HOME/armnn-devenv/boost/user-config.jam \
-     toolset=clang-arm link=static cxxflags=-fPIC --with-filesystem \
+     toolset=clang-arm link=static cxxflags=-fPIC \
         --with-test --with-log --with-program_options -j16
     ```
  Note: You can specify the 'Android_API' version you want. For example, if your ANDROID_API is 27 then the compiler will be aarch64-linux-android27-clang++.
@@ -230,7 +230,6 @@ All downloaded or generated files will be saved inside the `~/armnn-devenv` dire
     -DCMAKE_MODULE_LINKER_FLAGS="-llog" \
     -DBOOST_ROOT=$HOME/armnn-devenv/boost/install \
     -DBoost_SYSTEM_LIBRARY=$HOME/armnn-devenv/boost/install/lib/libboost_system.a \
-    -DBoost_FILESYSTEM_LIBRARY=$HOME/armnn-devenv/boost/install/lib/libboost_filesystem.a \
     -DARMNN_PATH=$HOME/armnn-devenv/armnn/build/libarmnn.so ..
     ```
 
index 156488a..3a89a30 100644 (file)
@@ -101,7 +101,7 @@ The instructions show how to build the ArmNN core library and the Boost, Protobu
     cd boost_1_64_0
     echo "using gcc : arm : aarch64-linux-gnu-g++ ;" > user_config.jam
     ./bootstrap.sh --prefix=$HOME/armnn-devenv/boost_arm64_install
-    ./b2 install toolset=gcc-arm link=static cxxflags=-fPIC --with-filesystem --with-test --with-log --with-program_options -j32 --user-config=user_config.jam
+    ./b2 install toolset=gcc-arm link=static cxxflags=-fPIC --with-test --with-log --with-program_options -j32 --user-config=user_config.jam
     ```
 
 #### <a name="buildCL">Build Compute Library</a>
@@ -243,7 +243,6 @@ The instructions show how to build the ArmNN core library and the Boost, Protobu
     -DCMAKE_CXX_FLAGS=--std=c++14 \
     -DBOOST_ROOT=$HOME/armnn-devenv/boost_arm64_install/ \
     -DBoost_SYSTEM_LIBRARY=$HOME/armnn-devenv/boost_arm64_install/lib/libboost_system.a \
-    -DBoost_FILESYSTEM_LIBRARY=$HOME/armnn-devenv/boost_arm64_install/lib/libboost_filesystem.a \
     -DARMNN_PATH=$HOME/armnn-devenv/armnn/build/libarmnn.so
     ```
 
index 13d7077..8f5a0bd 100644 (file)
@@ -184,7 +184,6 @@ if(BUILD_ARMNN_QUANTIZER AND ARMNNREF)
             armnn
             ${Boost_SYSTEM_LIBRARY}
             ${Boost_PROGRAM_OPTIONS_LIBRARY}
-            ${Boost_FILESYSTEM_LIBRARY}
             ${Boost_THREAD_LIBRARY} )
 
     add_executable_ex(ArmnnQuantizer
@@ -196,7 +195,6 @@ if(BUILD_ARMNN_QUANTIZER AND ARMNNREF)
     target_link_libraries(ArmnnQuantizer
             ${Boost_SYSTEM_LIBRARY}
             ${Boost_PROGRAM_OPTIONS_LIBRARY}
-            ${Boost_FILESYSTEM_LIBRARY}
             ${Boost_THREAD_LIBRARY} )
 
     target_link_libraries(ArmnnQuantizer
@@ -611,7 +609,7 @@ endif()
 install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 target_link_libraries(armnn ${Boost_THREAD_LIBRARY}
-                            ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
+                            ${Boost_SYSTEM_LIBRARY})
 
 if(ARMCOMPUTENEON OR ARMCOMPUTECL)
     target_link_libraries(armnn ${ARMCOMPUTE_LIBRARIES})
@@ -1029,7 +1027,6 @@ if (BUILD_ARMNN_SERIALIZER AND (BUILD_TF_PARSER OR BUILD_TF_LITE_PARSER OR BUILD
     target_link_libraries(ArmnnConverter ${CMAKE_THREAD_LIBS_INIT})
     target_link_libraries(ArmnnConverter
         ${Boost_SYSTEM_LIBRARY}
-        ${Boost_FILESYSTEM_LIBRARY}
         ${Boost_PROGRAM_OPTIONS_LIBRARY})
     addDllCopyCommands(ArmnnConverter)
   endif()
index 3e0f0fe..2bfca58 100644 (file)
@@ -127,7 +127,7 @@ else()
     set(Boost_USE_STATIC_LIBS ON)
 endif()
 add_definitions("-DBOOST_ALL_NO_LIB") # Turn off auto-linking as we specify the libs manually
-find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework system filesystem program_options)
+find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework filesystem system program_options)
 include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
 link_directories(${Boost_LIBRARY_DIRS})
 
index 8491ad7..96185c8 100644 (file)
@@ -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;
 };
 }
 
index 1bffa9c..c6c93ed 100644 (file)
@@ -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>
index b9579d5..f59c757 100644 (file)
@@ -19,7 +19,6 @@
 #include <ParserHelper.hpp>
 #include <VerificationHelpers.hpp>
 
-#include <boost/filesystem.hpp>
 #include <boost/format.hpp>
 #include <boost/numeric/conversion/cast.hpp>
 
index 0cccb66..ace4a50 100644 (file)
@@ -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;
index 7042d74..819b437 100644 (file)
@@ -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.");
index 2b46aae..9e71f68 100644 (file)
@@ -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;
 };
 
 
index 97c55a1..d14cb75 100755 (executable)
@@ -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
index 7f68199..bad2504 100644 (file)
@@ -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%") %
index 9ae3412..9777333 100644 (file)
@@ -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);
index 56811b5..891e0be 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <test/TensorHelpers.hpp>
 
-#include <boost/filesystem.hpp>
 #include <boost/format.hpp>
 
 #include "flatbuffers/idl.h"
index 4a2e2ed..ac9a414 100644 (file)
@@ -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;
 }
 
 }
index 1b12502..869b0c1 100644 (file)
@@ -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);
 
 }
 }
index d197dc8..418737c 100644 (file)
@@ -7,7 +7,6 @@
 
 #include <armnn/Logging.hpp>
 
-#include <boost/filesystem.hpp>
 #include <map>
 #include <vector>
 
index 5b675ba..1abea11 100644 (file)
@@ -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))
index a2a6df0..79f208d 100644 (file)
@@ -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));
index 36a238a..39ed188 100644 (file)
@@ -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 ..
 ```
 
index 452ca94..a6c2906 100644 (file)
@@ -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})
index e968d67..79da17a 100644 (file)
@@ -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()
index c368678..6784dda 100644 (file)
@@ -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()
index 4702577..695aa5c 100644 (file)
@@ -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)
index 84472d8..a039214 100644 (file)
@@ -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();
 }
index 38d6983..4d6fcec 100644 (file)
@@ -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();
 
index 2d78564..8241419 100644 (file)
@@ -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;
index 145af12..8d3d832 100644 (file)
@@ -29,7 +29,6 @@ if(BUILD_CAFFE_PARSER)
         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
         target_link_libraries(${testName}
             ${Boost_SYSTEM_LIBRARY}
-            ${Boost_FILESYSTEM_LIBRARY}
             ${Boost_PROGRAM_OPTIONS_LIBRARY})
         addDllCopyCommands(${testName})
     endmacro()
@@ -96,7 +95,6 @@ if(BUILD_TF_PARSER)
         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
         target_link_libraries(${testName}
             ${Boost_SYSTEM_LIBRARY}
-            ${Boost_FILESYSTEM_LIBRARY}
             ${Boost_PROGRAM_OPTIONS_LIBRARY})
         addDllCopyCommands(${testName})
     endmacro()
@@ -144,7 +142,6 @@ if (BUILD_TF_LITE_PARSER)
         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
         target_link_libraries(${testName}
             ${Boost_SYSTEM_LIBRARY}
-            ${Boost_FILESYSTEM_LIBRARY}
             ${Boost_PROGRAM_OPTIONS_LIBRARY})
         addDllCopyCommands(${testName})
     endmacro()
@@ -232,7 +229,6 @@ if (BUILD_ONNX_PARSER)
         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
         target_link_libraries(${testName}
             ${Boost_SYSTEM_LIBRARY}
-            ${Boost_FILESYSTEM_LIBRARY}
             ${Boost_PROGRAM_OPTIONS_LIBRARY})
         addDllCopyCommands(${testName})
     endmacro()
@@ -280,7 +276,6 @@ if (BUILD_ARMNN_SERIALIZER OR BUILD_CAFFE_PARSER OR BUILD_TF_PARSER OR BUILD_TF_
     target_link_libraries(ExecuteNetwork ${CMAKE_THREAD_LIBS_INIT})
     target_link_libraries(ExecuteNetwork
         ${Boost_SYSTEM_LIBRARY}
-        ${Boost_FILESYSTEM_LIBRARY}
         ${Boost_PROGRAM_OPTIONS_LIBRARY})
     addDllCopyCommands(ExecuteNetwork)
 endif()
@@ -305,7 +300,6 @@ if(BUILD_ACCURACY_TOOL)
         endif()
         target_link_libraries(${executorName}
                 ${Boost_SYSTEM_LIBRARY}
-                ${Boost_FILESYSTEM_LIBRARY}
                 ${Boost_PROGRAM_OPTIONS_LIBRARY})
         addDllCopyCommands(${executorName})
     endmacro()
@@ -328,7 +322,6 @@ if(BUILD_ARMNN_QUANTIZER)
         target_link_libraries(${executorName} ${CMAKE_THREAD_LIBS_INIT})
         target_link_libraries(${executorName}
                 ${Boost_SYSTEM_LIBRARY}
-                ${Boost_FILESYSTEM_LIBRARY}
                 ${Boost_PROGRAM_OPTIONS_LIBRARY})
         addDllCopyCommands(${executorName})
     endmacro()
@@ -349,5 +342,6 @@ if(BUILD_ARMNN_QUANTIZER)
             ImageCSVFileGenerator/ImageCSVFileGenerator.cpp)
 
     add_executable_ex(ImageCSVFileGenerator ${ImageCSVFileGenerator_sources})
+    target_include_directories(ImageCSVFileGenerator PRIVATE ../src/armnnUtils)
     ImageTensorExecutor(ImageCSVFileGenerator)
 endif()
index 3c4a032..9b79c8c 100644 (file)
@@ -212,7 +212,7 @@ int main(int argc, const char* argv[])
     if (CheckOption(vm, "test-cases"))
     {
         // Check that the file exists.
-        if (!boost::filesystem::exists(testCasesFile))
+        if (!fs::exists(testCasesFile))
         {
             ARMNN_LOG(fatal) << "Given file \"" << testCasesFile << "\" does not exist";
             return EXIT_FAILURE;
index 706a0c0..0d2252d 100644 (file)
@@ -3,9 +3,7 @@
 // SPDX-License-Identifier: MIT
 //
 
-#include <boost/filesystem.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
+#include <Filesystem.hpp>
 #include <boost/program_options.hpp>
 
 #include <algorithm>
@@ -35,13 +33,13 @@ public:
             dir += "/";
         }
 
-        if (!boost::filesystem::exists(dir))
+        if (!fs::exists(dir))
         {
             std::cerr << "Directory [" << dir << "] does not exist" << std::endl;
             return false;
         }
 
-        if (!boost::filesystem::is_directory(dir))
+        if (!fs::is_directory(dir))
         {
             std::cerr << "Given directory [" << dir << "] is not a directory" << std::endl;
             return false;
@@ -58,20 +56,20 @@ public:
             return false;
         }
 
-        if (boost::filesystem::exists(outputFileName))
+        if (fs::exists(outputFileName))
         {
             std::cerr << "Output file [" << outputFileName << "] already exists" << std::endl;
             return false;
         }
 
-        if (boost::filesystem::is_directory(outputFileName))
+        if (fs::is_directory(outputFileName))
         {
             std::cerr << "Output file [" << outputFileName << "] is a directory" << std::endl;
             return false;
         }
 
-        boost::filesystem::path outputPath(outputFileName);
-        if (!boost::filesystem::exists(outputPath.parent_path()))
+        fs::path outputPath(outputFileName);
+        if (!fs::exists(outputPath.parent_path()))
         {
             std::cerr << "Directory [" << outputPath.parent_path().c_str() << "] does not exist" << std::endl;
             return false;
@@ -172,8 +170,6 @@ int main(int argc, char* argv[])
         return -1;
     }
 
-    namespace fs = boost::filesystem;
-
     const std::string fileFormat(".raw");
 
     const std::string rawDirectory(cmdline.GetInputDirectory());
index 9c23200..568ba1e 100644 (file)
@@ -7,10 +7,8 @@
 #include "../InferenceTestImage.hpp"
 #include <armnn/Logging.hpp>
 #include <armnn/TypesUtils.hpp>
+#include <Filesystem.hpp>
 
-#include <boost/filesystem.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
 #include <boost/program_options.hpp>
 #include <boost/variant.hpp>
 
@@ -37,13 +35,13 @@ public:
             return false;
         }
 
-        if (!boost::filesystem::exists(inputFileName))
+        if (!fs::exists(inputFileName))
         {
             std::cerr << "Input file [" << inputFileName << "] does not exist" << std::endl;
             return false;
         }
 
-        if (boost::filesystem::is_directory(inputFileName))
+        if (fs::is_directory(inputFileName))
         {
             std::cerr << "Input file [" << inputFileName << "] is a directory" << std::endl;
             return false;
@@ -80,20 +78,20 @@ public:
             return false;
         }
 
-        if (boost::filesystem::exists(outputFileName))
+        if (fs::exists(outputFileName))
         {
             std::cerr << "Output file [" << outputFileName << "] already exists" << std::endl;
             return false;
         }
 
-        if (boost::filesystem::is_directory(outputFileName))
+        if (fs::is_directory(outputFileName))
         {
             std::cerr << "Output file [" << outputFileName << "] is a directory" << std::endl;
             return false;
         }
 
-        boost::filesystem::path outputPath(outputFileName);
-        if (!boost::filesystem::exists(outputPath.parent_path()))
+        fs::path outputPath(outputFileName);
+        if (!fs::exists(outputPath.parent_path()))
         {
             std::cerr << "Output directory [" << outputPath.parent_path().c_str() << "] does not exist" << std::endl;
             return false;
index 781cef4..5588d55 100644 (file)
@@ -21,6 +21,7 @@
 #include <armnnOnnxParser/IOnnxParser.hpp>
 #endif
 
+#include <Filesystem.hpp>
 #include <HeapProfiling.hpp>
 #include <TensorIOUtils.hpp>
 
@@ -29,7 +30,6 @@
 #include <boost/exception/diagnostic_information.hpp>
 #include <boost/format.hpp>
 #include <boost/program_options.hpp>
-#include <boost/filesystem.hpp>
 #include <boost/variant.hpp>
 
 #include <algorithm>
@@ -188,9 +188,9 @@ public:
         {
             ARMNN_SCOPED_HEAP_PROFILING("Parsing");
 
-            boost::system::error_code errorCode;
-            boost::filesystem::path pathToFile(params.m_ModelPath);
-            if (!boost::filesystem::exists(pathToFile, errorCode))
+            std::error_code errorCode;
+            fs::path pathToFile(params.m_ModelPath);
+            if (!fs::exists(pathToFile, errorCode))
             {
                 throw armnn::FileNotFoundException(boost::str(
                                                    boost::format("Cannot find the file (%1%) errorCode: %2% %3%") %
@@ -429,7 +429,7 @@ public:
 
         if (params.m_VisualizePostOptimizationModel)
         {
-            boost::filesystem::path filename = params.m_ModelPath;
+            fs::path filename = params.m_ModelPath;
             filename.replace_extension("dot");
             std::fstream file(filename.c_str(), std::ios_base::out);
             optNet->SerializeToDot(file);
index 0391a9a..b0d0b47 100644 (file)
@@ -5,13 +5,12 @@
 #include "InferenceTest.hpp"
 
 #include <armnn/utility/Assert.hpp>
+#include <Filesystem.hpp>
 
 #include "../src/armnn/Profiling.hpp"
 #include <boost/numeric/conversion/cast.hpp>
-#include <boost/filesystem/path.hpp>
 #include <boost/format.hpp>
 #include <boost/program_options.hpp>
-#include <boost/filesystem/operations.hpp>
 
 #include <fstream>
 #include <iostream>
@@ -102,13 +101,13 @@ bool ValidateDirectory(std::string& dir)
         dir += "/";
     }
 
-    if (!boost::filesystem::exists(dir))
+    if (!fs::exists(dir))
     {
         std::cerr << "Given directory " << dir << " does not exist" << std::endl;
         return false;
     }
 
-    if (!boost::filesystem::is_directory(dir))
+    if (!fs::is_directory(dir))
     {
         std::cerr << "Given directory [" << dir << "] is not a directory" << std::endl;
         return false;
index 32a164d..362be7b 100644 (file)
@@ -6,10 +6,8 @@
 
 #include <armnn/utility/Assert.hpp>
 #include <boost/numeric/conversion/cast.hpp>
-#include <boost/filesystem/path.hpp>
 #include <boost/format.hpp>
 #include <boost/program_options.hpp>
-#include <boost/filesystem/operations.hpp>
 
 #include <fstream>
 #include <iostream>
index 85d757f..be45d9a 100644 (file)
@@ -7,8 +7,8 @@
 #include "../InferenceTest.hpp"
 #include "ModelAccuracyChecker.hpp"
 #include "armnnDeserializer/IDeserializer.hpp"
+#include <Filesystem.hpp>
 
-#include <boost/filesystem.hpp>
 #include <boost/program_options/variables_map.hpp>
 #include <boost/range/iterator_range.hpp>
 #include <map>
@@ -49,7 +49,6 @@ int main(int argc, char* argv[])
 {
     try
     {
-        using namespace boost::filesystem;
         armnn::LogSeverity level = armnn::LogSeverity::Debug;
         armnn::ConfigureLogging(true, true, level);
 
@@ -195,8 +194,8 @@ int main(int argc, char* argv[])
         std::vector<BindingPointInfo> outputBindings = { m_OutputBindingInfo };
 
         // Load model output labels
-        if (modelOutputLabelsPath.empty() || !boost::filesystem::exists(modelOutputLabelsPath) ||
-            !boost::filesystem::is_regular_file(modelOutputLabelsPath))
+        if (modelOutputLabelsPath.empty() || !fs::exists(modelOutputLabelsPath) ||
+            !fs::is_regular_file(modelOutputLabelsPath))
         {
             ARMNN_LOG(fatal) << "Invalid model output labels path at " << modelOutputLabelsPath;
         }
@@ -225,7 +224,7 @@ int main(int argc, char* argv[])
 
         // Validate  blacklist file if it's specified
         if (!blacklistPath.empty() &&
-            !(boost::filesystem::exists(blacklistPath) && boost::filesystem::is_regular_file(blacklistPath)))
+            !(fs::exists(blacklistPath) && fs::is_regular_file(blacklistPath)))
         {
             ARMNN_LOG(fatal) << "Invalid path to blacklist file at " << blacklistPath;
             return 1;
@@ -309,7 +308,7 @@ int main(int argc, char* argv[])
                 vector<TContainer> inputDataContainers;
                 vector<TContainer> outputDataContainers;
 
-                auto imagePath = pathToDataDir / boost::filesystem::path(imageName);
+                auto imagePath = pathToDataDir / fs::path(imageName);
                 switch (inputTensorDataType)
                 {
                     case armnn::DataType::Signed32:
@@ -393,11 +392,11 @@ map<std::string, std::string> LoadValidationImageFilenamesAndLabels(const string
     // Populate imageFilenames with names of all .JPEG, .PNG images
     std::vector<std::string> imageFilenames;
     for (const auto& imageEntry :
-         boost::make_iterator_range(boost::filesystem::directory_iterator(boost::filesystem::path(imageDirectoryPath))))
+         boost::make_iterator_range(fs::directory_iterator(fs::path(imageDirectoryPath))))
     {
-        boost::filesystem::path imagePath = imageEntry.path();
+        fs::path imagePath = imageEntry.path();
         std::string imageExtension        = boost::to_upper_copy<std::string>(imagePath.extension().string());
-        if (boost::filesystem::is_regular_file(imagePath) && (imageExtension == ".JPEG" || imageExtension == ".PNG"))
+        if (fs::is_regular_file(imagePath) && (imageExtension == ".JPEG" || imageExtension == ".PNG"))
         {
             imageFilenames.push_back(imagePath.filename().string());
         }