in tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/op/NameScope.java [58:91]
void importIdsFrom(ExecutionEnvironment env) {
if (env instanceof Graph) {
((Graph) env)
.operations()
.forEachRemaining(
op -> {
if (op.name().startsWith(opPrefix != null ? opPrefix : "")) {
String name = op.name();
if (opPrefix != null) {
name = name.substring(opPrefix.length() + 1);
}
if (!name.contains("/")) {
Matcher matcher = NAME_PATTERN.matcher(name);
if (matcher.find()) {
String realName = matcher.group(1);
int num = Integer.parseInt(matcher.group(2)) + 1;
if (!(ids.containsKey(realName) && ids.get(realName) > num)) {
ids.put(realName, num);
}
} else {
if (!ids.containsKey(name)) {
ids.put(name, 1);
} else {
ids.put(name, ids.get(name) + 1);
}
}
}
}
});
}
}