mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
Fix for gcc 13.3.1: Avoid creating a copy (#23500)
### Description
This change avoids creating loop variable copy. GCC 13.3 suggests to use
reference type to prevent copying.
### Motivation and Context
While building onnxruntime 1.20.1 with latest changes from gcc 13.3, I
get build error like
```
onnxruntime-1.20.1/onnxruntime/core/optimizer/selectors_actions/selector_action_transformer.cc: In function 'onnxruntime::common::Status onnxruntime::MatchAndProcess(Graph&, const GraphViewer&, Node&, bool&, const logging::Logger&, const std::string&, const SelectorActionRegistry&, const SatRuntimeOptimizationSaveContext*)':
onnxruntime-1.20.1/onnxruntime/core/optimizer/selectors_actions/selector_action_transformer.cc:150:23: error: loop variable 'op_schema' creates a copy from type 'const gsl::not_null<const onnx::OpSchema*>' [-Werror=range-loop-construct]
150 | for (const auto op_schema : action_saved_state.produced_node_op_schemas) {
| ^~~~~~~~~
onnxruntime-1.20.1/onnxruntime/core/optimizer/selectors_actions/selector_action_transformer.cc:150:23: note: use reference type to prevent copying
150 | for (const auto op_schema : action_saved_state.produced_node_op_schemas) {
| ^~~~~~~~~
| &
```
This commit is contained in:
parent
96ec1dd134
commit
fdde2e25e1
2 changed files with 2 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -921,7 +921,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));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue