Commit 29d922ab authored by Carlos Alfredo Yeverino Rodriguez's avatar Carlos Alfredo Yeverino Rodriguez
Browse files

Adaptation for generator interface

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