Commit 180da9b6 authored by Sebastian Nickels's avatar Sebastian Nickels
Browse files

Fixed a bug where input/outputs with CONST_OFFSET index were added to global inputs/outputs

parent 09301be7
Pipeline #180406 passed with stages
in 17 minutes and 21 seconds
......@@ -61,7 +61,6 @@ public class CheckIOAccessAndIOMissing extends CNNArchSymbolCoCo {
}
}
private void checkIOArray(IODeclarationSymbol ioDeclaration){
List<Integer> unusedIndices = IntStream.range(0, ioDeclaration.getArrayLength()).boxed().collect(Collectors.toList());
......@@ -72,22 +71,10 @@ public class CheckIOAccessAndIOMissing extends CNNArchSymbolCoCo {
unusedIndices.remove(arrayAccess.get());
}
else {
ArchitectureSymbol architecture = ioDeclaration.getArchitecture();
boolean isUnroll = false;
for (NetworkInstructionSymbol networkInstruction : architecture.getNetworkInstructions()) {
if (networkInstruction.isUnroll()) {
isUnroll = contains(networkInstruction.getBody(), ioElement);
}
}
// Allow invalid indices in UnrollSymbols
if (!isUnroll) {
Log.error("0" + ErrorCodes.INVALID_ARRAY_ACCESS + " The IO array access value of '" + ioElement.getName() +
"' must be an integer between 0 and " + (ioDeclaration.getArrayLength()-1) + ". " +
"The current value is: " + ioElement.getArrayAccess().get().getValue().get().toString()
Log.error("0" + ErrorCodes.INVALID_ARRAY_ACCESS + " The IO array access value of '" + ioElement.getName() +
"' must be an integer between 0 and " + (ioDeclaration.getArrayLength()-1) + ". " +
"The current value is: " + ioElement.getArrayAccess().get().getValue().get().toString()
, ioElement.getSourcePosition());
}
}
}
else{
......@@ -102,21 +89,4 @@ public class CheckIOAccessAndIOMissing extends CNNArchSymbolCoCo {
}
}
private boolean contains(ArchitectureElementSymbol element, ArchitectureElementSymbol containedElement) {
ArchitectureElementSymbol resolvedElement = (ArchitectureElementSymbol) element.getResolvedThis().get();
if (resolvedElement instanceof CompositeElementSymbol) {
List<ArchitectureElementSymbol> constructedElements = ((CompositeElementSymbol) resolvedElement).getElements();
for (ArchitectureElementSymbol constructedElement : constructedElements) {
if (contains(constructedElement, containedElement)) {
return true;
}
}
}
return resolvedElement.equals(containedElement);
}
}
......@@ -92,15 +92,22 @@ public class ArchitectureSymbol extends CommonScopeSpanningSymbol {
return this.componentName;
}
public List<VariableSymbol> getInputs() {
return inputs;
}
public void setInputs(List<VariableSymbol> inputs) {
this.inputs = inputs;
}
public List<VariableSymbol> getOutputs() {
return outputs;
}
public void setOutputs(List<VariableSymbol> outputs) {
this.outputs = outputs;
}
public Collection<IODeclarationSymbol> getIODeclarations(){
return getEnclosingScope().resolveLocally(IODeclarationSymbol.KIND);
}
......
......@@ -106,9 +106,20 @@ public class UnrollInstructionSymbol extends NetworkInstructionSymbol {
int startValue = getTimeParameter().getDefaultExpression().get().getIntValue().get();
int endValue = getIntValue(AllPredefinedLayers.MAX_LENGTH_NAME).get();
List<VariableSymbol> inputs = new ArrayList<>(getArchitecture().getInputs());
List<VariableSymbol> outputs = new ArrayList<>(getArchitecture().getOutputs());
// body is resolved and only used for network generation, t is set to CONST_OFFSET which results in
// high array indices to avoid clashing with regular array indices, e.g. when having a network with
// (target[0] | target[t-1]) as input, we generate one network and call it multiple times with different
// arguments for each timestep t
getTimeParameter().getExpression().setValue(CONST_OFFSET);
getBody().resolveOrError();
// we do not want those inputs and outputs with CONST_OFFSET as array index in our global inputs/outputs
getArchitecture().setInputs(inputs);
getArchitecture().setOutputs(outputs);
for (int timestep = startValue; timestep < endValue; timestep++) {
SerialCompositeElementSymbol currentBody = getBody().preResolveDeepCopy();
currentBody.putInScope(getBody().getSpannedScope());
......@@ -121,7 +132,6 @@ public class UnrollInstructionSymbol extends NetworkInstructionSymbol {
bodies.add(currentBody);
}
UnrollInstructionSymbol resolvedUnroll = getDeclaration().call(this);
setResolvedThis(resolvedUnroll);
}
......
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