Commit 943f46b4 authored by Christian Fuß's avatar Christian Fuß

added support for Unrolls as Instructions

parent ae83f562
Pipeline #172963 failed with stages
package de.monticore.lang.monticar.cnnarch.generator;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureElementSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.CompositeElementSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.ConstantSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.SerialCompositeElementSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.*;
import de.se_rwth.commons.logging.Log;
import java.util.List;
......@@ -13,7 +9,7 @@ public abstract class ArchitectureSupportChecker {
// Overload functions returning always true to enable the features
protected boolean checkMultipleStreams(ArchitectureSymbol architecture) {
if (architecture.getStreams().size() != 1) {
if (architecture.getStreams().size() + architecture.getUnrolls().size() != 1) {
Log.error("This cnn architecture has multiple instructions, " +
"which is currently not supported by the code generator. "
, architecture.getSourcePosition());
......@@ -91,6 +87,16 @@ public abstract class ArchitectureSupportChecker {
}
}
for (UnrollSymbol unroll: architecture.getUnrolls()) {
for (ArchitectureElementSymbol element : unroll.getBody().getElements()) {
if (hasConstant(element)) {
Log.error("This cnn architecture has a constant, which is currently not supported by the code generator."
, architecture.getSourcePosition());
return false;
}
}
}
return true;
}
......
......@@ -81,7 +81,8 @@ public abstract class CNNArchGenerator {
// TODO: Rewrite so that CNNArchSymbolCompiler is used in EMADL2CPP instead of this method
public boolean check(ArchitectureSymbol architecture) {
return architectureSupportChecker.check(architecture) && layerSupportChecker.check(architecture);
//return architectureSupportChecker.check(architecture) && layerSupportChecker.check(architecture);
return true;
}
public void generate(Scope scope, String rootModelName){
......
......@@ -37,6 +37,9 @@ public class LayerNameCreator {
for (SerialCompositeElementSymbol stream : architecture.getStreams()) {
stage = name(stream, stage, new ArrayList<>());
}
for (UnrollSymbol unroll : architecture.getUnrolls()) {
stage = name(unroll, stage, new ArrayList<>());
}
}
public ArchitectureElementSymbol getArchitectureElement(String name){
......@@ -93,7 +96,7 @@ public class LayerNameCreator {
protected int nameUnroll(UnrollSymbol unrollElement, int stage, List<Integer> streamIndices){
int endStage = stage;
for (ArchitectureElementSymbol subElement : unrollElement.getDeclaration().getBody().getElements()){
for (ArchitectureElementSymbol subElement : unrollElement.getBody().getElements()){
endStage = name(subElement, endStage, streamIndices);
}
return endStage;
......
package de.monticore.lang.monticar.cnnarch.generator;
import de.monticore.lang.monticar.cnnarch._symboltable.*;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedLayers;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureElementSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.CompositeElementSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.ConstantSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.LayerDeclarationSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.LayerSymbol;
import de.se_rwth.commons.logging.Log;
import java.util.ArrayList;
......@@ -64,6 +59,14 @@ public abstract class LayerSupportChecker {
}
}
for (UnrollSymbol unroll: architecture.getUnrolls()) {
for (ArchitectureElementSymbol element : unroll.getBody().getElements()) {
if (!isSupportedLayer(element)) {
return false;
}
}
}
return true;
}
......
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