From 007c84d684edfc81a76e9485588f70db73b7ae2e Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Wed, 8 Jan 2025 15:25:48 +0100 Subject: [PATCH] imx-machine-learning: onnxruntime: fix compilation error This mirrors the change done for the STM version of the recipe in meta-digi commit b7c15294a2a3, re-using the same patch that was used to fix the compilation error introduced by poky commit 19fce77a5f13. Signed-off-by: Gabriel Valcazar --- ...pe-to-prevent-copying-the-entire-con.patch | 43 +++++++++++++++++++ .../onnxruntime/onnxruntime_%.bbappend | 7 +++ 2 files changed, 50 insertions(+) create mode 100644 meta-digi-dey/dynamic-layers/imx-machine-learning/recipes-libraries/onnxruntime/files/0001-Use-reference-type-to-prevent-copying-the-entire-con.patch create mode 100644 meta-digi-dey/dynamic-layers/imx-machine-learning/recipes-libraries/onnxruntime/onnxruntime_%.bbappend diff --git a/meta-digi-dey/dynamic-layers/imx-machine-learning/recipes-libraries/onnxruntime/files/0001-Use-reference-type-to-prevent-copying-the-entire-con.patch b/meta-digi-dey/dynamic-layers/imx-machine-learning/recipes-libraries/onnxruntime/files/0001-Use-reference-type-to-prevent-copying-the-entire-con.patch new file mode 100644 index 000000000..d328e1328 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/imx-machine-learning/recipes-libraries/onnxruntime/files/0001-Use-reference-type-to-prevent-copying-the-entire-con.patch @@ -0,0 +1,43 @@ +From: Arturo Buzarra +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 +--- + .../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)); + } + +-- diff --git a/meta-digi-dey/dynamic-layers/imx-machine-learning/recipes-libraries/onnxruntime/onnxruntime_%.bbappend b/meta-digi-dey/dynamic-layers/imx-machine-learning/recipes-libraries/onnxruntime/onnxruntime_%.bbappend new file mode 100644 index 000000000..83a6f2f7e --- /dev/null +++ b/meta-digi-dey/dynamic-layers/imx-machine-learning/recipes-libraries/onnxruntime/onnxruntime_%.bbappend @@ -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 \ +"