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;