[AI Codemod][DevmatePerfOptimizationVectorReallocation] fbcode/caffe2/torch/csrc/jit/serialization/unpickler.cpp (#163240)

Reviewed By: marksantaniello, yfeldblum

Differential Revision: D82140619

Pull Request resolved: https://github.com/pytorch/pytorch/pull/163240
Approved by: https://github.com/Skylion007
This commit is contained in:
Yedidya Feldblum
2025-09-20 23:26:24 +00:00
committed by PyTorch MergeBot
parent 9e3725e8e5
commit 8e3fd3d4f9

View File

@ -261,9 +261,8 @@ void Unpickler::run() {
void Unpickler::setInput(size_t memo_id) {
AT_ASSERT(!stack_.empty());
if (memo_id >= memo_table_.size()) {
memo_table_.insert(
memo_table_.end(), memo_id - memo_table_.size(), IValue());
memo_table_.push_back(stack_.back());
memo_table_.resize(memo_id + 1);
memo_table_[memo_id] = stack_.back();
} else {
memo_table_[memo_id] = stack_.back();
}