From ed4edfec15c54595e5299aa69fb5ee156b632a67 Mon Sep 17 00:00:00 2001 From: Chi Lo <54722500+chilo-ms@users.noreply.github.com> Date: Tue, 26 Mar 2024 21:20:14 -0700 Subject: [PATCH] [TensorRT EP] Fix concurrency issue for TRT custom op list (#20093) The `CreateTensorRTCustomOpDomainList()` is not thread-safe due to its static variables, `created_custom_op_list` and `custom_op_domain`. This PR makes sure synchronization using mutex. see issue: https://github.com/microsoft/onnxruntime/issues/20089 --- .../tensorrt/tensorrt_execution_provider_custom_ops.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider_custom_ops.cc b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider_custom_ops.cc index eb340ba1e64b6..31f1d10a7b654 100644 --- a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider_custom_ops.cc +++ b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider_custom_ops.cc @@ -29,6 +29,8 @@ extern TensorrtLogger& GetTensorrtLogger(); common::Status CreateTensorRTCustomOpDomainList(std::vector& domain_list, const std::string extra_plugin_lib_paths) { static std::unique_ptr custom_op_domain = std::make_unique(); static std::vector> created_custom_op_list; + static OrtMutex mutex; + std::lock_guard lock(mutex); if (custom_op_domain->domain_ != "" && custom_op_domain->custom_ops_.size() > 0) { domain_list.push_back(custom_op_domain.get()); return Status::OK();