mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-03 23:49:44 +00:00
[VitisAI] fix graph save (#21293)
### Description <!-- Describe your changes. --> Revert the wrong change in https://github.com/microsoft/onnxruntime/pull/20920 ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> It would save the data at a wrong position
This commit is contained in:
parent
5df4ddd1c3
commit
dcc04367b7
2 changed files with 5 additions and 6 deletions
|
|
@ -126,7 +126,7 @@ static std::string config_to_json_str(const onnxruntime::ProviderOptions& config
|
|||
|
||||
vaip_core::DllSafe<std::vector<std::unique_ptr<vaip_core::ExecutionProvider>>> compile_onnx_model(
|
||||
const onnxruntime::GraphViewer& graph_viewer, const logging::Logger& logger, const ProviderOptions& options) {
|
||||
auto model_path = PathToUTF8String(ToPathString(graph_viewer.ModelPath().string()));
|
||||
auto model_path = graph_viewer.ModelPath().string();
|
||||
if (s_library_vitisaiep.compile_onnx_model_with_options) {
|
||||
return vaip_core::DllSafe(s_library_vitisaiep.compile_onnx_model_with_options(model_path, graph_viewer.GetGraph(), options));
|
||||
} else {
|
||||
|
|
@ -227,9 +227,9 @@ vaip_core::OrtApiForVaip* create_org_api_hook() {
|
|||
auto& logger = logging::LoggingManager::DefaultLogger();
|
||||
auto& model = const_cast<onnxruntime::Model&>(const_model);
|
||||
auto model_proto = model.ToProto();
|
||||
auto file_path = ToPathString(model.MainGraph().ModelPath().string());
|
||||
auto file_path = model.MainGraph().ModelPath();
|
||||
auto local_registries = IOnnxRuntimeOpSchemaRegistryList{model.MainGraph().GetSchemaRegistry()};
|
||||
auto ret = Model::Create(std::move(*model_proto), file_path, &local_registries, logger);
|
||||
auto ret = Model::Create(std::move(*model_proto), ToPathString(file_path), &local_registries, logger);
|
||||
auto status = ret->MainGraph().Resolve();
|
||||
vai_assert(status.IsOK(), status.ErrorMessage());
|
||||
return ret.release();
|
||||
|
|
|
|||
|
|
@ -107,12 +107,11 @@ void graph_save(const Graph& graph, const std::string& filename, const std::stri
|
|||
auto graph_proto_subgraph = graph.ToGraphProto();
|
||||
*model_proto->mutable_graph() = *graph_proto_subgraph;
|
||||
auto& logger = logging::LoggingManager::DefaultLogger();
|
||||
auto filename_data_relative_path = std::filesystem::path();
|
||||
auto model = Model::Create(std::move(*model_proto), ToPathString(filename), nullptr, logger);
|
||||
if (initializer_size_threshold == std::numeric_limits<size_t>::max()) {
|
||||
model_proto = model->ToProto();
|
||||
} else {
|
||||
model_proto = model->ToGraphProtoWithExternalInitializers(filename_dat, graph.ModelPath(), initializer_size_threshold);
|
||||
model_proto = model->ToGraphProtoWithExternalInitializers(ToPathString(filename_dat), ToPathString(filename), initializer_size_threshold);
|
||||
}
|
||||
auto& metadata = model->MetaData();
|
||||
if (!metadata.empty()) {
|
||||
|
|
@ -124,7 +123,7 @@ void graph_save(const Graph& graph, const std::string& filename, const std::stri
|
|||
*prop->mutable_value() = m.second;
|
||||
}
|
||||
}
|
||||
std::fstream output(filename, std::ios::out | std::ios::trunc | std::ios::binary);
|
||||
std::fstream output(ToPathString(filename), std::ios::out | std::ios::trunc | std::ios::binary);
|
||||
bool result = model_proto->SerializeToOstream(output);
|
||||
output << std::flush;
|
||||
vai_assert(result, "model serialize to ostream error");
|
||||
|
|
|
|||
Loading…
Reference in a new issue