From 9eb8b29da63562782782e780b4dbc283ff067c78 Mon Sep 17 00:00:00 2001 From: liumingyue Date: Mon, 20 Oct 2025 21:57:46 -0600 Subject: [PATCH] use std::move(model_proto) to avoid extra copy Previously, model_proto was passed by name, which triggered a copy constructor call instead of move construction. Using std::move(model_proto) ensures that the object is constructed via move semantics, reducing unnecessary memory allocation and copy overhead. --- onnxruntime/core/session/provider_bridge_ort.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime/core/session/provider_bridge_ort.cc b/onnxruntime/core/session/provider_bridge_ort.cc index 960b9eff051be..40ab0de5abace 100644 --- a/onnxruntime/core/session/provider_bridge_ort.cc +++ b/onnxruntime/core/session/provider_bridge_ort.cc @@ -1239,7 +1239,7 @@ struct ProviderHostImpl : ProviderHost { std::unique_ptr Model__construct(ONNX_NAMESPACE::ModelProto&& model_proto, const PathString& model_path, const IOnnxRuntimeOpSchemaRegistryList* local_registries, const logging::Logger& logger) override { - return std::make_unique(model_proto, model_path, local_registries, logger); + return std::make_unique(std::move(model_proto), model_path, local_registries, logger); } std::unique_ptr Model__construct(const std::string& graph_name, bool is_onnx_domain_only,