Skip to content

Commit 0f52340

Browse files
authored
Move computation init to odla_BindToArgument to avoid problem caused by ASYNC call (#840)
* callback function definition changes, and handle the error raised by poplar SDK * Move computation init to odla_BindToArgument to avoid early call odla_CreteContext before compuation graph constructed in ASYN call
1 parent f462914 commit 0f52340

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ODLA/platforms/odla_popart/odla_compute.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,6 @@ odla_status odla_CreateComputation(odla_computation* comp) {
197197
}
198198

199199
odla_status odla_CreateContext(odla_context* context) {
200-
odla_status status =
201-
_odla_computation::instance(false)
202-
->init(); // Place the init here to avoid long execution problem
203-
if (status != ODLA_SUCCESS &&
204-
_odla_computation::instance()->session == nullptr) {
205-
popart::logging::err("init computation item in CreateContext failed.");
206-
return status;
207-
}
208200
if (PopartConfig::instance()->execution_mode() == PIPELINE_ASYNC)
209201
*context = new _odla_pipeline_async_context(_odla_computation::instance());
210202
else
@@ -299,6 +291,14 @@ odla_value odla_CreateConstant(odla_value_type type, const void* data_ptr,
299291

300292
odla_status odla_BindToArgument(odla_value value, const odla_void* data_ptr,
301293
odla_context context) {
294+
odla_status status =
295+
_odla_computation::instance(false)
296+
->init(); // to avoid long execution and async context problem
297+
if (status != ODLA_SUCCESS &&
298+
_odla_computation::instance()->session == nullptr) {
299+
popart::logging::err("init computation item in CreateContext failed.");
300+
return status;
301+
}
302302
if (!context->hold("odla_BindToArgument")) return ODLA_FAILURE;
303303
std::vector<int64_t> shape =
304304
context->comp->builder->getTensorShape(value->tensor_id);

0 commit comments

Comments
 (0)