diff options
35 files changed, 140 insertions, 222 deletions
diff --git a/BuildGuideAndroidNDK.md b/BuildGuideAndroidNDK.md index 70844564a7..79de1fcf58 100644 --- a/BuildGuideAndroidNDK.md +++ b/BuildGuideAndroidNDK.md @@ -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 .. ``` diff --git a/BuildGuideCrossCompilation.md b/BuildGuideCrossCompilation.md index 156488abca..3a89a309d4 100644 --- a/BuildGuideCrossCompilation.md +++ b/BuildGuideCrossCompilation.md @@ -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 ``` diff --git a/CMakeLists.txt b/CMakeLists.txt index 13d7077de9..8f5a0bd046 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/cmake/GlobalConfig.cmake b/cmake/GlobalConfig.cmake index 3e0f0fe330..2bfca58500 100644 --- a/cmake/GlobalConfig.cmake +++ b/cmake/GlobalConfig.cmake @@ -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}) 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; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 145af1225d..8d3d8320c2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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() diff --git a/tests/ExecuteNetwork/ExecuteNetwork.cpp b/tests/ExecuteNetwork/ExecuteNetwork.cpp index 3c4a03272c..9b79c8c6b4 100644 --- a/tests/ExecuteNetwork/ExecuteNetwork.cpp +++ b/tests/ExecuteNetwork/ExecuteNetwork.cpp @@ -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; diff --git a/tests/ImageCSVFileGenerator/ImageCSVFileGenerator.cpp b/tests/ImageCSVFileGenerator/ImageCSVFileGenerator.cpp index 706a0c0c7a..0d2252dfc9 100644 --- a/tests/ImageCSVFileGenerator/ImageCSVFileGenerator.cpp +++ b/tests/ImageCSVFileGenerator/ImageCSVFileGenerator.cpp @@ -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()); diff --git a/tests/ImageTensorGenerator/ImageTensorGenerator.cpp b/tests/ImageTensorGenerator/ImageTensorGenerator.cpp index 9c23200802..568ba1ee95 100644 --- a/tests/ImageTensorGenerator/ImageTensorGenerator.cpp +++ b/tests/ImageTensorGenerator/ImageTensorGenerator.cpp @@ -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; diff --git a/tests/InferenceModel.hpp b/tests/InferenceModel.hpp index 781cef4ed0..5588d55aaf 100644 --- a/tests/InferenceModel.hpp +++ b/tests/InferenceModel.hpp @@ -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); diff --git a/tests/InferenceTest.cpp b/tests/InferenceTest.cpp index 0391a9af46..b0d0b47443 100644 --- a/tests/InferenceTest.cpp +++ b/tests/InferenceTest.cpp @@ -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; diff --git a/tests/InferenceTest.inl b/tests/InferenceTest.inl index 32a164dc43..362be7bdae 100644 --- a/tests/InferenceTest.inl +++ b/tests/InferenceTest.inl @@ -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> diff --git a/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp b/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp index 85d757f820..be45d9af35 100644 --- a/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp +++ b/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp @@ -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()); } |