From 7421755198cefc4680332d52db3e444fa9d463f8 Mon Sep 17 00:00:00 2001 From: ybrnathan <7902510+ybrnathan@users.noreply.github.com> Date: Thu, 23 May 2019 10:59:36 -0700 Subject: [PATCH] Optimize ExecutionFrame to avoid mem re-allocation. (#1085) --- onnxruntime/core/framework/execution_frame.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/onnxruntime/core/framework/execution_frame.cc b/onnxruntime/core/framework/execution_frame.cc index 3dc87b1e02..91a5462991 100644 --- a/onnxruntime/core/framework/execution_frame.cc +++ b/onnxruntime/core/framework/execution_frame.cc @@ -190,6 +190,8 @@ ExecutionFrame::ExecutionFrame(const std::vector& feed_mlvalue_idxs, const if (session_state.GetEnableMemoryPattern() && session_state.GetExecutionPlan()) { std::vector input_shapes; bool all_tensors = true; + // Reserve mem to avoid re-allocation. + input_shapes.reserve(feeds.size()); for (const auto& feed : feeds) { if (!(feed.IsTensor())) { all_tensors = false;