use irange for loops (#66234)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/66234

Modified loops in files under fbsource/fbcode/caffe2/ from the format

`for(TYPE var=x0;var<x_max;x++)`

to the format

`for(const auto var: irange(xmax))`

This was achieved by running r-barnes's loop upgrader script (D28874212) with some modification to exclude all files under /torch/jit and a number of reversions or unused variable suppression warnings added by hand.

bypass_size_limit
allow-large-files

Test Plan: Sandcastle

Reviewed By: ngimel

Differential Revision: D30652629

fbshipit-source-id: 0ae6c4bbbb554bad42e372792a6430e1acf15e3e
This commit is contained in:
Richard Barnes
2021-10-15 13:48:39 -07:00
committed by Facebook GitHub Bot
parent b5b7d6a3a6
commit 687c2267d4
487 changed files with 22184 additions and 21930 deletions

View File

@ -2,6 +2,7 @@
#include "test/cpp/tensorexpr/test_base.h"
#include <c10/util/irange.h>
#include <torch/csrc/jit/tensorexpr/cpp_codegen.h>
#include <torch/csrc/jit/tensorexpr/fwd_decls.h>
#include <torch/csrc/jit/tensorexpr/stmt.h>
@ -207,7 +208,7 @@ TEST(CppPrinter, Cond) {
TEST(CppPrinter, Intrinsics) {
const std::unordered_set<IntrinsicsOp, std::hash<int>> unsupported_ops{
kRand, kSigmoid};
for (int i = 0; i < kMaxIntrinsicsOp; i++) {
for (const auto i : c10::irange(static_cast<uint32_t>(kMaxIntrinsicsOp))) {
IntrinsicsOp op = static_cast<IntrinsicsOp>(i);
if (unsupported_ops.count(op)) {
continue;