Skip to content

Commit a1a39c1

Browse files
committed
Responded to comments
1 parent fcf71e2 commit a1a39c1

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

aten/src/ATen/core/List_inl.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,10 @@ void ListPtr<T>::push_back(T&& value) const {
180180

181181
template<class T>
182182
void ListPtr<T>::append(ListPtr<T> b) const {
183-
size_type neededSize = this->size() + b.size();
184-
if (impl_->list.capacity() < neededSize) {
185-
this->reserve(std::max(impl_->list.capacity() * 2, neededSize));
186-
}
187183
if (b.use_count() == 1) {
188-
std::move(b.begin(), b.end(), this->begin());
184+
impl_->list.insert(impl_->list.end(), make_move_iterator(b.impl_->list.begin()), make_move_iterator(b.impl_->list.end()));
189185
} else {
190-
for (const auto& el: b) {
191-
this->push_back(el);
192-
}
186+
impl_->list.insert(impl_->list.end(), b.impl_->list.begin(), b.impl_->list.end());
193187
}
194188
}
195189

torch/csrc/jit/register_prim_ops.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ int listInplaceAdd(Stack& stack) {
15591559
c10::ListPtr<T> a = c10::make_list<T>();
15601560
c10::ListPtr<T> b = c10::make_list<T>();
15611561
pop(stack, a, b);
1562-
a.append(b);
1562+
a.append(std::move(b));
15631563
push(stack, std::move(a));
15641564
return 0;
15651565
}

torch/csrc/jit/script/compiler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,6 @@ struct to_ir {
16341634
// If it's a list of scalars, then return the corresponding list augment op
16351635
Symbol getAugOp(const AugAssign& stmt, const TypePtr& type) {
16361636
if (type->cast<ListType>()) { // Lists also have in-place ops.
1637-
std::cout<<"generating list op"<<std::endl;
16381637
switch (stmt.aug_op()) {
16391638
case '+':
16401639
return aten::add_;

0 commit comments

Comments
 (0)