Use SmallVector to allocate Compound operands inline. (#20762)

Summary:
Reduces load time for serialized ResNet-18 by 5.5%.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/20762

Differential Revision: D15437364

fbshipit-source-id: 2ba34dd229a1054553d0ee09f044ce1915377d78
This commit is contained in:
Owen Anderson
2019-05-21 16:30:01 -07:00
committed by Facebook Github Bot
parent c9da01194a
commit c1d6bcf301
2 changed files with 3 additions and 2 deletions

View File

@ -41,7 +41,7 @@ ReturnInfo makeReturnsFinal(
const SourceRange& range,
at::ArrayRef<TreeRef> stmts,
bool return_none) {
std::vector<TreeRef> changed;
at::SmallVector<TreeRef, 4> changed;
changed.reserve(stmts.size());
for (size_t i = 0; i < stmts.size(); ++i) {
const TreeRef& stmt = stmts[i];

View File

@ -6,6 +6,7 @@
#include <vector>
#include <torch/csrc/jit/script/lexer.h>
#include <c10/util/SmallVector.h>
namespace torch {
namespace jit {
@ -29,7 +30,7 @@ namespace script {
struct Tree;
using TreeRef = std::shared_ptr<Tree>;
using TreeList = std::vector<TreeRef>;
using TreeList = at::SmallVector<TreeRef, 4>;
static const TreeList empty_trees = {};