Commit f253088f authored by Malte Heithoff's avatar Malte Heithoff
Browse files

Add cmake dependencies when they are needed

parent 48beb9f4
Pipeline #336060 passed with stage
in 2 minutes and 27 seconds
......@@ -24,7 +24,7 @@ import java.util.List;
import java.util.Map;
public class CNNArch2Caffe2 extends CNNArchGenerator {
CMakeConfig cMakeConfig;
CMakeConfig cMakeConfig = new CMakeConfig("");
public CNNArch2Caffe2() {
architectureSupportChecker = new CNNArch2Caffe2ArchitectureSupportChecker();
......@@ -33,6 +33,12 @@ public class CNNArch2Caffe2 extends CNNArchGenerator {
//check cocos with CNNArchCocos.checkAll(architecture) before calling this method.
public List<FileContent> generateStrings(TaggingResolver taggingResolver, ArchitectureSymbol architecture){
if(architecture != null && architecture.getFullName() != null) {
cMakeConfig.getCMakeListsViewModel().setCompName(architecture.getFullName().replace('.', '_').replace('[', '_').replace(']', '_'));
}
// Add cmake dependencies when they are needed
addCMakeDependencies();
List<FileContent> fileContents = new ArrayList<>();
CNNArchTemplateController archTc = new CNNArchTemplateController(architecture);
FileContent temp;
......@@ -50,6 +56,22 @@ public class CNNArch2Caffe2 extends CNNArchGenerator {
return fileContents;
}
private void addCMakeDependencies() {
cMakeConfig.addModuleDependency(new CMakeFindModule("Armadillo", true));
cMakeConfig.addModuleDependency(new CMakeFindModule("Caffe2", true));
cMakeConfig.addCMakeCommand("set(LIBS ${LIBS} -lprotobuf -lglog -lgflags)");
cMakeConfig.addCMakeCommand("find_package(CUDA)" + "\n");
//Needed since CUDA cannot be found correctly (including CUDA_curand_LIBRARY)
cMakeConfig.addCMakeCommand("if(CUDA_FOUND)" + "\n"
+ " set(LIBS ${LIBS} caffe2 caffe2_gpu)" + "\n"
+ " set(INCLUDE_DIRS ${INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS})" + "\n"
+ " set(LIBS ${LIBS} ${CUDA_LIBRARIES} ${CUDA_curand_LIBRARY})" + "\n"
+ "else()" + "\n"
+ " set(LIBS ${LIBS} caffe2)" + "\n"
+ "endif()");
}
public List<FileContent> generateCMakeContent(String rootModelName) {
List<FileContent> fileContents = new ArrayList<>();
// model name should start with a lower case letter. If it is a component, replace dot . by _
......@@ -57,19 +79,7 @@ public class CNNArch2Caffe2 extends CNNArchGenerator {
rootModelName = rootModelName.substring(0, 1).toLowerCase() + rootModelName.substring(1);
cMakeConfig = new CMakeConfig(rootModelName);
cMakeConfig.addModuleDependency(new CMakeFindModule("Armadillo", true));
cMakeConfig.addModuleDependency(new CMakeFindModule("Caffe2", true));
cMakeConfig.addCMakeCommand("set(LIBS ${LIBS} -lprotobuf -lglog -lgflags)");
cMakeConfig.addCMakeCommand("find_package(CUDA)" + "\n");
//Needed since CUDA cannot be found correctly (including CUDA_curand_LIBRARY)
cMakeConfig.addCMakeCommand("if(CUDA_FOUND)" + "\n"
+ " set(LIBS ${LIBS} caffe2 caffe2_gpu)" + "\n"
+ " set(INCLUDE_DIRS ${INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS})" + "\n"
+ " set(LIBS ${LIBS} ${CUDA_LIBRARIES} ${CUDA_curand_LIBRARY})" + "\n"
+ "else()" + "\n"
+ " set(LIBS ${LIBS} caffe2)" + "\n"
+ "endif()");
addCMakeDependencies();
for (FileContent fileContent : cMakeConfig.generateCMakeFiles()){
fileContents.add(fileContent);
......
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