Commit de808892 authored by Malte Heithoff's avatar Malte Heithoff
Browse files

Merge branch 'interface-dev' into 'master'

Interface dev

See merge request !31
parents 9c0faec5 dd4fda2f
Pipeline #336026 passed with stage
in 1 minute and 37 seconds
# (c) https://github.com/MontiCore/monticore
stages:
- windows
# -windows
- linux
masterJobLinux:
......@@ -14,12 +14,12 @@ masterJobLinux:
only:
- master
masterJobWindows:
stage: windows
script:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
tags:
- Windows10
#masterJobWindows:
# stage: windows
# script:
# - mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
# tags:
# - Windows
BranchJobLinux:
stage: linux
......
......@@ -9,17 +9,14 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnnarch-mxnet-generator</artifactId>
<version>0.2.17-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
<properties>
<!-- .. SE-Libraries .................................................. -->
<CNNArch.version>0.3.4-SNAPSHOT</CNNArch.version>
<CNNTrain.version>0.3.9-SNAPSHOT</CNNTrain.version>
<CNNArch2X.version>0.0.5-SNAPSHOT</CNNArch2X.version>
<embedded-montiarc-math-opt-generator>0.1.4</embedded-montiarc-math-opt-generator>
<CNNArch2X.version>0.4.0-SNAPSHOT</CNNArch2X.version>
<!-- .. Libraries .................................................. -->
<guava.version>18.0</guava.version>
......@@ -61,46 +58,12 @@
<!-- MontiCore Dependencies -->
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnn-arch</artifactId>
<version>${CNNArch.version}</version>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnn-arch</artifactId>
<version>${CNNArch.version}</version>
<classifier>${grammars.classifier}</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnn-train</artifactId>
<version>${CNNTrain.version}</version>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnn-train</artifactId>
<version>${CNNTrain.version}</version>
<classifier>${grammars.classifier}</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnnarch-generator</artifactId>
<version>${CNNArch2X.version}</version>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-opt-generator</artifactId>
<version>${embedded-montiarc-math-opt-generator}</version>
</dependency>
<!-- .. Test Libraries ............................................... -->
<dependency>
......
......@@ -11,53 +11,64 @@ import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.cmake.CMakeConfig;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.Scope;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CNNArch2MxNet extends CNNArchGenerator {
CMakeConfig cMakeConfig;
public CNNArch2MxNet() {
architectureSupportChecker = new CNNArch2MxNetArchitectureSupportChecker();
layerSupportChecker = new CNNArch2MxNetLayerSupportChecker();
}
//check cocos with CNNArchCocos.checkAll(architecture) before calling this method.
public Map<String, String> generateStrings(ArchitectureSymbol architecture){
Map<String, String> fileContentMap = new HashMap<>();
public List<FileContent> generateStrings(TaggingResolver var1, ArchitectureSymbol architecture){
List<FileContent> fileContents = new ArrayList<>();
FileContent temp;
CNNArch2MxNetTemplateController archTc = new CNNArch2MxNetTemplateController(architecture);
Map.Entry<String, String> temp;
temp = archTc.process("CNNPredictor", Target.CPP);
fileContentMap.put(temp.getKey(), temp.getValue());
fileContents.add(temp);
temp = archTc.process("CNNCreator", Target.PYTHON);
fileContentMap.put(temp.getKey(), temp.getValue());
fileContents.add(temp);
temp = archTc.process("execute", Target.CPP);
fileContentMap.put(temp.getKey().replace(".h", ""), temp.getValue());
temp.setFileName(temp.getFileName().replace(".h", ""));
fileContents.add(temp);
temp = archTc.process("CNNBufferFile", Target.CPP);
fileContentMap.put("CNNBufferFile.h", temp.getValue());
temp.setFileName("CNNBufferFile.h");
fileContents.add(temp);
return fileContentMap;
return fileContents;
}
public Map<String, String> generateCMakeContent(String rootModelName) {
public List<FileContent> generateCMakeContent(String rootModelName) {
List<FileContent> fileContents = new ArrayList<>();
// model name should start with a lower case letter. If it is a component, replace dot . by _
rootModelName = rootModelName.replace('.', '_').replace('[', '_').replace(']', '_');
rootModelName = rootModelName.substring(0, 1).toLowerCase() + rootModelName.substring(1);
CMakeConfig cMakeConfig = new CMakeConfig(rootModelName);
cMakeConfig = new CMakeConfig(rootModelName);
cMakeConfig.addModuleDependency(new CMakeFindModule("Armadillo", true));
cMakeConfig.addCMakeCommand("set(LIBS ${LIBS} mxnet)");
cMakeConfig.addCmakeLibraryLinkage("mxnet");
fileContents.addAll(cMakeConfig.generateCMakeFiles());
return fileContents;
}
Map<String,String> fileContentMap = new HashMap<>();
for (FileContent fileContent : cMakeConfig.generateCMakeFiles()){
fileContentMap.put(fileContent.getFileName(), fileContent.getFileContent());
}
return fileContentMap;
public CMakeConfig getCmakeConfig() {
return this.cMakeConfig;
}
}
......@@ -23,12 +23,12 @@ public class CNNTrain2MxNet extends CNNTrainGenerator {
@Override
public void generate(Path modelsDirPath, String rootModelName) {
ConfigurationSymbol configuration = getConfigurationSymbol(modelsDirPath, rootModelName);
Map<String, String> fileContents = generateStrings(configuration);
List<FileContent> fileContents = generateStrings(configuration);
GeneratorCPP genCPP = new GeneratorCPP();
genCPP.setGenerationTargetPath(getGenerationTargetPath());
try {
for (String fileName : fileContents.keySet()){
genCPP.generateFile(new FileContent(fileContents.get(fileName), fileName));
for (FileContent fileContent : fileContents){
genCPP.generateFile(fileContent);
}
} catch (IOException e) {
Log.error("CNNTrainer file could not be generated" + e.getMessage());
......@@ -36,7 +36,7 @@ public class CNNTrain2MxNet extends CNNTrainGenerator {
}
@Override
public Map<String, String> generateStrings(ConfigurationSymbol configuration) {
public List<FileContent> generateStrings(ConfigurationSymbol configuration) {
TemplateConfiguration templateConfiguration = new MxNetTemplateConfiguration();
ConfigurationData configData = new ConfigurationData(configuration, getInstanceName());
List<ConfigurationData> configDataList = new ArrayList<>();
......@@ -44,6 +44,9 @@ public class CNNTrain2MxNet extends CNNTrainGenerator {
Map<String, Object> ftlContext = Collections.singletonMap("configurations", configDataList);
String templateContent = templateConfiguration.processTemplate(ftlContext, "CNNTrainer.ftl");
return Collections.singletonMap("CNNTrainer_" + getInstanceName() + ".py", templateContent);
List<FileContent> fileContents = new ArrayList<>();
FileContent temp = new FileContent(templateContent, "CNNTrainer_" + getInstanceName() + ".py");
fileContents.add(temp);
return fileContents;
}
}
......@@ -11,9 +11,12 @@ find_package(Armadillo REQUIRED)
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Armadillo_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Armadillo_LIBRARIES})
# additional commands
# additional library linkage
set(LIBS ${LIBS} mxnet)
# additional commands
# create static library
include_directories(${INCLUDE_DIRS})
add_library(alexnet alexnet.cpp)
......@@ -24,4 +27,4 @@ set_target_properties(alexnet PROPERTIES LINKER_LANGUAGE CXX)
# export cmake project
export(TARGETS alexnet FILE alexnet.cmake)
# additional commands end
# additional commands end
\ No newline at end of file
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