[caffe2] fix -Wrange-loop-construct in onnx_exporter.cc (#56759)

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

```
 caffe2/caffe2/onnx/onnx_exporter.cc:415:21: error: loop variable 'it' creates a copy from type 'const std::pair<const std::basic_string<char>, int>' [-Werror,-Wrange-loop-construct]
    for (const auto it : blob_versions) {
                    ^
caffe2/caffe2/onnx/onnx_exporter.cc:415:10: note: use reference type 'const std::pair<const std::basic_string<char>, int> &' to prevent copying
    for (const auto it : blob_versions) {
         ^~~~~~~~~~~~~~~
                    &
```

Reviewed By: yfeldblum

Differential Revision: D27960126

fbshipit-source-id: fd46f37cf1aca9441209de8eb06add204046db95
This commit is contained in:
Igor Sugak
2021-04-24 13:12:44 -07:00
committed by Facebook GitHub Bot
parent 4ef8205104
commit 51bca2ca4d

View File

@ -412,7 +412,7 @@ std::unordered_map<std::string, std::string> SsaRewrite(
// output. If so add a mapping from it's latest renamed version to its
// original name.
std::unordered_map<std::string, std::string> renamed_external_outputs;
for (const auto it : blob_versions) {
for (const auto& it : blob_versions) {
if (external_outputs.count(it.first)) {
renamed_external_outputs.emplace(
SsaName(it.first, it.second), it.first);