Skip to content

Commit

Permalink
vsort/vs_onnxruntime.cpp: eliminate redundant graph replay
Browse files Browse the repository at this point in the history
  • Loading branch information
WolframRhodium committed Aug 7, 2022
1 parent d7fb1a7 commit afcf5e6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions vsort/vs_onnxruntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,19 @@ static const VSFrameRef *VS_CC vsOrtGetFrame(
if (resource.require_replay) [[unlikely]] {
resource.require_replay = false;

// runs it under a global lock
// onnxruntime uses global-mode stream capture on a private stream
// this lock prevents concurrent capture sequences in other threads
//
// note that this applies only to stream capture from the ort library
// this fails when another plugin also uses global-mode stream capture
std::lock_guard _ { capture_lock };
checkError(ortapi->RunWithBinding(resource.session, nullptr, resource.binding));
}

checkError(ortapi->RunWithBinding(resource.session, nullptr, resource.binding));
// onnxruntime replays the graph itself in CUDAExecutionProvider::OnRunEnd
} else {
checkError(ortapi->RunWithBinding(resource.session, nullptr, resource.binding));
}

#ifdef ENABLE_CUDA
if (d->backend == Backend::CUDA) {
Expand Down

0 comments on commit afcf5e6

Please sign in to comment.