Update to new EMA Version

parent b9d79ffc
Pipeline #96301 passed with stages
...@@ -8,18 +8,18 @@ ...@@ -8,18 +8,18 @@
<groupId>de.monticore.lang.monticar</groupId> <groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-emadl-generator</artifactId> <artifactId>embedded-montiarc-emadl-generator</artifactId>
<version>0.2.5-SNAPSHOT</version> <version>0.2.6-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= --> <!-- == PROJECT DEPENDENCIES ============================================= -->
<properties> <properties>
<!-- .. SE-Libraries .................................................. --> <!-- .. SE-Libraries .................................................. -->
<emadl.version>0.2.3</emadl.version> <emadl.version>0.2.4</emadl.version>
<CNNTrain.version>0.2.5</CNNTrain.version> <CNNTrain.version>0.2.5</CNNTrain.version>
<cnnarch-mxnet-generator.version>0.2.5</cnnarch-mxnet-generator.version> <cnnarch-mxnet-generator.version>0.2.7</cnnarch-mxnet-generator.version>
<cnnarch-caffe2-generator.version>0.2.7-SNAPSHOT</cnnarch-caffe2-generator.version> <cnnarch-caffe2-generator.version>0.2.7-SNAPSHOT</cnnarch-caffe2-generator.version>
<embedded-montiarc-math-opt-generator>0.1.0</embedded-montiarc-math-opt-generator> <embedded-montiarc-math-opt-generator>0.1.2-SNAPSHOT</embedded-montiarc-math-opt-generator>
<!-- .. Libraries .................................................. --> <!-- .. Libraries .................................................. -->
<guava.version>18.0</guava.version> <guava.version>18.0</guava.version>
......
...@@ -23,7 +23,7 @@ package de.monticore.lang.monticar.emadl.generator; ...@@ -23,7 +23,7 @@ package de.monticore.lang.monticar.emadl.generator;
import de.monticore.ModelingLanguageFamily; import de.monticore.ModelingLanguageFamily;
import de.monticore.io.paths.ModelPath; import de.monticore.io.paths.ModelPath;
import de.monticore.lang.embeddedmontiarc.LogConfig; import de.monticore.lang.embeddedmontiarc.LogConfig;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ConstantPortSymbol; import de.monticore.lang.embeddedmontiarc.helper.ConstantPortHelper;
import de.monticore.lang.monticar.emadl._symboltable.EMADLLanguage; import de.monticore.lang.monticar.emadl._symboltable.EMADLLanguage;
import de.monticore.lang.monticar.enumlang._symboltable.EnumLangLanguage; import de.monticore.lang.monticar.enumlang._symboltable.EnumLangLanguage;
import de.monticore.lang.monticar.generator.cpp.converter.MathConverter; import de.monticore.lang.monticar.generator.cpp.converter.MathConverter;
...@@ -62,7 +62,7 @@ public class EMADLAbstractSymtab { ...@@ -62,7 +62,7 @@ public class EMADLAbstractSymtab {
} }
public static Scope createSymTab(String... modelPath) { public static Scope createSymTab(String... modelPath) {
ConstantPortSymbol.resetLastID(); ConstantPortHelper.resetLastID();
MathConverter.resetIDs(); MathConverter.resetIDs();
ThreadingOptimizer.resetID(); ThreadingOptimizer.resetID();
ModelingLanguageFamily fam = new ModelingLanguageFamily(); ModelingLanguageFamily fam = new ModelingLanguageFamily();
......
...@@ -24,8 +24,8 @@ import com.google.common.base.Charsets; ...@@ -24,8 +24,8 @@ import com.google.common.base.Charsets;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.io.Resources; import com.google.common.io.Resources;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ComponentSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAComponentSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.math._symboltable.MathStatementsSymbol; import de.monticore.lang.math._symboltable.MathStatementsSymbol;
import de.monticore.lang.monticar.cnnarch.CNNArchGenerator; import de.monticore.lang.monticar.cnnarch.CNNArchGenerator;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
...@@ -102,7 +102,7 @@ public class EMADLGenerator { ...@@ -102,7 +102,7 @@ public class EMADLGenerator {
public void generate(String modelPath, String qualifiedName) throws IOException, TemplateException { public void generate(String modelPath, String qualifiedName) throws IOException, TemplateException {
setModelsPath( modelPath ); setModelsPath( modelPath );
TaggingResolver symtab = EMADLAbstractSymtab.createSymTabAndTaggingResolver(getModelsPath()); TaggingResolver symtab = EMADLAbstractSymtab.createSymTabAndTaggingResolver(getModelsPath());
ComponentSymbol component = symtab.<ComponentSymbol>resolve(qualifiedName, ComponentSymbol.KIND).orElse(null); EMAComponentSymbol component = symtab.<EMAComponentSymbol>resolve(qualifiedName, EMAComponentSymbol.KIND).orElse(null);
List<String> splitName = Splitters.DOT.splitToList(qualifiedName); List<String> splitName = Splitters.DOT.splitToList(qualifiedName);
String componentName = splitName.get(splitName.size() - 1); String componentName = splitName.get(splitName.size() - 1);
...@@ -113,22 +113,22 @@ public class EMADLGenerator { ...@@ -113,22 +113,22 @@ public class EMADLGenerator {
System.exit(1); System.exit(1);
} }
ExpandedComponentInstanceSymbol instance = component.getEnclosingScope().<ExpandedComponentInstanceSymbol>resolve(instanceName, ExpandedComponentInstanceSymbol.KIND).get(); EMAComponentInstanceSymbol instance = component.getEnclosingScope().<EMAComponentInstanceSymbol>resolve(instanceName, EMAComponentInstanceSymbol.KIND).get();
generateFiles(symtab, instance, symtab); generateFiles(symtab, instance, symtab);
} }
public void generateFiles(TaggingResolver taggingResolver, ExpandedComponentInstanceSymbol componentSymbol, Scope symtab) throws IOException { public void generateFiles(TaggingResolver taggingResolver, EMAComponentInstanceSymbol EMAComponentSymbol, Scope symtab) throws IOException {
List<FileContent> fileContents = generateStrings(taggingResolver, componentSymbol, symtab); List<FileContent> fileContents = generateStrings(taggingResolver, EMAComponentSymbol, symtab);
for (FileContent fileContent : fileContents) { for (FileContent fileContent : fileContents) {
emamGen.generateFile(fileContent); emamGen.generateFile(fileContent);
} }
} }
public List<FileContent> generateStrings(TaggingResolver taggingResolver, ExpandedComponentInstanceSymbol componentInstanceSymbol, Scope symtab){ public List<FileContent> generateStrings(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentInstanceSymbol, Scope symtab){
List<FileContent> fileContents = new ArrayList<>(); List<FileContent> fileContents = new ArrayList<>();
Set<ExpandedComponentInstanceSymbol> allInstances = new HashSet<>(); Set<EMAComponentInstanceSymbol> allInstances = new HashSet<>();
generateComponent(fileContents, allInstances, taggingResolver, componentInstanceSymbol, symtab); generateComponent(fileContents, allInstances, taggingResolver, componentInstanceSymbol, symtab);
...@@ -159,20 +159,20 @@ public class EMADLGenerator { ...@@ -159,20 +159,20 @@ public class EMADLGenerator {
} }
protected void generateComponent(List<FileContent> fileContents, protected void generateComponent(List<FileContent> fileContents,
Set<ExpandedComponentInstanceSymbol> allInstances, Set<EMAComponentInstanceSymbol> allInstances,
TaggingResolver taggingResolver, TaggingResolver taggingResolver,
ExpandedComponentInstanceSymbol componentInstanceSymbol, EMAComponentInstanceSymbol componentInstanceSymbol,
Scope symtab){ Scope symtab){
allInstances.add(componentInstanceSymbol); allInstances.add(componentInstanceSymbol);
ComponentSymbol componentSymbol = componentInstanceSymbol.getComponentType().getReferencedSymbol(); EMAComponentSymbol EMAComponentSymbol = componentInstanceSymbol.getComponentType().getReferencedSymbol();
/* remove the following two lines if the component symbol full name bug with generic variables is fixed */ /* remove the following two lines if the component symbol full name bug with generic variables is fixed */
componentSymbol.setFullName(null); EMAComponentSymbol.setFullName(null);
componentSymbol.getFullName(); EMAComponentSymbol.getFullName();
/* */ /* */
Optional<ArchitectureSymbol> architecture = componentInstanceSymbol.getSpannedScope().resolve("", ArchitectureSymbol.KIND); Optional<ArchitectureSymbol> architecture = componentInstanceSymbol.getSpannedScope().resolve("", ArchitectureSymbol.KIND);
Optional<MathStatementsSymbol> mathStatements = componentSymbol.getSpannedScope().resolve("MathStatements", MathStatementsSymbol.KIND); Optional<MathStatementsSymbol> mathStatements = EMAComponentSymbol.getSpannedScope().resolve("MathStatements", MathStatementsSymbol.KIND);
EMADLCocos.checkAll(componentInstanceSymbol); EMADLCocos.checkAll(componentInstanceSymbol);
...@@ -195,7 +195,7 @@ public class EMADLGenerator { ...@@ -195,7 +195,7 @@ public class EMADLGenerator {
} }
} }
public void generateCNN(List<FileContent> fileContents, TaggingResolver taggingResolver, ExpandedComponentInstanceSymbol instance, ArchitectureSymbol architecture){ public void generateCNN(List<FileContent> fileContents, TaggingResolver taggingResolver, EMAComponentInstanceSymbol instance, ArchitectureSymbol architecture){
Map<String,String> contentMap = cnnArchGenerator.generateStrings(architecture); Map<String,String> contentMap = cnnArchGenerator.generateStrings(architecture);
String fullName = instance.getFullName().replaceAll("\\.", "_"); String fullName = instance.getFullName().replaceAll("\\.", "_");
...@@ -238,16 +238,16 @@ public class EMADLGenerator { ...@@ -238,16 +238,16 @@ public class EMADLGenerator {
return component; return component;
} }
public void generateMathComponent(List<FileContent> fileContents, TaggingResolver taggingResolver, ExpandedComponentInstanceSymbol componentSymbol, MathStatementsSymbol mathStatementsSymbol){ public void generateMathComponent(List<FileContent> fileContents, TaggingResolver taggingResolver, EMAComponentInstanceSymbol EMAComponentSymbol, MathStatementsSymbol mathStatementsSymbol){
fileContents.add(new FileContent( fileContents.add(new FileContent(
emamGen.generateString(taggingResolver, componentSymbol, mathStatementsSymbol), emamGen.generateString(taggingResolver, EMAComponentSymbol, mathStatementsSymbol),
componentSymbol)); EMAComponentSymbol));
} }
public void generateSubComponents(List<FileContent> fileContents, Set<ExpandedComponentInstanceSymbol> allInstances, TaggingResolver taggingResolver, ExpandedComponentInstanceSymbol componentInstanceSymbol, Scope symtab){ public void generateSubComponents(List<FileContent> fileContents, Set<EMAComponentInstanceSymbol> allInstances, TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentInstanceSymbol, Scope symtab){
fileContents.add(new FileContent(emamGen.generateString(taggingResolver, componentInstanceSymbol, (MathStatementsSymbol) null), componentInstanceSymbol)); fileContents.add(new FileContent(emamGen.generateString(taggingResolver, componentInstanceSymbol, (MathStatementsSymbol) null), componentInstanceSymbol));
String lastNameWithoutArrayPart = ""; String lastNameWithoutArrayPart = "";
for (ExpandedComponentInstanceSymbol instanceSymbol : componentInstanceSymbol.getSubComponents()) { for (EMAComponentInstanceSymbol instanceSymbol : componentInstanceSymbol.getSubComponents()) {
int arrayBracketIndex = instanceSymbol.getName().indexOf("["); int arrayBracketIndex = instanceSymbol.getName().indexOf("[");
boolean generateComponentInstance = true; boolean generateComponentInstance = true;
if (arrayBracketIndex != -1) { if (arrayBracketIndex != -1) {
...@@ -262,10 +262,10 @@ public class EMADLGenerator { ...@@ -262,10 +262,10 @@ public class EMADLGenerator {
} }
} }
public List<FileContent> generateCNNTrainer(Set<ExpandedComponentInstanceSymbol> allInstances, String mainComponentName) { public List<FileContent> generateCNNTrainer(Set<EMAComponentInstanceSymbol> allInstances, String mainComponentName) {
List<FileContent> fileContents = new ArrayList<>(); List<FileContent> fileContents = new ArrayList<>();
for (ExpandedComponentInstanceSymbol componentInstance : allInstances) { for (EMAComponentInstanceSymbol componentInstance : allInstances) {
ComponentSymbol component = componentInstance.getComponentType().getReferencedSymbol(); EMAComponentSymbol component = componentInstance.getComponentType().getReferencedSymbol();
Optional<ArchitectureSymbol> architecture = component.getSpannedScope().resolve("", ArchitectureSymbol.KIND); Optional<ArchitectureSymbol> architecture = component.getSpannedScope().resolve("", ArchitectureSymbol.KIND);
if (architecture.isPresent()) { if (architecture.isPresent()) {
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
*/ */
package de.monticore.lang.monticar.emadl; package de.monticore.lang.monticar.emadl;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ComponentSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAComponentSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.emadl._parser.EMADLParser; import de.monticore.lang.monticar.emadl._parser.EMADLParser;
import de.monticore.symboltable.Scope; import de.monticore.symboltable.Scope;
import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.Log;
...@@ -49,8 +49,8 @@ public class SymtabTest extends AbstractSymtabTest { ...@@ -49,8 +49,8 @@ public class SymtabTest extends AbstractSymtabTest {
@Test @Test
public void testAlexnet(){ public void testAlexnet(){
Scope symTab = createSymTab("src/test/resources/models"); Scope symTab = createSymTab("src/test/resources/models");
ComponentSymbol a = symTab.<ComponentSymbol>resolve("ResNet34", ComponentSymbol.KIND).orElse(null); EMAComponentSymbol a = symTab.<EMAComponentSymbol>resolve("ResNet34", EMAComponentSymbol.KIND).orElse(null);
ExpandedComponentInstanceSymbol c = symTab.<ExpandedComponentInstanceSymbol>resolve("resNet34", ExpandedComponentInstanceSymbol.KIND).orElse(null); EMAComponentInstanceSymbol c = symTab.<EMAComponentInstanceSymbol>resolve("resNet34", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(a); assertNotNull(a);
} }
......
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