Adaptation for generator interface

parent aaa745b1
Pipeline #55967 failed with stages
in 16 seconds
......@@ -127,7 +127,7 @@
<configuration>
<archive>
<manifest>
<mainClass>de.monticore.lang.monticar.cnnarch.generator.CNNArchGeneratorCli</mainClass>
<mainClass>de.monticore.lang.monticar.cnnarch.generator.CNNArch2MxNetCli</mainClass>
</manifest>
</archive>
<descriptorRefs>
......
......@@ -21,10 +21,12 @@
package de.monticore.lang.monticar.cnnarch.generator;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.monticar.cnnarch.CNNArchGenerator;
import de.monticore.lang.monticar.cnnarch._cocos.CNNArchCocos;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchCompilationUnitSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchLanguage;
import de.monticore.lang.monticar.cnntrain._symboltable.ConfigurationSymbol;
import de.monticore.symboltable.GlobalScope;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.logging.Log;
......@@ -34,14 +36,15 @@ import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public class CNNArchGenerator {
public class CNNArch2MxNet implements CNNArchGenerator {
private String generationTargetPath;
public CNNArchGenerator() {
public CNNArch2MxNet() {
setGenerationTargetPath("./target/generated-sources-cnnarch/");
}
......@@ -79,6 +82,11 @@ public class CNNArchGenerator {
}
}
@Override
public Map<String, String> generateTrainer(List<ConfigurationSymbol> configurations, List<String> instanceNames) {
return null;
}
//check cocos with CNNArchCocos.checkAll(architecture) before calling this method.
public Map<String, String> generateStrings(ArchitectureSymbol architecture){
Map<String, String> fileContentMap = new HashMap<>();
......
......@@ -25,7 +25,7 @@ import org.apache.commons.cli.*;
import java.nio.file.Path;
import java.nio.file.Paths;
public class CNNArchGeneratorCli {
public class CNNArch2MxNetCli {
public static final Option OPTION_MODELS_PATH = Option.builder("m")
.longOpt("models-dir")
......@@ -48,7 +48,7 @@ public class CNNArchGeneratorCli {
.required(false)
.build();
private CNNArchGeneratorCli() {
private CNNArch2MxNetCli() {
}
public static void main(String[] args) {
......@@ -84,7 +84,7 @@ public class CNNArchGeneratorCli {
Path modelsDirPath = Paths.get(cliArgs.getOptionValue(OPTION_MODELS_PATH.getOpt()));
String rootModelName = cliArgs.getOptionValue(OPTION_ROOT_MODEL.getOpt());
String outputPath = cliArgs.getOptionValue(OPTION_OUTPUT_PATH.getOpt());
CNNArchGenerator generator = new CNNArchGenerator();
CNNArch2MxNet generator = new CNNArch2MxNet();
if (outputPath != null){
generator.setGenerationTargetPath(outputPath);
}
......
......@@ -20,7 +20,7 @@
*/
package de.monticore.lang.monticar.cnnarch;
import de.monticore.lang.monticar.cnnarch.generator.CNNArchGeneratorCli;
import de.monticore.lang.monticar.cnnarch.generator.CNNArch2MxNetCli;
import de.se_rwth.commons.logging.Log;
import freemarker.template.TemplateException;
import org.junit.Before;
......@@ -45,7 +45,7 @@ public class GenerationTest extends AbstractSymtabTest{
public void testCifar10Classifier() throws IOException, TemplateException {
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/valid_tests", "-r", "CifarClassifierNetwork", "-o", "./target/generated-sources-cnnarch/"};
CNNArchGeneratorCli.main(args);
CNNArch2MxNetCli.main(args);
assertTrue(Log.getFindings().isEmpty());
checkFilesAreEqual(
......@@ -62,7 +62,7 @@ public class GenerationTest extends AbstractSymtabTest{
public void testAlexnetGeneration() throws IOException, TemplateException {
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/architectures", "-r", "Alexnet", "-o", "./target/generated-sources-cnnarch/"};
CNNArchGeneratorCli.main(args);
CNNArch2MxNetCli.main(args);
assertTrue(Log.getFindings().isEmpty());
checkFilesAreEqual(
......@@ -78,7 +78,7 @@ public class GenerationTest extends AbstractSymtabTest{
public void testGeneratorVGG16() throws IOException, TemplateException {
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/architectures", "-r", "VGG16", "-o", "./target/generated-sources-cnnarch/"};
CNNArchGeneratorCli.main(args);
CNNArch2MxNetCli.main(args);
assertTrue(Log.getFindings().isEmpty());
checkFilesAreEqual(
......@@ -95,7 +95,7 @@ public class GenerationTest extends AbstractSymtabTest{
public void testThreeInputCNNGeneration() throws IOException, TemplateException {
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/architectures", "-r", "ThreeInputCNN_M14"};
CNNArchGeneratorCli.main(args);
CNNArch2MxNetCli.main(args);
assertTrue(Log.getFindings().size() == 1);
}
......@@ -103,7 +103,7 @@ public class GenerationTest extends AbstractSymtabTest{
public void testResNeXtGeneration() throws IOException, TemplateException {
Log.getFindings().clear();;
String[] args = {"-m", "src/test/resources/architectures", "-r", "ResNeXt50"};
CNNArchGeneratorCli.main(args);
CNNArch2MxNetCli.main(args);
assertTrue(Log.getFindings().isEmpty());
}
......@@ -111,7 +111,7 @@ public class GenerationTest extends AbstractSymtabTest{
public void testMultipleOutputs() throws IOException, TemplateException {
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/valid_tests", "-r", "MultipleOutputs"};
CNNArchGeneratorCli.main(args);
CNNArch2MxNetCli.main(args);
assertTrue(Log.getFindings().size() == 3);
}
}
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