|
3 | 3 | #include <ATen/core/functional.h>
|
4 | 4 | #include <ATen/core/interned_strings.h>
|
5 | 5 | #include <c10/util/Exception.h>
|
| 6 | +#include <c10/util/irange.h> |
6 | 7 | #include <torch/csrc/jit/ir/alias_analysis.h>
|
7 | 8 | #include <torch/csrc/jit/ir/constants.h>
|
8 | 9 | #include <torch/csrc/jit/passes/dead_code_elimination.h>
|
@@ -151,7 +152,7 @@ RegisterOperators mm_tree_reduction_reg({Operator(
|
151 | 152 | push(stack, at::mm(lhs, rhs));
|
152 | 153 | } else {
|
153 | 154 | auto acc = at::mm(inputs[0], inputs[side_num_elems]);
|
154 |
| - for (size_t i = 1; i < side_num_elems; ++i) { |
| 155 | + for (const auto i : c10::irange(1, side_num_elems)) { |
155 | 156 | acc.add_(at::mm(inputs[i], inputs[side_num_elems + i]));
|
156 | 157 | }
|
157 | 158 | push(stack, std::move(acc));
|
@@ -374,7 +375,7 @@ std::pair<std::vector<Node*>, std::vector<Node*>> gatherIndependentMMUses(
|
374 | 375 | // Filter out dependent MMs. This algorithm might do very badly if e.g. you
|
375 | 376 | // have a lot of independent MMs, that depend on the first one, but I doubt
|
376 | 377 | // this will be a common scenario.
|
377 |
| - for (size_t i = 0; i < mms.size(); ++i) { |
| 378 | + for (const auto i : c10::irange(mms.size())) { |
378 | 379 | if (mms[i] == nullptr)
|
379 | 380 | continue;
|
380 | 381 | for (size_t j = i + 1; j < mms.size(); ++j) {
|
@@ -423,7 +424,7 @@ void BatchMMSide(Block* block, AliasDb& alias_db) {
|
423 | 424 | batch_mm->i_(Symbol::attr("side"), static_cast<int>(side));
|
424 | 425 | Value* const_side = mms[0]->inputs().at(side == Side::LHS ? 0 : 1);
|
425 | 426 | batch_mm->addInput(const_side);
|
426 |
| - for (size_t i = 0; i < mms.size(); ++i) { |
| 427 | + for (const auto i : c10::irange(mms.size())) { |
427 | 428 | batch_mm->addInput(mms[i]->inputs().at(side == Side::LHS ? 1 : 0));
|
428 | 429 | mms[i]->output()->replaceAllUsesWith(batch_mm->outputs().at(i));
|
429 | 430 | }
|
|
0 commit comments