From: Scott Wolchok Date: Mon, 30 Aug 2021 16:34:24 +0000 (-0700) Subject: [PyTorch] Fix missing move in unpickler (#63974) X-Git-Tag: accepted/tizen/8.0/unified/20231005.095509~599 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=16ecdbbaa2a24debae1c80b441bbea945d61d02d;p=platform%2Fupstream%2Fpytorch.git [PyTorch] Fix missing move in unpickler (#63974) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63974 Saw some time spent in this for model loading, no reason not to move here. ghstack-source-id: 136760979 Test Plan: Re-profile model loading on devserver; IValue copy ctor time has gone down Reviewed By: dhruvbird Differential Revision: D30548923 fbshipit-source-id: 42000f2e18582762b43353cca10ae094833de3b3 --- diff --git a/torch/csrc/jit/serialization/unpickler.cpp b/torch/csrc/jit/serialization/unpickler.cpp index f944387..b521dc8 100644 --- a/torch/csrc/jit/serialization/unpickler.cpp +++ b/torch/csrc/jit/serialization/unpickler.cpp @@ -318,7 +318,7 @@ PickleOpCode Unpickler::readInstruction() { tuple->elements().reserve(stack_.size() - start); auto start_it = stack_.begin() + start; for (auto it = start_it; it != stack_.end(); ++it) { - tuple->elements().emplace_back(*it); + tuple->elements().emplace_back(std::move(*it)); } stack_.erase(start_it, stack_.end()); stack_.emplace_back(std::move(tuple));