Executor should wait for operators before deleting the local scope
Created by: tonyyang-svail
In every Executor:Run()
, all the temporary variables are created in a local scope. This local scope (including variables belong to it) is deleted at the end of the Executor:Run()
.
Since operators maybe launched asynchronously, the host code has to explicitly add a wait. Otherwise, delete local scope may happen before the execution of an operator.
Sidenote: fetch_op, usually the last op to be executed, has a wait. So ProgramDesc with fetch op won't have this issue. But it is not guaranteed that every ProgramDesc has a fetch op at the end.