Commit e4c6eff0 authored by Christopher Jan-Steffen Brix's avatar Christopher Jan-Steffen Brix
Browse files

Merge branch 'oneclick_nn_training' of...

Merge branch 'oneclick_nn_training' of git.rwth-aachen.de:monticore/EmbeddedMontiArc/generators/EMADL2CPP into oneclick_nn_training
parents df8e63c8 5f1ad44a
Pipeline #99119 passed with stages
in 5 minutes and 30 seconds
{
"configurations": [
{
"type": "java",
"name": "CodeLens (Launch) - EMADLGeneratorCli",
"request": "launch",
"mainClass": "de.monticore.lang.monticar.emadl.generator.EMADLGeneratorCli",
"projectName": "embedded-montiarc-emadl-generator"
}
]
}
\ No newline at end of file
......@@ -103,7 +103,7 @@ public class EMADLGenerator {
return emamGen;
}
public void generate(String modelPath, String qualifiedName) throws IOException, TemplateException {
public void generate(String modelPath, String qualifiedName, String forced) throws IOException, TemplateException {
setModelsPath( modelPath );
TaggingResolver symtab = EMADLAbstractSymtab.createSymTabAndTaggingResolver(getModelsPath());
ComponentSymbol component = symtab.<ComponentSymbol>resolve(qualifiedName, ComponentSymbol.KIND).orElse(null);
......@@ -118,13 +118,15 @@ public class EMADLGenerator {
}
ExpandedComponentInstanceSymbol instance = component.getEnclosingScope().<ExpandedComponentInstanceSymbol>resolve(instanceName, ExpandedComponentInstanceSymbol.KIND).get();
generateFiles(symtab, instance, symtab);
generateFiles(symtab, instance, symtab, forced);
}
public void generateFiles(TaggingResolver taggingResolver, ExpandedComponentInstanceSymbol componentSymbol, Scope symtab) throws IOException {
public void generateFiles(TaggingResolver taggingResolver, ExpandedComponentInstanceSymbol componentSymbol, Scope symtab, String forced) throws IOException {
Set<ExpandedComponentInstanceSymbol> allInstances = new HashSet<>();
List<FileContent> fileContents = generateStrings(taggingResolver, componentSymbol, symtab, allInstances);
List<FileContent> fileContents = generateStrings(taggingResolver, componentSymbol, symtab, allInstances, forced);
for (FileContent fileContent : fileContents) {
emamGen.generateFile(fileContent);
......@@ -235,8 +237,7 @@ public class EMADLGenerator {
}
}
public List<FileContent> generateStrings(TaggingResolver taggingResolver, ExpandedComponentInstanceSymbol componentInstanceSymbol, Scope symtab,
Set<ExpandedComponentInstanceSymbol> allInstances) {
public List<FileContent> generateStrings(TaggingResolver taggingResolver, ExpandedComponentInstanceSymbol componentInstanceSymbol, Scope symtab, Set<ExpandedComponentInstanceSymbol> allInstances, String forced){
List<FileContent> fileContents = new ArrayList<>();
generateComponent(fileContents, allInstances, taggingResolver, componentInstanceSymbol, symtab);
......
......@@ -20,7 +20,6 @@
*/
package de.monticore.lang.monticar.emadl.generator;
import de.se_rwth.commons.logging.Log;
import freemarker.template.TemplateException;
import org.apache.commons.cli.*;
......@@ -56,6 +55,16 @@ public class EMADLGeneratorCli {
.hasArg(true)
.required(false)
.build();
/**/
public static final Option OPTION_RESTRAINED_TRAINING = Option.builder("f")
.longOpt("forced")
.desc("no training or a forced training. Options: y (a forced training), n (no training)")
.hasArg(true)
.required(false)
.build();
private EMADLGeneratorCli() {
}
......@@ -75,6 +84,7 @@ public class EMADLGeneratorCli {
options.addOption(OPTION_ROOT_MODEL);
options.addOption(OPTION_OUTPUT_PATH);
options.addOption(OPTION_BACKEND);
options.addOption(OPTION_RESTRAINED_TRAINING);
return options;
}
......@@ -94,7 +104,9 @@ public class EMADLGeneratorCli {
String rootModelName = cliArgs.getOptionValue(OPTION_ROOT_MODEL.getOpt());
String outputPath = cliArgs.getOptionValue(OPTION_OUTPUT_PATH.getOpt());
String backendString = cliArgs.getOptionValue(OPTION_BACKEND.getOpt());
String forced = cliArgs.getOptionValue(OPTION_RESTRAINED_TRAINING.getOpt());
final String DEFAULT_BACKEND = "MXNET";
final String DEFAULT_FORCED = "UNSET";
if (backendString == null) {
Log.warn("backend not specified. backend set to default value " + DEFAULT_BACKEND);
......@@ -106,13 +118,27 @@ public class EMADLGeneratorCli {
Log.warn("specified backend " + backendString + " not supported. backend set to default value " + DEFAULT_BACKEND);
backend = Backend.getBackendFromString(DEFAULT_BACKEND);
}
if (forced == null) {
Log.warn("forced not specified. forced set to default value" + DEFAULT_FORCED);
forced = DEFAULT_FORCED;
}else if (forced == "y") {
Log.warn("training with enforcement");
/**/
}else if (forced == "n") {
Log.warn("no training with enforcement");
}else{
Log.error("no such parameter" + forced);
System.exit(1);
}
EMADLGenerator generator = new EMADLGenerator(backend.get());
if (outputPath != null){
generator.setGenerationTargetPath(outputPath);
}
try{
generator.generate(cliArgs.getOptionValue(OPTION_MODELS_PATH.getOpt()), rootModelName);
generator.generate(cliArgs.getOptionValue(OPTION_MODELS_PATH.getOpt()), rootModelName, forced);
}
catch (IOException e){
Log.error("io error during generation", e);
......@@ -122,5 +148,6 @@ public class EMADLGeneratorCli {
Log.error("template error during generation", e);
System.exit(1);
}
}
}
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