Skip to content

Commit

Permalink
Modernize for-loops (#50912)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #50912

Test Plan: Sandcastle tests

Reviewed By: ansley

Differential Revision: D26001948

fbshipit-source-id: 3bfe6a8283a2b1882ed472f836ae1b6e720e519f
  • Loading branch information
r-barnes authored and facebook-github-bot committed Jan 22, 2021
1 parent 156da22 commit 89cafde
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions test/cpp/api/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ TEST(SerializeTest, Optim_Adagrad) {
std::vector<int64_t> step_buffers;
const auto& params_ = optim1.param_groups()[0].params();
const auto& optim1_state = optim1.state();
for (size_t i = 0; i < params_.size(); i++) {
auto key_ = c10::guts::to_string(params_[i].unsafeGetTensorImpl());
for (const auto & param : params_) {
auto key_ = c10::guts::to_string(param.unsafeGetTensorImpl());
const AdagradParamState& curr_state_ = static_cast<const AdagradParamState&>(*(optim1_state.at(key_).get()));
sum_buffers.emplace_back(curr_state_.sum());
step_buffers.emplace_back(curr_state_.step());
Expand Down
4 changes: 2 additions & 2 deletions test/cpp/jit/test_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class TestBackend : public PyTorchBackendInterface {

// Return the same string as a value for every key in method_compile_spec.
auto handles = c10::Dict<std::string, std::string>();
for (auto it = spec.begin(), end = spec.end(); it != end; ++it) {
handles.insert(it->key(), it->key());
for (const auto& it : spec) {
handles.insert(it.key(), it.key());
}
return c10::impl::toGenericDict(handles);
}
Expand Down
14 changes: 7 additions & 7 deletions test/cpp/jit/test_gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

// fuser and IR parser
#include <torch/csrc/jit/codegen/cuda/parser.h>
#include "torch/csrc/jit/ir/irparser.h"
#include <torch/csrc/jit/ir/irparser.h>

#include <ATen/cuda/Exceptions.h>
#include <c10/cuda/CUDAStream.h>
Expand Down Expand Up @@ -59,9 +59,9 @@ TensorView* makeConcreteTensor(
// We can uncomment the below statement to test all tests with contiguous
// tensors. return makeContigTensor(nDims, dtype);
std::vector<IterDomain*> dom;
for (size_t i = 0; i < sizes.size(); i++) {
if (sizes[i] >= 0) {
dom.push_back(new IterDomain(new Int(0), new Int(sizes[i])));
for (int size : sizes) {
if (size >= 0) {
dom.push_back(new IterDomain(new Int(0), new Int(size)));
} else {
dom.push_back(new IterDomain(new Int(0), new Int()));
}
Expand Down Expand Up @@ -7353,9 +7353,9 @@ TEST(NVFuserTest, FusionLSTMCell_CUDA) {
FusionGuard fg(&fusion);

TensorView* tvs[16];
for (size_t i = 0; i < 16; i++) {
tvs[i] = makeDummyTensor(2);
fusion.addInput(tvs[i]);
for (auto& tv : tvs) {
tv = makeDummyTensor(2);
fusion.addInput(tv);
}

auto ingate = unaryOp(
Expand Down

0 comments on commit 89cafde

Please sign in to comment.