From f3d7dcba14b7d0c7e7a84c00e3abbef457324148 Mon Sep 17 00:00:00 2001 From: Ryan Yu Date: Tue, 5 Mar 2024 17:01:09 +0800 Subject: [PATCH] Modify the filesystem namespace for compatibility Signed-off-by: Ryan Yu --- onnxoptimizer/model_util.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/onnxoptimizer/model_util.cc b/onnxoptimizer/model_util.cc index eacb69e1f..b263ef366 100644 --- a/onnxoptimizer/model_util.cc +++ b/onnxoptimizer/model_util.cc @@ -7,7 +7,7 @@ #include #include // size_t -#include +#include #include #include #include @@ -180,7 +180,7 @@ bool usesExternalData(TensorProto* tensor) { } void loadExternalDataForTensor(TensorProto* tensor, - const std::filesystem::path& base_dir) { + const std::experimental::filesystem::path& base_dir) { ExternalDataInfo info(tensor); auto external_data_file_path = base_dir; external_data_file_path /= (info.location); @@ -212,7 +212,7 @@ void loadExternalDataForTensor(TensorProto* tensor, } void loadExternalDataForModel(ModelProto* m, - const std::filesystem::path& base_dir) { + const std::experimental::filesystem::path& base_dir) { auto tensors = getAllTensors(m); for (auto& tensor : tensors) { if (usesExternalData(tensor)) { @@ -222,7 +222,7 @@ void loadExternalDataForModel(ModelProto* m, } void saveExternalData(TensorProto* tensor, - const std::filesystem::path& base_dir) { + const std::experimental::filesystem::path& base_dir) { ExternalDataInfo info(tensor); auto external_data_file_path = base_dir; external_data_file_path /= (info.location); @@ -262,7 +262,7 @@ void convertModelToExternalData(ModelProto* m, const std::string& location = {}, } void writeExternalDataTensors(ModelProto* m, - const std::filesystem::path& base_dir) { + const std::experimental::filesystem::path& base_dir) { auto tensors = getAllTensors(m); for (auto& tensor : tensors) { if (usesExternalData(tensor) && tensor->has_raw_data()) { @@ -278,7 +278,7 @@ void loadModel(ModelProto* m, const std::string& model_path, bool load_external_data) { LoadProtoFromPath(model_path, *m); if (load_external_data) { - const auto parent_path = std::filesystem::path(model_path).parent_path(); + const auto parent_path = std::experimental::filesystem::path(model_path).parent_path(); loadExternalDataForModel(m, parent_path); } } @@ -289,7 +289,7 @@ void saveModel(ModelProto* m, const std::string& model_path, if (save_external_data) { convertModelToExternalData(m, data_file_name); } - const auto parent_path = std::filesystem::path(model_path).parent_path(); + const auto parent_path = std::experimental::filesystem::path(model_path).parent_path(); writeExternalDataTensors(m, parent_path); std::string serialize;