Use yaml config file for the demo instead of param list
Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <ios>
|
||||
#include <chrono>
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
#define dnnType float
|
||||
|
||||
@@ -137,4 +138,19 @@ static inline bool isCudaPointer(void *data) {
|
||||
cudaPointerAttributes attr;
|
||||
return cudaPointerGetAttributes(&attr, data) == 0;
|
||||
}
|
||||
|
||||
inline YAML::Node YAMLloadConf(const std::string& conf_file) {
|
||||
std::cerr<<"Loading YAML: "<<conf_file<<"\n";
|
||||
return YAML::LoadFile(conf_file);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T YAMLgetConf(YAML::Node conf, std::string key, T defaultVal) {
|
||||
T val = defaultVal;
|
||||
if(conf && conf[key]) {
|
||||
val = conf[key].as<T>();
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
#endif //UTILS_H
|
||||
|
||||
Reference in New Issue
Block a user