Skip to content

Commit

Permalink
Cache begin/end iterators in min/max extraction loop
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 627174757
  • Loading branch information
paulinesho authored and tensorflower-gardener committed Apr 22, 2024
1 parent bb981f1 commit 7cdc494
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -396,7 +396,9 @@ void ExtractMinMaxFromAttr(const DenseFPElementsAttr values, const int dim_size,
}
} else {
int64_t flatten_index = 0;
for (auto it = values.begin(); it != values.end(); ++it, ++flatten_index) {
auto begin = values.begin();
auto end = values.end();
for (auto it = begin; it != end; ++it, ++flatten_index) {
const double ele_value = FloatAttr::getValueAsDouble(*it);
const int slice_index = flatten_index / slice_size;
const int channel_index = slice_index % dim_size;
Expand Down

0 comments on commit 7cdc494

Please sign in to comment.