mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
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:
committed by
Facebook Github Bot
parent
c9da01194a
commit
c1d6bcf301
@ -41,7 +41,7 @@ ReturnInfo makeReturnsFinal(
|
|||||||
const SourceRange& range,
|
const SourceRange& range,
|
||||||
at::ArrayRef<TreeRef> stmts,
|
at::ArrayRef<TreeRef> stmts,
|
||||||
bool return_none) {
|
bool return_none) {
|
||||||
std::vector<TreeRef> changed;
|
at::SmallVector<TreeRef, 4> changed;
|
||||||
changed.reserve(stmts.size());
|
changed.reserve(stmts.size());
|
||||||
for (size_t i = 0; i < stmts.size(); ++i) {
|
for (size_t i = 0; i < stmts.size(); ++i) {
|
||||||
const TreeRef& stmt = stmts[i];
|
const TreeRef& stmt = stmts[i];
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <torch/csrc/jit/script/lexer.h>
|
#include <torch/csrc/jit/script/lexer.h>
|
||||||
|
#include <c10/util/SmallVector.h>
|
||||||
|
|
||||||
namespace torch {
|
namespace torch {
|
||||||
namespace jit {
|
namespace jit {
|
||||||
@ -29,7 +30,7 @@ namespace script {
|
|||||||
|
|
||||||
struct Tree;
|
struct Tree;
|
||||||
using TreeRef = std::shared_ptr<Tree>;
|
using TreeRef = std::shared_ptr<Tree>;
|
||||||
using TreeList = std::vector<TreeRef>;
|
using TreeList = at::SmallVector<TreeRef, 4>;
|
||||||
|
|
||||||
static const TreeList empty_trees = {};
|
static const TreeList empty_trees = {};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user