27
27
#include " json.hpp"
28
28
29
29
PopartConfig* PopartConfig::instance_ = new PopartConfig();
30
+ std::vector<std::string> PopartConfig::mode = {" unknown" , " pipeline" ,
31
+ " parallel" , " sequence" };
32
+
33
+ const char * bool_to_str (const bool & value) { return value ? " true" : " false" ; }
30
34
31
35
const std::string& get_config_path_from_cache_file (
32
36
const std::string& cache_path) {
@@ -43,6 +47,7 @@ const std::string& get_config_path_from_cache_file(
43
47
44
48
void PopartConfig::use_default () {
45
49
amp_ = 0.6 ;
50
+ sdk_version_ = popart::core::packageHash ();
46
51
version_ = " 1.0.0" ;
47
52
batches_per_step_ = 1 ;
48
53
ipu_num_ = 1 ;
@@ -54,19 +59,27 @@ void PopartConfig::use_default() {
54
59
queue_type_ = " LockFreeQueue" ;
55
60
queue_capacity_ = 1024 * 1024 ;
56
61
debug_ = false ;
57
- default_config_string_ =
62
+ char config_base[] =
58
63
" {\n \
59
- \" version\" :\" 1.0.0\" ,\n \
60
- \" amp\" :0.6,\n \
61
- \" batches_per_step\" :1,\n \
62
- \" execution_mode\" :\" sequence\" ,\n \
63
- \" ipu_num\" :1,\n \
64
- \" load_onnx\" :false, \n \
65
- \" load_onnx_path\" :\" test-load-time.onnx\" ,\n \
66
- \" queue_type\" :\" LockFreeQueue\" ,\n \
67
- \" queue_capacity\" :1048576,\n \
68
- \" debug\" : false\n \
64
+ \" sdk_version\" :\" %s\" ,\n \
65
+ \" version\" :\" %s\" ,\n \
66
+ \" amp\" :%f,\n \
67
+ \" batches_per_step\" :%d,\n \
68
+ \" execution_mode\" :\" %s\" ,\n \
69
+ \" ipu_num\" :%d,\n \
70
+ \" load_onnx\" :%s, \n \
71
+ \" load_onnx_path\" :\" %s\" ,\n \
72
+ \" queue_type\" :\" %s\" ,\n \
73
+ \" queue_capacity\" :%d,\n \
74
+ \" debug\" :%s\n \
69
75
}\n " ;
76
+ char raw_default_config[1024 ] = {0 };
77
+ snprintf (raw_default_config, 1024 , config_base, sdk_version_.c_str (),
78
+ version_.c_str (), amp_, batches_per_step_,
79
+ PopartConfig::mode[(int )execution_mode_].c_str (), ipu_num_,
80
+ bool_to_str (load_onnx_), load_onnx_path_.c_str (),
81
+ queue_type_.c_str (), queue_capacity_, bool_to_str (debug_));
82
+ default_config_string_ = raw_default_config;
70
83
}
71
84
72
85
odla_status PopartConfig::load_config (const char * env_file_path) {
@@ -104,6 +117,8 @@ odla_status PopartConfig::load_config(const char* env_file_path) {
104
117
void PopartConfig::parse_from_json (const json& jf) {
105
118
if (jf.contains (" sdk_version" )) {
106
119
sdk_version_ = jf[" sdk_version" ].get <std::string>();
120
+ } else {
121
+ sdk_version_ = popart::core::packageHash ();
107
122
}
108
123
if (jf.contains (" amp" )) {
109
124
amp_ = jf[" amp" ].get <float >();
@@ -196,12 +211,12 @@ odla_status PopartConfig::load_from_file(const std::string& file_path) {
196
211
void PopartConfig::print () {
197
212
std::string line (80 , ' =' );
198
213
popart::logging::info (line);
214
+ popart::logging::info (" sdk_version: {}" , sdk_version_);
199
215
popart::logging::info (" version: {}" , version_);
200
216
popart::logging::info (" amp: {}" , amp_);
201
217
popart::logging::info (" batch_per_step: {}" , batches_per_step_);
202
- std::string mode[] = {" UNKNOWN" , " PIPELINE" , " PARALLEL" , " SEQUENCE" };
203
218
popart::logging::info (" execution_mode: {}" ,
204
- mode[(long unsigned int )execution_mode_]);
219
+ PopartConfig:: mode[(long unsigned int )execution_mode_]);
205
220
popart::logging::info (" ipu_num: {}" , ipu_num_);
206
221
std::string bool_value[] = {" false" , " true" };
207
222
popart::logging::info (" load_onnx: {}" ,
0 commit comments