Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the filesystem namespace for compatibility #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions onnxoptimizer/model_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <algorithm>
#include <cstddef> // size_t
#include <filesystem>
#include <experimental/filesystem>
#include <fstream>
#include <limits>
#include <numeric>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down Expand Up @@ -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()) {
Expand All @@ -278,7 +278,7 @@ void loadModel(ModelProto* m, const std::string& model_path,
bool load_external_data) {
LoadProtoFromPath<ModelProto>(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);
}
}
Expand All @@ -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;
Expand Down