Commit 901e863c authored by Carlos Alfredo Yeverino Rodriguez's avatar Carlos Alfredo Yeverino Rodriguez

Merge branch 'revert-e86f9476' into 'master'

Revert e86f9476

See merge request !37
parents bc274a53 350723da
Pipeline #108019 passed with stages
in 7 minutes and 18 seconds
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
<groupId>de.monticore.lang.monticar</groupId> <groupId>de.monticore.lang.monticar</groupId>
<artifactId>cnnarch-caffe2-generator</artifactId> <artifactId>cnnarch-caffe2-generator</artifactId>
<version>0.2.9</version> <version>0.2.10-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= --> <!-- == PROJECT DEPENDENCIES ============================================= -->
<properties> <properties>
<!-- .. SE-Libraries .................................................. --> <!-- .. SE-Libraries .................................................. -->
<CNNArch.version>0.2.9</CNNArch.version> <CNNArch.version>0.3.0-SNAPSHOT</CNNArch.version>
<CNNTrain.version>0.2.6</CNNTrain.version> <CNNTrain.version>0.2.6</CNNTrain.version>
<embedded-montiarc-math-opt-generator>0.1.4</embedded-montiarc-math-opt-generator> <embedded-montiarc-math-opt-generator>0.1.4</embedded-montiarc-math-opt-generator>
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<id>se-nexus</id> <id>se-nexus</id>
<username>cibuild</username> <username>cibuild</username>
<password>${env.cibuild}</password> <password>${env.cibuild}</password>
</server> </server>
</servers> </servers>
<mirrors> <mirrors>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<id>se-nexus</id> <id>se-nexus</id>
<mirrorOf>external:*</mirrorOf> <mirrorOf>external:*</mirrorOf>
<url>https://nexus.se.rwth-aachen.de/content/groups/public</url> <url>https://nexus.se.rwth-aachen.de/content/groups/public</url>
</mirror> </mirror>
</mirrors> </mirrors>
<profiles> <profiles>
...@@ -93,5 +93,5 @@ ...@@ -93,5 +93,5 @@
<activeProfiles> <activeProfiles>
<activeProfile>se-nexus</activeProfile> <activeProfile>se-nexus</activeProfile>
</activeProfiles> </activeProfiles>
</settings> </settings>
\ No newline at end of file
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
package de.monticore.lang.monticar.cnnarch.caffe2generator; package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.monticore.lang.monticar.cnnarch.CNNArchGenerator; import de.monticore.lang.monticar.cnnarch.CNNArchGenerator;
import de.monticore.lang.monticar.cnnarch.DataPathConfigParser;
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.ArchitectureElementSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureElementSymbol;
...@@ -87,6 +88,11 @@ public class CNNArch2Caffe2 extends CNNArchGenerator{ ...@@ -87,6 +88,11 @@ public class CNNArch2Caffe2 extends CNNArchGenerator{
} }
try{ try{
String confPath = getModelsDirPath() + "/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()); generateFiles(compilationUnit.get().getArchitecture());
} catch (IOException e){ } catch (IOException e){
Log.error(e.toString()); Log.error(e.toString());
......
...@@ -89,6 +89,11 @@ public class CNNArchTemplateController { ...@@ -89,6 +89,11 @@ public class CNNArchTemplateController {
return getArchitecture().getEnclosingScope().getSpanningSymbol().get().getFullName().replaceAll("\\.","_"); return getArchitecture().getEnclosingScope().getSpanningSymbol().get().getFullName().replaceAll("\\.","_");
} }
public String getDataPath(){
return getArchitecture().getDataPath();
}
public List<String> getLayerInputs(ArchitectureElementSymbol layer){ public List<String> getLayerInputs(ArchitectureElementSymbol layer){
List<String> inputNames = new ArrayList<>(); List<String> inputNames = new ArrayList<>();
...@@ -125,6 +130,10 @@ public class CNNArchTemplateController { ...@@ -125,6 +130,10 @@ public class CNNArchTemplateController {
return list; return list;
} }
public String getComponentName(){
return getArchitecture().getComponentName();
}
public String getArchitectureLoss(){ public String getArchitectureLoss(){
return this.loss; return this.loss;
} }
......
...@@ -13,8 +13,8 @@ class ${tc.fileNameWithoutEnding}: ...@@ -13,8 +13,8 @@ class ${tc.fileNameWithoutEnding}:
module = None module = None
_current_dir_ = os.path.join('./') _current_dir_ = os.path.join('./')
_data_dir_ = os.path.join(_current_dir_, 'data', '${tc.fullArchitectureName}') _data_dir_ = os.path.join(_current_dir_, '${tc.dataPath}')
_model_dir_ = os.path.join(_current_dir_, 'model', '${tc.fullArchitectureName}') _model_dir_ = os.path.join(_current_dir_, 'model', '${tc.componentName}')
_init_net_ = os.path.join(_model_dir_, 'init_net.pb') _init_net_ = os.path.join(_model_dir_, 'init_net.pb')
_predict_net_ = os.path.join(_model_dir_, 'predict_net.pb') _predict_net_ = os.path.join(_model_dir_, 'predict_net.pb')
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include <iostream> #include <iostream>
#include <map> #include <map>
CAFFE2_DEFINE_string(init_net, "./model/${tc.fullArchitectureName}/init_net.pb", "The given path to the init protobuffer."); 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, "./model/${tc.fullArchitectureName}/predict_net.pb", "The given path to the predict protobuffer."); CAFFE2_DEFINE_string(predict_net_${tc.fileNameWithoutEnding}, "./model/${tc.componentName}/predict_net.pb", "The given path to the predict protobuffer.");
using namespace caffe2; using namespace caffe2;
...@@ -43,21 +43,21 @@ class ${tc.fileNameWithoutEnding}{ ...@@ -43,21 +43,21 @@ class ${tc.fileNameWithoutEnding}{
char **a[1]; char **a[1];
caffe2::GlobalInit(&n, a); caffe2::GlobalInit(&n, a);
if (!std::ifstream(FLAGS_init_net).good()) { if (!std::ifstream(FLAGS_init_net_${tc.fileNameWithoutEnding}).good()) {
std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net << "' does not exist." << std::endl; std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net_${tc.fileNameWithoutEnding} << "' does not exist." << std::endl;
exit(1); exit(1);
} }
if (!std::ifstream(FLAGS_predict_net).good()) { if (!std::ifstream(FLAGS_predict_net_${tc.fileNameWithoutEnding}).good()) {
std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net << "' does not exist." << std::endl; std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net_${tc.fileNameWithoutEnding} << "' does not exist." << std::endl;
exit(1); exit(1);
} }
std::cout << "\nLoading network..." << std::endl; std::cout << "\nLoading network..." << std::endl;
// Read protobuf // Read protobuf
CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net, &initNet)); CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net_${tc.fileNameWithoutEnding}, &initNet));
CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net, &predictNet)); CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net_${tc.fileNameWithoutEnding}, &predictNet));
// Set device type // Set device type
#ifdef USE_GPU #ifdef USE_GPU
......
Alexnet data/Alexnet
CifarClassifierNetwork data/CifarClassifierNetwork
LeNet data/LeNet
VGG16 data/VGG16
MultipleOutputs data/MultipleOutputs
\ No newline at end of file
Alexnet data/Alexnet
CifarClassifierNetwork data/CifarClassifierNetwork
LeNet data/LeNet
VGG16 data/VGG16
MultipleOutputs data/MultipleOutputs
\ No newline at end of file
...@@ -12,7 +12,7 @@ class CNNCreator_Alexnet: ...@@ -12,7 +12,7 @@ class CNNCreator_Alexnet:
module = None module = None
_current_dir_ = os.path.join('./') _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') _model_dir_ = os.path.join(_current_dir_, 'model', 'Alexnet')
_init_net_ = os.path.join(_model_dir_, 'init_net.pb') _init_net_ = os.path.join(_model_dir_, 'init_net.pb')
......
...@@ -12,7 +12,7 @@ class CNNCreator_CifarClassifierNetwork: ...@@ -12,7 +12,7 @@ class CNNCreator_CifarClassifierNetwork:
module = None module = None
_current_dir_ = os.path.join('./') _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') _model_dir_ = os.path.join(_current_dir_, 'model', 'CifarClassifierNetwork')
_init_net_ = os.path.join(_model_dir_, 'init_net.pb') _init_net_ = os.path.join(_model_dir_, 'init_net.pb')
......
...@@ -13,7 +13,7 @@ class CNNCreator_LeNet: ...@@ -13,7 +13,7 @@ class CNNCreator_LeNet:
module = None module = None
_current_dir_ = os.path.join('./') _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') _model_dir_ = os.path.join(_current_dir_, 'model', 'LeNet')
_init_net_ = os.path.join(_model_dir_, 'init_net.pb') _init_net_ = os.path.join(_model_dir_, 'init_net.pb')
......
...@@ -13,7 +13,7 @@ class CNNCreator_VGG16: ...@@ -13,7 +13,7 @@ class CNNCreator_VGG16:
module = None module = None
_current_dir_ = os.path.join('./') _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') _model_dir_ = os.path.join(_current_dir_, 'model', 'VGG16')
_init_net_ = os.path.join(_model_dir_, 'init_net.pb') _init_net_ = os.path.join(_model_dir_, 'init_net.pb')
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include <iostream> #include <iostream>
#include <map> #include <map>
CAFFE2_DEFINE_string(init_net, "./model/LeNet/init_net.pb", "The given path to the init protobuffer."); CAFFE2_DEFINE_string(init_net_CNNPredictor_LeNet, "./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."); CAFFE2_DEFINE_string(predict_net_CNNPredictor_LeNet, "./model/LeNet/predict_net.pb", "The given path to the predict protobuffer.");
using namespace caffe2; using namespace caffe2;
...@@ -43,21 +43,21 @@ class CNNPredictor_LeNet{ ...@@ -43,21 +43,21 @@ class CNNPredictor_LeNet{
char **a[1]; char **a[1];
caffe2::GlobalInit(&n, a); caffe2::GlobalInit(&n, a);
if (!std::ifstream(FLAGS_init_net).good()) { if (!std::ifstream(FLAGS_init_net_CNNPredictor_LeNet).good()) {
std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net << "' does not exist." << std::endl; std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net_CNNPredictor_LeNet << "' does not exist." << std::endl;
exit(1); exit(1);
} }
if (!std::ifstream(FLAGS_predict_net).good()) { if (!std::ifstream(FLAGS_predict_net_CNNPredictor_LeNet).good()) {
std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net << "' does not exist." << std::endl; std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net_CNNPredictor_LeNet << "' does not exist." << std::endl;
exit(1); exit(1);
} }
std::cout << "\nLoading network..." << std::endl; std::cout << "\nLoading network..." << std::endl;
// Read protobuf // Read protobuf
CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net, &initNet)); CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net_CNNPredictor_LeNet, &initNet));
CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net, &predictNet)); CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net_CNNPredictor_LeNet, &predictNet));
// Set device type // Set device type
#ifdef USE_GPU #ifdef USE_GPU
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include <iostream> #include <iostream>
#include <map> #include <map>
CAFFE2_DEFINE_string(init_net, "./model/VGG16/init_net.pb", "The given path to the init protobuffer."); CAFFE2_DEFINE_string(init_net_CNNPredictor_VGG16, "./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."); CAFFE2_DEFINE_string(predict_net_CNNPredictor_VGG16, "./model/VGG16/predict_net.pb", "The given path to the predict protobuffer.");
using namespace caffe2; using namespace caffe2;
...@@ -43,21 +43,21 @@ class CNNPredictor_VGG16{ ...@@ -43,21 +43,21 @@ class CNNPredictor_VGG16{
char **a[1]; char **a[1];
caffe2::GlobalInit(&n, a); caffe2::GlobalInit(&n, a);
if (!std::ifstream(FLAGS_init_net).good()) { if (!std::ifstream(FLAGS_init_net_CNNPredictor_VGG16).good()) {
std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net << "' does not exist." << std::endl; std::cerr << "\nNetwork loading failure, init_net file '" << FLAGS_init_net_CNNPredictor_VGG16 << "' does not exist." << std::endl;
exit(1); exit(1);
} }
if (!std::ifstream(FLAGS_predict_net).good()) { if (!std::ifstream(FLAGS_predict_net_CNNPredictor_VGG16).good()) {
std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net << "' does not exist." << std::endl; std::cerr << "\nNetwork loading failure, predict_net file '" << FLAGS_predict_net_CNNPredictor_VGG16 << "' does not exist." << std::endl;
exit(1); exit(1);
} }
std::cout << "\nLoading network..." << std::endl; std::cout << "\nLoading network..." << std::endl;
// Read protobuf // Read protobuf
CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net, &initNet)); CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_init_net_CNNPredictor_VGG16, &initNet));
CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net, &predictNet)); CAFFE_ENFORCE(ReadProtoFromFile(FLAGS_predict_net_CNNPredictor_VGG16, &predictNet));
// Set device type // Set device type
#ifdef USE_GPU #ifdef USE_GPU
...@@ -114,4 +114,4 @@ class CNNPredictor_VGG16{ ...@@ -114,4 +114,4 @@ class CNNPredictor_VGG16{
} }
}; };
#endif // CNNPREDICTOR_VGG16 #endif // CNNPREDICTOR_VGG16
\ No newline at end of file
Alexnet data/Alexnet
CifarClassifierNetwork data/CifarClassifierNetwork
LeNet data/LeNet
VGG16 data/VGG16
MultipleOutputs data/MultipleOutputs
\ 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