From 61bbf4bfcca32a8bdc96807a223e8d636c401afe Mon Sep 17 00:00:00 2001 From: Pranav Sharma Date: Wed, 23 Jan 2019 21:19:31 -0800 Subject: [PATCH] Fix redundant population of output_indices_ in the execution frame and reserve memory for it in advance. (#375) --- onnxruntime/core/framework/execution_frame.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/onnxruntime/core/framework/execution_frame.cc b/onnxruntime/core/framework/execution_frame.cc index 9e3c122f21..4a793167ff 100644 --- a/onnxruntime/core/framework/execution_frame.cc +++ b/onnxruntime/core/framework/execution_frame.cc @@ -338,20 +338,14 @@ void ExecutionFrame::Init(const onnxruntime::GraphViewer& graph, } // 4. Handle non-empty output vector - // setup output_indices_, we dont' want to generate mem plan on output tensors. - for (const auto& oname : output_names) { - int mlvalue_idx; - Status status = mlvalue_idx_map.GetIdx(oname, mlvalue_idx); - ORT_ENFORCE(status.IsOK(), status.ErrorMessage()); - output_indices_.push_back(mlvalue_idx); - } - if (!fetches.empty()) { // should've already verified this much before when Run() starts ORT_ENFORCE(output_names.size() == fetches.size(), "output_names vector size: " + std::to_string(output_names.size()) + " does not match that of fetches vector: " + std::to_string(fetches.size())); + // setup output_indices_, we dont' want to generate mem plan on output tensors. + output_indices_.reserve(output_names.size()); auto idx = 0; for (const auto& oname : output_names) { int mlvalue_idx;