Skip to content

Commit

Permalink
Revert "Fix race condition in CUDA, ROCm, and TensorRT EP GetKernelRe…
Browse files Browse the repository at this point in the history
…gistry() implementations. (#10200)"

This reverts commit d07a237.
  • Loading branch information
chilo-ms committed Mar 8, 2022
1 parent f4fd67c commit 04e91fb
Show file tree
Hide file tree
Showing 4 changed files with 868 additions and 904 deletions.
23 changes: 11 additions & 12 deletions onnxruntime/core/providers/cuda/cuda_execution_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2184,23 +2184,22 @@ static Status RegisterCudaKernels(KernelRegistry& kernel_registry) {

} // namespace cuda

static std::shared_ptr<KernelRegistry>& CudaKernelRegistry() {
// static local variable ensures thread-safe initialization
static std::shared_ptr<KernelRegistry> cuda_kernel_registry = []() {
std::shared_ptr<KernelRegistry> registry = KernelRegistry::Create();
ORT_THROW_IF_ERROR(cuda::RegisterCudaKernels(*registry));
return registry;
}();

return cuda_kernel_registry;
}
static std::shared_ptr<onnxruntime::KernelRegistry> s_kernel_registry;

void Shutdown_DeleteRegistry() {
CudaKernelRegistry().reset();
s_kernel_registry.reset();
}

std::shared_ptr<KernelRegistry> CUDAExecutionProvider::GetKernelRegistry() const {
return CudaKernelRegistry();
if (!s_kernel_registry) {
s_kernel_registry = KernelRegistry::Create();
auto status = cuda::RegisterCudaKernels(*s_kernel_registry);
if (!status.IsOK())
s_kernel_registry.reset();
ORT_THROW_IF_ERROR(status);
}

return s_kernel_registry;
}

static bool RNNNeedFallbackToCPU(const onnxruntime::Node& node,
Expand Down
Loading

0 comments on commit 04e91fb

Please sign in to comment.