mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
use irange for loops 5 (#66744)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/66744 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: ngimel Differential Revision: D31705358 fbshipit-source-id: d6ea350cbaa8f452fc78f238160e5374be637a48
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bceb1db885
commit
e0643fa3fc
@ -1706,7 +1706,7 @@ void concrete_dispatch_fn(
|
||||
}
|
||||
|
||||
// Find overloaded tensors
|
||||
for (int64_t idx = 0; idx < arguments.size(); idx++) {
|
||||
for (const auto idx : c10::irange(arguments.size())) {
|
||||
const auto& ivalue = arguments[idx];
|
||||
if (ivalue.isTensor()) {
|
||||
const auto& tensor = ivalue.toTensor();
|
||||
@ -1728,12 +1728,12 @@ void concrete_dispatch_fn(
|
||||
}
|
||||
|
||||
// Populate positional arguments
|
||||
for (int64_t idx = 0; idx < positional_default_start; idx++) {
|
||||
for (const auto idx : c10::irange(positional_default_start)) {
|
||||
PyTuple_SET_ITEM(args.ptr(), idx, torch::jit::toPyObject(std::move(arguments[idx])).release().ptr());
|
||||
}
|
||||
|
||||
// Populate keyword arguments
|
||||
for (int64_t idx = kwarg_only_start; idx < arguments.size(); idx++) {
|
||||
for (const auto idx : c10::irange(kwarg_only_start, arguments.size())) {
|
||||
// But don't populate default keyword arguments
|
||||
if (is_default(idx)) continue;
|
||||
const auto& arg = schema.arguments()[idx];
|
||||
|
Reference in New Issue
Block a user