Skip to content

Commit

Permalink
Fix some move warnings by gcc13 (pytorch#102353)
Browse files Browse the repository at this point in the history
GCC 13 has improved warnings about std::move. This PR tries to fix some detected code issues.

Pull Request resolved: pytorch#102353
Approved by: https://github.com/ezyang
  • Loading branch information
cyyever authored and pytorchmergebot committed May 27, 2023
1 parent 26f53bb commit d7eec56
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions aten/src/ATen/core/ivalue_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2100,8 +2100,7 @@ template <
guts::negation<std::is_constructible<IValue, Args>>...>::value,
std::nullptr_t>>
inline IValue::IValue(const std::tuple<Args...>& t)
: IValue(
std::move(c10::guts::apply(c10::ivalue::Tuple::create<const Args&...>, t))) {
: IValue(c10::guts::apply(c10::ivalue::Tuple::create<const Args&...>, t)) {
}

template <
Expand All @@ -2112,8 +2111,7 @@ template <
guts::negation<std::is_constructible<IValue, Args>>...>::value,
std::nullptr_t>>
inline IValue::IValue(std::tuple<Args...>&& t)
: IValue(
std::move(c10::guts::apply(c10::ivalue::Tuple::create<Args&&...>, std::move(t)))) {
: IValue(c10::guts::apply(c10::ivalue::Tuple::create<Args&&...>, std::move(t))) {
}

inline IValue::IValue(c10::intrusive_ptr<ivalue::ConstantString> v)
Expand Down
4 changes: 2 additions & 2 deletions aten/src/ATen/native/TensorAdvancedIndexingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const Tensor& value){
int64_t num_ind = 0;
Tensor mask;
auto self_device = self.device();
for (const c10::optional<Tensor> i: indices) {
for (const c10::optional<Tensor>& i: indices) {
if (!i.has_value() || !(*i).defined()){
num_ind++;
} else {
Tensor index = std::move(*i);
const Tensor &index = *i;
if ((index.scalar_type() != kByte && index.scalar_type() != kBool) ||
index.device() != self_device || mask.defined()){
return std::make_tuple(false, Tensor());
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/native/mkldnn/ConvPrepack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ ContextConv create(
{stride_expanded.begin(), stride_expanded.end()},
{dilation_expanded.begin(), dilation_expanded.end()},
groups,
std::move(attr)};
attr};
}

void _mkldnn_convolution_out(
Expand Down

0 comments on commit d7eec56

Please sign in to comment.