Skip to content

Commit

Permalink
Remove post-processing after ov::Model read that caused memory increase
Browse files Browse the repository at this point in the history
  • Loading branch information
javier-intel committed Dec 6, 2024
1 parent 77a4099 commit 952d15f
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions onnxruntime/core/providers/openvino/backend_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,16 @@ CreateOVModel(const ONNX_NAMESPACE::ModelProto& model_proto, const GlobalContext
}
const std::string model = model_proto.SerializeAsString();
try {
auto cnn_network = global_context.ie_core.ReadModel(model, global_context.onnx_model_path_name);
auto ov_model = global_context.ie_core.ReadModel(model, global_context.onnx_model_path_name);

// Check for Constant Folding
if (!global_context.is_wholly_supported_graph) {
ov::pass::ConstantFolding pass_const_obj;
pass_const_obj.run_on_model(cnn_network);
auto& results = const_cast<ov::ResultVector&>(cnn_network.get()->get_results());
size_t index = results.size() - 1;

for (auto it = results.rbegin(); it != results.rend(); ++it) {
if (auto const_node =
std::dynamic_pointer_cast<ov::op::v0::Constant>((*it)->input_value(0).get_node_shared_ptr())) {
const_outputs_map[(*it)->get_friendly_name()] = const_node;
results.erase(results.begin() + index);
}
--index;
}
}
#ifndef NDEBUG
if (IsDebugEnabled()) {
std::string name = cnn_network->get_friendly_name();
ov::pass::Serialize serializer(name + ".xml", name + ".bin");
serializer.run_on_model(cnn_network);
}
#endif
return cnn_network;
return ov_model;
} catch (std::string const& msg) {
ORT_THROW(msg);
}
Expand Down

0 comments on commit 952d15f

Please sign in to comment.