Skip to content

Commit fc97a57

Browse files
jackziputianboh
andauthored
Add the test for the cache configuration (#730)
* Add information to check the cache sdk version and the working sdk version * Set the log level to info for test * Add environment variable for error injection test * format the code for lint check * Add information to show the ENGION OPTIONS set * Make it recompile when cache version mismatch * Remote the environment for error simulator to make it set by environment variable * Add error injector for temporarily test * Fix the problem when there's not the error injection config file * Move the error injector to the odla_CreateComputation to make sure it will be called for each inference request * Add try catch to computation create and init * make the error handling code at one place * Use config file setting for batch per step when it's inconsistent with ODLA set * set the log level when error injector used * pass the error code to caller * Make sdk version mismatch cache recompile when error injector set * Make the popart log level take POPART_LOG_LEVEL firstly * change format to pass lint Co-authored-by: tianboh <54729592+tianboh@users.noreply.github.com>
1 parent 13a4b2d commit fc97a57

File tree

4 files changed

+185
-166
lines changed

4 files changed

+185
-166
lines changed

ODLA/platforms/odla_popart/odla_compute.cc

+27-4
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ odla_status odla_SetComputationItem(odla_computation comp, odla_item_type type,
6363
comp->opts.cache_dir = (reinterpret_cast<char*>(value));
6464
break;
6565
case 1001: // load cache directly, need set path of cache file
66+
{
6667
popart::logging::info("set load_or_save_cache");
6768
PopartConfig::instance()->set_load_or_save_cache(true);
6869
PopartConfig::instance()->set_cache_path(
6970
(std::string) reinterpret_cast<char*>(value));
70-
break;
71+
} break;
7172
case 1002:
7273
setenv("POPART_LOG_LEVEL", "INFO", 1);
7374
default:
74-
std::cerr << "Unsupported property type: " << type << std::endl;
75+
popart::logging::err("Unsupported property type: {}", type);
7576
return ODLA_UNSUPPORTED_DATATYPE;
7677
}
7778
return ODLA_SUCCESS;
@@ -96,7 +97,7 @@ odla_status odla_CreateExecutable(odla_executable* executable,
9697
// create executable
9798
if (ret != ODLA_SUCCESS) {
9899
popart::logging::err("Failed to init computation when compiling.");
99-
return ODLA_FAILURE;
100+
return ret;
100101
}
101102
_odla_computation::instance()->compile_and_export();
102103
}
@@ -117,6 +118,28 @@ odla_status odla_LoadExecutable(const odla_char* file_name, odla_device device,
117118
}
118119

119120
odla_status odla_CreateComputation(odla_computation* comp) {
121+
auto injector = PopartConfig::instance()->temp_get_error_inject_env();
122+
if (injector.empty()) {
123+
popart::logging::warn("NO VALUE SET for error injector");
124+
if (nullptr == getenv("POPART_LOG_LEVEL")) { // if POPART_LOG_LEVEL not set
125+
popart::logging::warn("popart logging level set to warn.");
126+
popart::logging::setLogLevel(popart::logging::Module::popart,
127+
popart::logging::Level::Warn);
128+
}
129+
} else {
130+
setenv("POPLAR_ENGINE_OPTIONS", injector.c_str(), 1);
131+
if (nullptr == getenv("POPART_LOG_LEVEL")) { // if POPART_LOG_LEVEL not set
132+
popart::logging::warn("popart logging level set to info.");
133+
popart::logging::setLogLevel(popart::logging::Module::popart,
134+
popart::logging::Level::Info);
135+
}
136+
}
137+
if (nullptr != getenv("POPLAR_ENGINE_OPTIONS"))
138+
popart::logging::info("The env POPLAR_ENGINE_OPTIONS value is: {}",
139+
getenv("POPLAR_ENGINE_OPTIONS"));
140+
else
141+
popart::logging::info("The env POPLAR_ENGINE_OPTIONS value is not set");
142+
120143
static void* custom_op_handle = nullptr;
121144
*comp = _odla_computation::instance();
122145
popart::logging::info("computation created");
@@ -159,7 +182,7 @@ odla_status odla_CreateContext(odla_context* context) {
159182
if (status != ODLA_SUCCESS &&
160183
_odla_computation::instance()->session == nullptr) {
161184
popart::logging::err("init computation item in CreateContext failed.");
162-
return ODLA_FAILURE;
185+
return status;
163186
}
164187
*context = new _odla_pipeline_context(_odla_computation::instance());
165188
return ODLA_SUCCESS;

0 commit comments

Comments
 (0)