From b7c15294a2a367b3242457f74bcc0913d9609e09 Mon Sep 17 00:00:00 2001 From: Arturo Buzarra Date: Tue, 7 Jan 2025 15:03:16 +0100 Subject: [PATCH] x-linux-ai: recipes-frameworks: fix build issue with onnxruntime recipe This commit adds a patch to address a build issue with the onnxruntime recipe when warnings are treated as errors. The issue happens due to changes in commit 19fce77a5f132c569c555e8b6a4dda1379537653 ("gcc: Fix c++: tweak for Wrange-loop-construct") in the poky layer. Signed-off-by: Arturo Buzarra --- ...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/x-linux-ai/recipes-frameworks/onnxruntime/files/0001-Use-reference-type-to-prevent-copying-the-entire-con.patch create mode 100644 meta-digi-dey/dynamic-layers/x-linux-ai/recipes-frameworks/onnxruntime/onnxruntime_%.bbappend diff --git a/meta-digi-dey/dynamic-layers/x-linux-ai/recipes-frameworks/onnxruntime/files/0001-Use-reference-type-to-prevent-copying-the-entire-con.patch b/meta-digi-dey/dynamic-layers/x-linux-ai/recipes-frameworks/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/x-linux-ai/recipes-frameworks/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/x-linux-ai/recipes-frameworks/onnxruntime/onnxruntime_%.bbappend b/meta-digi-dey/dynamic-layers/x-linux-ai/recipes-frameworks/onnxruntime/onnxruntime_%.bbappend new file mode 100644 index 000000000..83a6f2f7e --- /dev/null +++ b/meta-digi-dey/dynamic-layers/x-linux-ai/recipes-frameworks/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 \ +"