From 532a29d12d72f54549d8b71edd485c17af65698a Mon Sep 17 00:00:00 2001 From: Francis Murtagh Date: Mon, 29 Jun 2020 11:50:01 +0100 Subject: IVGCVSW-4487 Remove boost::filesystem * Replace filesystem::path * Replace filesystem::exists * Replace filesystem::is_directory * Replace filesystem::directory_iterator * Replace filesystem::filesystem_error exception * Replace filesystem::temp_directory_path * Replace filesystem::unique path * Replace filesystem::ofstream with std::ofstream * Replace filesystem::remove * Replace filesystem::is_regular_file * Replace boost::optional with armnn::Optional in touched files * Remove some superfluous includes * Update build guides, GlobalConfig.cmake and CMakeLists.txt * Remove redundant armnnUtils::Filesystem::Remove function. * Remove redundant armnnUtils::Filesystem::GetFileSize function. Temporarily adding back Boost::filesystem to enable Boost::dll. Signed-off-by: Francis Murtagh Signed-off-by: Colm Donelan Change-Id: Ifa46d4a0097d2612ddacd8e9736c0b36e365fb11 --- tests/CMakeLists.txt | 8 +------- tests/ExecuteNetwork/ExecuteNetwork.cpp | 2 +- tests/ImageCSVFileGenerator/ImageCSVFileGenerator.cpp | 18 +++++++----------- tests/ImageTensorGenerator/ImageTensorGenerator.cpp | 16 +++++++--------- tests/InferenceModel.hpp | 10 +++++----- tests/InferenceTest.cpp | 7 +++---- tests/InferenceTest.inl | 2 -- .../ModelAccuracyTool-Armnn.cpp | 17 ++++++++--------- 8 files changed, 32 insertions(+), 48 deletions(-) (limited to 'tests') 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 -#include -#include +#include #include #include @@ -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 #include +#include -#include -#include -#include #include #include @@ -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 #endif +#include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include #include #include @@ -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 +#include #include "../src/armnn/Profiling.hpp" #include -#include #include #include -#include #include #include @@ -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 #include -#include #include #include -#include #include #include 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 -#include #include #include #include @@ -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 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 inputDataContainers; vector 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 LoadValidationImageFilenamesAndLabels(const string // Populate imageFilenames with names of all .JPEG, .PNG images std::vector 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(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()); } -- cgit v1.2.1