imx-machine-learning: onnxruntime: fix compilation error

This mirrors the change done for the STM version of the recipe in meta-digi
commit b7c15294a2, re-using the same patch that was used to fix the
compilation error introduced by poky commit 19fce77a5f13.

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
Gabriel Valcazar 2025-01-08 15:25:48 +01:00
parent b7c15294a2
commit 007c84d684
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,43 @@
From: Arturo Buzarra <arturo.buzarra@digi.com>
Date: Tue, 7 Jan 2025 14:03:27 +0100
Subject: [PATCH] Use reference type to prevent copying the entire container
The loop variable creates a copy of each element in the container. For large or
complex objects, this approach is costly in terms of memory and performance.
Changing the loop variable to a reference type prevents unnecessary copying and
improves efficiency. Additionally, this change addresses a build issue with the
compiler when warnings are treated as errors
Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
---
.../optimizer/selectors_actions/selector_action_transformer.cc | 2 +-
onnxruntime/core/session/inference_session.cc | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/onnxruntime/core/optimizer/selectors_actions/selector_action_transformer.cc b/onnxruntime/core/optimizer/selectors_actions/selector_action_transformer.cc
index b68cbaf85b..b1d6c51f69 100644
--- a/onnxruntime/core/optimizer/selectors_actions/selector_action_transformer.cc
+++ b/onnxruntime/core/optimizer/selectors_actions/selector_action_transformer.cc
@@ -147,7 +147,7 @@ static Status MatchAndProcess(
RuntimeOptimizationRecord::ProducedOpIdVector produced_op_ids{};
produced_op_ids.reserve(action_saved_state.produced_node_op_schemas.size());
- for (const auto op_schema : action_saved_state.produced_node_op_schemas) {
+ for (const auto& op_schema : action_saved_state.produced_node_op_schemas) {
produced_op_ids.push_back(utils::MakeOpId(*op_schema));
if (save_context->record_produced_node_op_schema) {
status = save_context->record_produced_node_op_schema(*op_schema);
diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc
index 5eed7c5c6f..5352d69044 100644
--- a/onnxruntime/core/session/inference_session.cc
+++ b/onnxruntime/core/session/inference_session.cc
@@ -899,7 +899,7 @@ common::Status InferenceSession::SaveToOrtFormat(const std::filesystem::path& fi
ORT_RETURN_IF_ERROR(kernel_type_str_resolver.RegisterGraphNodeOpSchemas(model_->MainGraph()));
ORT_RETURN_IF_ERROR(standalone::RegisterCustomOpNodeSchemas(kernel_type_str_resolver, model_->MainGraph()));
- for (const auto op_schema : saved_runtime_optimization_produced_node_op_schemas_) {
+ for (const auto& op_schema : saved_runtime_optimization_produced_node_op_schemas_) {
ORT_RETURN_IF_ERROR(kernel_type_str_resolver.RegisterOpSchema(*op_schema));
}
--

View File

@ -0,0 +1,7 @@
# Copyright (C) 2025, Digi International Inc.
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI += " \
file://0001-Use-reference-type-to-prevent-copying-the-entire-con.patch \
"