Commit 74f87b1c authored by Sebastian Nickels's avatar Sebastian Nickels

Fixed endless loop when using input or output multiple times

parent d2a60097
Pipeline #180359 failed with stages
in 2 minutes and 28 seconds
......@@ -30,7 +30,7 @@ import java.util.*;
public class LayerNameCreator {
private Map<ArchitectureElementSymbol, String> elementToName = new HashMap<>();
private Map<String, ArchitectureElementSymbol> nameToElement = new HashMap<>();
private Set<String> names = new HashSet<>();
public LayerNameCreator(ArchitectureSymbol architecture) {
int stage = 1;
......@@ -39,11 +39,9 @@ public class LayerNameCreator {
}
for (UnrollSymbol unroll : architecture.getUnrolls()) {
stage = name(unroll.getBody(), stage, new ArrayList<>());
}
}
public ArchitectureElementSymbol getArchitectureElement(String name){
return nameToElement.get(name);
// TODO: Add individual timesteps?
}
}
public String getName(ArchitectureElementSymbol architectureElement){
......@@ -97,24 +95,15 @@ public class LayerNameCreator {
if (!elementToName.containsKey(architectureElement)) {
String name = createName(architectureElement, endStage, streamIndices);
while (nameToElement.containsKey(name)) {
endStage++;
name = createName(architectureElement, endStage, streamIndices);
if (!(architectureElement instanceof VariableSymbol)) {
while (names.contains(name)) {
endStage++;
name = createName(architectureElement, endStage, streamIndices);
}
}
elementToName.put(architectureElement, name);
boolean isLayerVariable = false;
if (architectureElement instanceof VariableSymbol) {
isLayerVariable = ((VariableSymbol) architectureElement).getType() == VariableSymbol.Type.LAYER;
}
// Do not map names of layer variables to their respective element since the names are not unique
// for now the name to element mapping is not used anywhere so it doesn't matter
if (!isLayerVariable) {
nameToElement.put(name, architectureElement);
}
names.add(name);
}
return endStage;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment