}
}
-std::pair<string, int> ParseTensorName(string name, int default_idx = 0) {
+std::pair<string, int> ParseTensorName(const string& name,
+ int default_idx = 0) {
+ string name_no_idx = name;
int idx = default_idx;
- size_t sep = name.find_last_of(':');
+ const size_t sep = name_no_idx.find_last_of(':');
if (sep != string::npos) {
- name = name.substr(0, sep);
+ name_no_idx = name_no_idx.substr(0, sep);
idx = std::stoi(name.substr(sep + 1));
}
- return std::make_pair(name, idx);
+ return std::make_pair(name_no_idx, idx);
}
std::unordered_map<string, std::vector<int>> BuildTensorNameMap(
const std::vector<string>& tensor_names) {
std::unordered_map<string, std::vector<int>> result;
- for (string const& tensor_name : tensor_names) {
+ for (const string& tensor_name : tensor_names) {
string node_name;
int index;
std::tie(node_name, index) = ParseTensorName(tensor_name);
}
return result;
}
+
// TODO(sami): convert references to pointers
struct ConvertGraphParams {
ConvertGraphParams(