Skip to content

Commit

Permalink
Move computation init to odla_BindToArgument to avoid problem caused …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
jackzipu authored Mar 1, 2022
1 parent f462914 commit 0f52340
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ODLA/platforms/odla_popart/odla_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,6 @@ odla_status odla_CreateComputation(odla_computation* comp) {
}

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

odla_status odla_BindToArgument(odla_value value, const odla_void* data_ptr,
odla_context context) {
odla_status status =
_odla_computation::instance(false)
->init(); // to avoid long execution and async context problem
if (status != ODLA_SUCCESS &&
_odla_computation::instance()->session == nullptr) {
popart::logging::err("init computation item in CreateContext failed.");
return status;
}
if (!context->hold("odla_BindToArgument")) return ODLA_FAILURE;
std::vector<int64_t> shape =
context->comp->builder->getTensorShape(value->tensor_id);
Expand Down

0 comments on commit 0f52340

Please sign in to comment.