MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetUniqueName

Method GetUniqueName

tensorflow/cc/framework/scope.cc:360–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358}
359
360string Scope::Impl::GetUniqueName(const string& prefix,
361 bool check_single_use) const {
362 if (check_single_use && single_use_scope()) {
363 if (*scope_used_) {
364 *status_ =
365 errors::AlreadyExists(prefix, " already exists in the current scope");
366 return "";
367 }
368 *scope_used_ = true;
369 return prefix;
370 }
371 auto entry = name_map_->find(prefix);
372 if (entry == name_map_->end()) {
373 name_map_->insert({prefix, 0});
374 return prefix;
375 }
376 string unique_name;
377 do {
378 unique_name = strings::StrCat(prefix, kSuffixSeparator, ++entry->second);
379 } while (name_map_->find(unique_name) != name_map_->end());
380 name_map_->insert({unique_name, 0});
381 return unique_name;
382}
383
384string Scope::Impl::GetNameForOp(const string& default_name) const {
385 const string unique_name =

Callers 1

NewSubScopeMethod · 0.45

Calls 4

StrCatFunction · 0.50
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected