From da5ffefdc6b4f0986f7a8152ab70211f003815d8 Mon Sep 17 00:00:00 2001 From: Carlos Alfredo Yeverino Rodriguez Date: Fri, 22 Feb 2019 10:03:44 +0100 Subject: [PATCH] Revert "Merge branch 'oneclick_nn_training' into 'master'" This reverts merge request !29 --- pom.xml | 6 +++--- settings.xml | 8 ++++---- .../caffe2generator/CNNArch2Caffe2.java | 16 ---------------- .../CNNArchTemplateController.java | 9 --------- .../resources/templates/caffe2/CNNCreator.ftl | 4 ++-- .../templates/caffe2/CNNPredictor.ftl | 16 ++++++++-------- .../resources/architectures/data_paths.txt | 5 ----- .../resources/invalid_tests/data_paths.txt | 5 ----- .../target_code/CNNCreator_Alexnet.py | 2 +- .../CNNCreator_CifarClassifierNetwork.py | 2 +- .../resources/target_code/CNNCreator_LeNet.py | 2 +- .../resources/target_code/CNNCreator_VGG16.py | 2 +- .../resources/target_code/CNNPredictor_LeNet.h | 16 ++++++++-------- .../resources/target_code/CNNPredictor_VGG16.h | 18 +++++++++--------- src/test/resources/valid_tests/data_paths.txt | 5 ----- 15 files changed, 38 insertions(+), 78 deletions(-) delete mode 100644 src/test/resources/architectures/data_paths.txt delete mode 100644 src/test/resources/invalid_tests/data_paths.txt delete mode 100644 src/test/resources/valid_tests/data_paths.txt diff --git a/pom.xml b/pom.xml index 385eee8..da5d334 100644 --- a/pom.xml +++ b/pom.xml @@ -8,15 +8,15 @@ de.monticore.lang.monticar cnnarch-caffe2-generator - 0.2.8 + 0.2.8-SNAPSHOT - 0.2.8 - 0.2.6 + 0.2.7 + 0.2.6-SNAPSHOT 0.1.2-SNAPSHOT diff --git a/settings.xml b/settings.xml index 9bef594..138a9cf 100644 --- a/settings.xml +++ b/settings.xml @@ -39,7 +39,7 @@ se-nexus cibuild ${env.cibuild} - + @@ -47,7 +47,7 @@ se-nexus external:* https://nexus.se.rwth-aachen.de/content/groups/public - + @@ -93,5 +93,5 @@ se-nexus - - + + \ No newline at end of file diff --git a/src/main/java/de/monticore/lang/monticar/cnnarch/caffe2generator/CNNArch2Caffe2.java b/src/main/java/de/monticore/lang/monticar/cnnarch/caffe2generator/CNNArch2Caffe2.java index ea0a256..336e108 100644 --- a/src/main/java/de/monticore/lang/monticar/cnnarch/caffe2generator/CNNArch2Caffe2.java +++ b/src/main/java/de/monticore/lang/monticar/cnnarch/caffe2generator/CNNArch2Caffe2.java @@ -28,7 +28,6 @@ import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureElementSymbol import de.monticore.lang.monticar.cnnarch._symboltable.CompositeElementSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchCompilationUnitSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchLanguage; -import de.monticore.lang.monticar.cnnarch.DataPathConfigParser; import de.monticore.lang.monticar.generator.FileContent; import de.monticore.lang.monticar.generator.cmake.CMakeConfig; import de.monticore.lang.monticar.generator.cmake.CMakeFindModule; @@ -47,7 +46,6 @@ import java.util.List; public class CNNArch2Caffe2 implements CNNArchGenerator{ private String generationTargetPath; - private String modelPath; private boolean isSupportedLayer(ArchitectureElementSymbol element, LayerSupportChecker layerChecker){ List constructLayerElemList; @@ -78,14 +76,6 @@ public class CNNArch2Caffe2 implements CNNArchGenerator{ return true; } - public String getModelPath(){ - return modelPath; - } - - public void setModelPath(Path modelPath){ - this.modelPath = modelPath.toString(); - } - private static void quitGeneration(){ Log.error("Code generation is aborted"); System.exit(1); @@ -114,7 +104,6 @@ public class CNNArch2Caffe2 implements CNNArchGenerator{ public void generate(Path modelsDirPath, String rootModelName){ final ModelPath mp = new ModelPath(modelsDirPath); GlobalScope scope = new GlobalScope(mp, new CNNArchLanguage()); - setModelPath(modelsDirPath); generate(scope, rootModelName); } @@ -131,11 +120,6 @@ public class CNNArch2Caffe2 implements CNNArchGenerator{ } try{ - String confPath = getModelPath() + "/data_paths.txt"; - DataPathConfigParser newParserConfig = new DataPathConfigParser(confPath); - String dataPath = newParserConfig.getDataPath(rootModelName); - compilationUnit.get().getArchitecture().setDataPath(dataPath); - compilationUnit.get().getArchitecture().setComponentName(rootModelName); generateFiles(compilationUnit.get().getArchitecture()); } catch (IOException e){ Log.error(e.toString()); diff --git a/src/main/java/de/monticore/lang/monticar/cnnarch/caffe2generator/CNNArchTemplateController.java b/src/main/java/de/monticore/lang/monticar/cnnarch/caffe2generator/CNNArchTemplateController.java index b2cc359..9d7da73 100644 --- a/src/main/java/de/monticore/lang/monticar/cnnarch/caffe2generator/CNNArchTemplateController.java +++ b/src/main/java/de/monticore/lang/monticar/cnnarch/caffe2generator/CNNArchTemplateController.java @@ -89,11 +89,6 @@ public class CNNArchTemplateController { return getArchitecture().getEnclosingScope().getSpanningSymbol().get().getFullName().replaceAll("\\.","_"); } - public String getDataPath(){ - return getArchitecture().getDataPath(); - } - - public List getLayerInputs(ArchitectureElementSymbol layer){ List inputNames = new ArrayList<>(); @@ -130,10 +125,6 @@ public class CNNArchTemplateController { return list; } - public String getComponentName(){ - return getArchitecture().getComponentName(); - } - public String getArchitectureLoss(){ return this.loss; } diff --git a/src/main/resources/templates/caffe2/CNNCreator.ftl b/src/main/resources/templates/caffe2/CNNCreator.ftl index e767e76..a732b34 100644 --- a/src/main/resources/templates/caffe2/CNNCreator.ftl +++ b/src/main/resources/templates/caffe2/CNNCreator.ftl @@ -13,8 +13,8 @@ class ${tc.fileNameWithoutEnding}: module = None _current_dir_ = os.path.join('./') - _data_dir_ = os.path.join(_current_dir_, '${tc.dataPath}') - _model_dir_ = os.path.join(_current_dir_, 'model', '${tc.componentName}') + _data_dir_ = os.path.join(_current_dir_, 'data', '${tc.fullArchitectureName}') + _model_dir_ = os.path.join(_current_dir_, 'model', '${tc.fullArchitectureName}') _init_net_ = os.path.join(_model_dir_, 'init_net.pb') _predict_net_ = os.path.join(_model_dir_, 'predict_net.pb') diff --git a/src/main/resources/templates/caffe2/CNNPredictor.ftl b/src/main/resources/templates/caffe2/CNNPredictor.ftl index 7af3b8a..8ac49ae 100644 --- a/src/main/resources/templates/caffe2/CNNPredictor.ftl +++ b/src/main/resources/templates/caffe2/CNNPredictor.ftl @@ -18,8 +18,8 @@ #include #include -CAFFE2_DEFINE_string(init_net_${tc.fileNameWithoutEnding}, "./model/${tc.componentName}/init_net.pb", "The given path to the init protobuffer."); -CAFFE2_DEFINE_string(predict_net_${tc.fileNameWithoutEnding}, "./model/${tc.componentName}/predict_net.pb", "The given path to the predict protobuffer."); +CAFFE2_DEFINE_string(init_net, "./model/${tc.fullArchitectureName}/init_net.pb", "The given path to the init protobuffer."); +CAFFE2_DEFINE_string(predict_net, "./model/${tc.fullArchitectureName}/predict_net.pb", "The given path to the predict protobuffer."); using namespace caffe2; @@ -43,21 +43,21 @@ class ${tc.fileNameWithoutEnding}{ char **a[1]; caffe2::GlobalInit(&n, a); - if (!std::ifstream(FLAGS_init_net_${tc.fileNameWithoutEnding}).good()) { - std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net_${tc.fileNameWithoutEnding} << "' does not exist." << std::endl; + if (!std::ifstream(FLAGS_init_net).good()) { + std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net << "' does not exist." << std::endl; exit(1); } - if (!std::ifstream(FLAGS_predict_net_${tc.fileNameWithoutEnding}).good()) { - std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net_${tc.fileNameWithoutEnding} << "' does not exist." << std::endl; + if (!std::ifstream(FLAGS_predict_net).good()) { + std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net << "' does not exist." << std::endl; exit(1); } std::cout << "\nLoading network..." << std::endl; // Read protobuf - CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net_${tc.fileNameWithoutEnding}, &initNet)); - CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net_${tc.fileNameWithoutEnding}, &predictNet)); + CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net, &initNet)); + CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net, &predictNet)); // Set device type #ifdef USE_GPU diff --git a/src/test/resources/architectures/data_paths.txt b/src/test/resources/architectures/data_paths.txt deleted file mode 100644 index 1744c63..0000000 --- a/src/test/resources/architectures/data_paths.txt +++ /dev/null @@ -1,5 +0,0 @@ -Alexnet data/Alexnet -CifarClassifierNetwork data/CifarClassifierNetwork -LeNet data/LeNet -VGG16 data/VGG16 -MultipleOutputs data/MultipleOutputs \ No newline at end of file diff --git a/src/test/resources/invalid_tests/data_paths.txt b/src/test/resources/invalid_tests/data_paths.txt deleted file mode 100644 index 1744c63..0000000 --- a/src/test/resources/invalid_tests/data_paths.txt +++ /dev/null @@ -1,5 +0,0 @@ -Alexnet data/Alexnet -CifarClassifierNetwork data/CifarClassifierNetwork -LeNet data/LeNet -VGG16 data/VGG16 -MultipleOutputs data/MultipleOutputs \ No newline at end of file diff --git a/src/test/resources/target_code/CNNCreator_Alexnet.py b/src/test/resources/target_code/CNNCreator_Alexnet.py index 2220d9a..b029364 100644 --- a/src/test/resources/target_code/CNNCreator_Alexnet.py +++ b/src/test/resources/target_code/CNNCreator_Alexnet.py @@ -12,7 +12,7 @@ class CNNCreator_Alexnet: module = None _current_dir_ = os.path.join('./') - _data_dir_ = os.path.join(_current_dir_, 'data/Alexnet') + _data_dir_ = os.path.join(_current_dir_, 'data', 'Alexnet') _model_dir_ = os.path.join(_current_dir_, 'model', 'Alexnet') _init_net_ = os.path.join(_model_dir_, 'init_net.pb') diff --git a/src/test/resources/target_code/CNNCreator_CifarClassifierNetwork.py b/src/test/resources/target_code/CNNCreator_CifarClassifierNetwork.py index 4a5bd24..8c53ad5 100644 --- a/src/test/resources/target_code/CNNCreator_CifarClassifierNetwork.py +++ b/src/test/resources/target_code/CNNCreator_CifarClassifierNetwork.py @@ -12,7 +12,7 @@ class CNNCreator_CifarClassifierNetwork: module = None _current_dir_ = os.path.join('./') - _data_dir_ = os.path.join(_current_dir_, 'data/CifarClassifierNetwork') + _data_dir_ = os.path.join(_current_dir_, 'data', 'CifarClassifierNetwork') _model_dir_ = os.path.join(_current_dir_, 'model', 'CifarClassifierNetwork') _init_net_ = os.path.join(_model_dir_, 'init_net.pb') diff --git a/src/test/resources/target_code/CNNCreator_LeNet.py b/src/test/resources/target_code/CNNCreator_LeNet.py index 656d351..81d6d21 100644 --- a/src/test/resources/target_code/CNNCreator_LeNet.py +++ b/src/test/resources/target_code/CNNCreator_LeNet.py @@ -13,7 +13,7 @@ class CNNCreator_LeNet: module = None _current_dir_ = os.path.join('./') - _data_dir_ = os.path.join(_current_dir_, 'data/LeNet') + _data_dir_ = os.path.join(_current_dir_, 'data', 'LeNet') _model_dir_ = os.path.join(_current_dir_, 'model', 'LeNet') _init_net_ = os.path.join(_model_dir_, 'init_net.pb') diff --git a/src/test/resources/target_code/CNNCreator_VGG16.py b/src/test/resources/target_code/CNNCreator_VGG16.py index 4193bc9..34457b3 100644 --- a/src/test/resources/target_code/CNNCreator_VGG16.py +++ b/src/test/resources/target_code/CNNCreator_VGG16.py @@ -13,7 +13,7 @@ class CNNCreator_VGG16: module = None _current_dir_ = os.path.join('./') - _data_dir_ = os.path.join(_current_dir_, 'data/VGG16') + _data_dir_ = os.path.join(_current_dir_, 'data', 'VGG16') _model_dir_ = os.path.join(_current_dir_, 'model', 'VGG16') _init_net_ = os.path.join(_model_dir_, 'init_net.pb') diff --git a/src/test/resources/target_code/CNNPredictor_LeNet.h b/src/test/resources/target_code/CNNPredictor_LeNet.h index ff4cb75..d89c225 100644 --- a/src/test/resources/target_code/CNNPredictor_LeNet.h +++ b/src/test/resources/target_code/CNNPredictor_LeNet.h @@ -18,8 +18,8 @@ #include #include -CAFFE2_DEFINE_string(init_net_CNNPredictor_LeNet, "./model/LeNet/init_net.pb", "The given path to the init protobuffer."); -CAFFE2_DEFINE_string(predict_net_CNNPredictor_LeNet, "./model/LeNet/predict_net.pb", "The given path to the predict protobuffer."); +CAFFE2_DEFINE_string(init_net, "./model/LeNet/init_net.pb", "The given path to the init protobuffer."); +CAFFE2_DEFINE_string(predict_net, "./model/LeNet/predict_net.pb", "The given path to the predict protobuffer."); using namespace caffe2; @@ -43,21 +43,21 @@ class CNNPredictor_LeNet{ char **a[1]; caffe2::GlobalInit(&n, a); - if (!std::ifstream(FLAGS_init_net_CNNPredictor_LeNet).good()) { - std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net_CNNPredictor_LeNet << "' does not exist." << std::endl; + if (!std::ifstream(FLAGS_init_net).good()) { + std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net << "' does not exist." << std::endl; exit(1); } - if (!std::ifstream(FLAGS_predict_net_CNNPredictor_LeNet).good()) { - std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net_CNNPredictor_LeNet << "' does not exist." << std::endl; + if (!std::ifstream(FLAGS_predict_net).good()) { + std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net << "' does not exist." << std::endl; exit(1); } std::cout << "\nLoading network..." << std::endl; // Read protobuf - CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net_CNNPredictor_LeNet, &initNet)); - CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net_CNNPredictor_LeNet, &predictNet)); + CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net, &initNet)); + CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net, &predictNet)); // Set device type #ifdef USE_GPU diff --git a/src/test/resources/target_code/CNNPredictor_VGG16.h b/src/test/resources/target_code/CNNPredictor_VGG16.h index de7aa7d..28ab09c 100644 --- a/src/test/resources/target_code/CNNPredictor_VGG16.h +++ b/src/test/resources/target_code/CNNPredictor_VGG16.h @@ -18,8 +18,8 @@ #include #include -CAFFE2_DEFINE_string(init_net_CNNPredictor_VGG16, "./model/VGG16/init_net.pb", "The given path to the init protobuffer."); -CAFFE2_DEFINE_string(predict_net_CNNPredictor_VGG16, "./model/VGG16/predict_net.pb", "The given path to the predict protobuffer."); +CAFFE2_DEFINE_string(init_net, "./model/VGG16/init_net.pb", "The given path to the init protobuffer."); +CAFFE2_DEFINE_string(predict_net, "./model/VGG16/predict_net.pb", "The given path to the predict protobuffer."); using namespace caffe2; @@ -43,21 +43,21 @@ class CNNPredictor_VGG16{ char **a[1]; caffe2::GlobalInit(&n, a); - if (!std::ifstream(FLAGS_init_net_CNNPredictor_VGG16).good()) { - std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net_CNNPredictor_VGG16 << "' does not exist." << std::endl; + if (!std::ifstream(FLAGS_init_net).good()) { + std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net << "' does not exist." << std::endl; exit(1); } - if (!std::ifstream(FLAGS_predict_net_CNNPredictor_VGG16).good()) { - std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net_CNNPredictor_VGG16 << "' does not exist." << std::endl; + if (!std::ifstream(FLAGS_predict_net).good()) { + std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net << "' does not exist." << std::endl; exit(1); } std::cout << "\nLoading network..." << std::endl; // Read protobuf - CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net_CNNPredictor_VGG16, &initNet)); - CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net_CNNPredictor_VGG16, &predictNet)); + CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net, &initNet)); + CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net, &predictNet)); // Set device type #ifdef USE_GPU @@ -114,4 +114,4 @@ class CNNPredictor_VGG16{ } }; -#endif // CNNPREDICTOR_VGG16 +#endif // CNNPREDICTOR_VGG16 \ No newline at end of file diff --git a/src/test/resources/valid_tests/data_paths.txt b/src/test/resources/valid_tests/data_paths.txt deleted file mode 100644 index 1744c63..0000000 --- a/src/test/resources/valid_tests/data_paths.txt +++ /dev/null @@ -1,5 +0,0 @@ -Alexnet data/Alexnet -CifarClassifierNetwork data/CifarClassifierNetwork -LeNet data/LeNet -VGG16 data/VGG16 -MultipleOutputs data/MultipleOutputs \ No newline at end of file -- GitLab