mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
use irange for loops 2 (#66746)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/66746 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. Test Plan: Sandcastle Reviewed By: malfet Differential Revision: D31705361 fbshipit-source-id: 33fd22eb03086d114e2c98e56703e8ec84460268
This commit is contained in:
committed by
Facebook GitHub Bot
parent
91d16cb633
commit
29d759948e
@ -24,6 +24,7 @@
|
||||
#include "caffe2/core/operator.h"
|
||||
#include "caffe2/utils/string_utils.h"
|
||||
#include "c10/util/string_utils.h"
|
||||
#include <c10/util/irange.h>
|
||||
|
||||
using std::map;
|
||||
using std::shared_ptr;
|
||||
@ -55,12 +56,12 @@ void writeTextOutput(
|
||||
int dims_size = tensor_proto.dims_size();
|
||||
long long elem_dim_size =
|
||||
dims_size > 1 ? tensor_proto.dims(1) : tensor_proto.dims(0);
|
||||
for (int i = 2; i < dims_size; i++) {
|
||||
for (const auto i : c10::irange(2, dims_size)) {
|
||||
elem_dim_size *= tensor_proto.dims(i);
|
||||
}
|
||||
std::vector<std::string> lines;
|
||||
std::string dims;
|
||||
for (int i = 0; i < dims_size; i++) {
|
||||
for (const auto i : c10::irange(dims_size)) {
|
||||
int dim = tensor_proto.dims(i);
|
||||
if (i > 0) {
|
||||
dims += ", ";
|
||||
|
Reference in New Issue
Block a user