Commit 5ea62176 authored by Evgeny Kusmenko's avatar Evgeny Kusmenko

Merge branch 'master' into 'develop'

Master

See merge request !13
parents b2dda75a 340e16fd
Pipeline #348594 passed with stage
in 2 minutes and 33 seconds
......@@ -4,6 +4,28 @@ stages:
#- windows
- linux
githubjob:
image: maven:3-jdk-8
stage: linux
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$GITHUB_SSH_PRIV_KEY")
- echo "$GITHUB_SSH_PRIV_KEY" | tr -d '\r' | ssh-add -
- git config --global user.email "kusmenko@se-rwth.de"
- git config --global user.name "EMA CI Robot"
- mkdir -p ~/.ssh
# - cat gitlab-known-hosts >> ~/.ssh/known_hosts
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
script:
- git clone git@github.com:MontiCore/EmbeddedMontiArc.git
- cd EmbeddedMontiArc
- git subtree pull --prefix $PRJ_NAME https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/${PRJ_NAME}.git master --squash
- git push --force
only:
- master
masterJobLinux:
stage: linux
image: maven:3-jdk-8
......@@ -13,6 +35,11 @@ masterJobLinux:
- mvn package sonar:sonar -s settings.xml
only:
- master
except:
changes:
- .gitlab-ci.yml
- .gitignore
- README.md
#masterJobWindows:
# stage: windows
......
......@@ -9,7 +9,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnnarch-generator</artifactId>
<version>0.0.7-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......@@ -17,13 +17,13 @@
<!-- .. SE-Libraries .................................................. -->
<CNNArch.version>0.3.7-SNAPSHOT</CNNArch.version>
<CNNTrain.version>0.3.12-SNAPSHOT</CNNTrain.version>
<embedded-montiarc-math-opt-generator>0.1.6</embedded-montiarc-math-opt-generator>
<CNNArch.version>0.4.0-SNAPSHOT</CNNArch.version>
<CNNTrain.version>0.4.0-SNAPSHOT</CNNTrain.version>
<embedded-montiarc-math-generator>0.4.0-SNAPSHOT</embedded-montiarc-math-generator>
<!-- .. Libraries .................................................. -->
<guava.version>18.0</guava.version>
<junit.version>4.12</junit.version>
<guava.version>25.1-jre</guava.version>
<junit.version>4.13.1</junit.version>
<logback.version>1.1.2</logback.version>
<jscience.version>4.3.1</jscience.version>
......@@ -91,8 +91,8 @@
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-opt-generator</artifactId>
<version>${embedded-montiarc-math-opt-generator}</version>
<artifactId>embedded-montiarc-math-generator</artifactId>
<version>${embedded-montiarc-math-generator}</version>
</dependency>
......
......@@ -4,21 +4,25 @@ package de.monticore.lang.monticar.cnnarch.generator;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchLanguage;
import de.monticore.lang.monticar.generator.cmake.CMakeConfig;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.Generator;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.cpp.GeneratorCPP;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.GlobalScope;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.logging.Log;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public abstract class CNNArchGenerator {
public abstract class CNNArchGenerator implements Generator<ArchitectureSymbol> {
private boolean generateCMake = false;
protected ArchitectureSupportChecker architectureSupportChecker;
protected LayerSupportChecker layerSupportChecker;
......@@ -35,8 +39,14 @@ public abstract class CNNArchGenerator {
System.exit(1);
}
public boolean isCMakeRequired() {
return true;
@Override
public boolean isGenerateCMake() {
return generateCMake;
}
@Override
public void setGenerateCMake(boolean generateCMake) {
this.generateCMake = generateCMake;
}
public String getGenerationTargetPath(){
......@@ -58,7 +68,8 @@ public abstract class CNNArchGenerator {
this.modelsDirPath = modelsDirPath.toString();
final ModelPath mp = new ModelPath(modelsDirPath);
GlobalScope scope = new GlobalScope(mp, new CNNArchLanguage());
generate(scope, rootModelName);
TaggingResolver tagging = new TaggingResolver(scope, Arrays.asList(rootModelName));
generate(tagging, rootModelName);
}
// TODO: Rewrite so that CNNArchSymbolCompiler is used in EMADL2CPP instead of this method
......@@ -66,9 +77,9 @@ public abstract class CNNArchGenerator {
return architectureSupportChecker.check(architecture) && layerSupportChecker.check(architecture);
}
public void generate(Scope scope, String rootModelName){
public void generate(TaggingResolver taggingResolver, String rootModelName){
CNNArchSymbolCompiler symbolCompiler = new CNNArchSymbolCompiler(architectureSupportChecker, layerSupportChecker);
ArchitectureSymbol architectureSymbol = symbolCompiler.compileArchitectureSymbol(scope, rootModelName);
ArchitectureSymbol architectureSymbol = symbolCompiler.compileArchitectureSymbol(taggingResolver, rootModelName);
try{
String dataConfPath = getModelsDirPath() + "/data_paths.txt";
......@@ -86,37 +97,41 @@ public abstract class CNNArchGenerator {
}
architectureSymbol.setWeightsPath(weightsPath);
architectureSymbol.setComponentName(rootModelName);
generateFiles(architectureSymbol);
generateFiles(taggingResolver, architectureSymbol);
} catch (IOException e){
Log.error(e.toString());
}
}
//check cocos with CNNArchCocos.checkAll(architecture) before calling this method.
public abstract Map<String, String> generateStrings(ArchitectureSymbol architecture);
public abstract List<FileContent> generateStrings(TaggingResolver taggingResolver, ArchitectureSymbol architecture);
//check cocos with CNNArchCocos.checkAll(architecture) before calling this method.
public void generateFiles(ArchitectureSymbol architecture) throws IOException{
Map<String, String> fileContentMap = generateStrings(architecture);
generateFromFilecontentsMap(fileContentMap);
public List<File> generateFiles(TaggingResolver taggingResolver, ArchitectureSymbol architecture) throws IOException{
List<FileContent> fileContents = generateStrings(taggingResolver, architecture);
return generateFromFilecontentsMap(fileContents);
}
public void generateFromFilecontentsMap(Map<String, String> fileContentMap) throws IOException {
public List<File> generateFromFilecontentsMap(List<FileContent> fileContents) throws IOException {
List<File> res = new LinkedList<>();
GeneratorCPP genCPP = new GeneratorCPP();
genCPP.setGenerationTargetPath(getGenerationTargetPath());
for (String fileName : fileContentMap.keySet()){
genCPP.generateFile(new FileContent(fileContentMap.get(fileName), fileName));
for (FileContent fileContent : fileContents) {
res.add(genCPP.generateFile(fileContent));
}
return res;
}
public void generateCMake(String rootModelName){
Map<String, String> fileContentMap = generateCMakeContent(rootModelName);
List<FileContent> fileContents = generateCMakeContent(rootModelName);
try {
generateFromFilecontentsMap(fileContentMap);
generateFromFilecontentsMap(fileContents);
} catch (IOException e) {
Log.error("CMake file could not be generated" + e.getMessage());
}
}
public abstract Map<String, String> generateCMakeContent(String rootModelName);
public abstract List<FileContent> generateCMakeContent(String rootModelName);
}
......@@ -4,6 +4,8 @@ package de.monticore.lang.monticar.cnnarch.generator;
import de.monticore.lang.monticar.cnnarch._symboltable.*;
import de.monticore.lang.monticar.cnnarch.predefined.Sigmoid;
import de.monticore.lang.monticar.cnnarch.predefined.Softmax;
import de.monticore.lang.monticar.generator.FileContent;
import org.apache.commons.io.monitor.FileEntry;
import java.io.StringWriter;
import java.io.Writer;
......@@ -198,7 +200,7 @@ public abstract class CNNArchTemplateController {
templateConfiguration.processTemplate(ftlContext, templatePath, writer);
}
public Map.Entry<String,String> process(String templateNameWithoutEnding, Target targetLanguage){
public FileContent process(String templateNameWithoutEnding, Target targetLanguage){
StringWriter newWriter = new StringWriter();
this.mainTemplateNameWithoutEnding = templateNameWithoutEnding;
this.targetLanguage = targetLanguage;
......@@ -207,7 +209,7 @@ public abstract class CNNArchTemplateController {
include("", templateNameWithoutEnding, newWriter);
String fileEnding = targetLanguage.toString();
String fileName = getFileNameWithoutEnding() + fileEnding;
Map.Entry<String,String> fileContent = new AbstractMap.SimpleEntry<>(fileName, newWriter.toString());
FileContent fileContent = new FileContent(newWriter.toString(), fileName);
this.mainTemplateNameWithoutEnding = null;
this.targetLanguage = null;
......
......@@ -113,5 +113,5 @@ public abstract class CNNTrainGenerator {
public abstract void generate(Path modelsDirPath, String rootModelNames);
//check cocos with CNNTrainCocos.checkAll(configuration) before calling this method.
public abstract Map<String, String> generateStrings(ConfigurationSymbol configuration);
public abstract List<FileContent> generateStrings(ConfigurationSymbol configuration);
}
......@@ -25,6 +25,10 @@ public abstract class TemplateConfiguration {
configuration.setClassForTemplateLoading(TemplateConfiguration.class, getBaseTemplatePackagePath());
configuration.setDefaultEncoding("UTF-8");
configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
// numbers in windows germany are formatted as '0,2' instead of '0.2'
configuration.setNumberFormat("computer");
return configuration;
}
......
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