From 96bec6c27056bef96e0c798303e82dc40b402450 Mon Sep 17 00:00:00 2001 From: Chi Lo Date: Wed, 27 Mar 2024 01:43:15 +0000 Subject: [PATCH] use lock --- .../tensorrt/tensorrt_execution_provider_custom_ops.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 a6091bfdb2760..bd8b46d9aabb8 100644 --- a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider_custom_ops.cc +++ b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider_custom_ops.cc @@ -26,8 +26,10 @@ extern TensorrtLogger& GetTensorrtLogger(); * So, TensorRTCustomOp uses variadic inputs/outputs to pass ONNX graph validation. */ common::Status CreateTensorRTCustomOpDomainList(std::vector& domain_list, const std::string extra_plugin_lib_paths) { - static thread_local std::unique_ptr custom_op_domain = std::make_unique(); - static thread_local std::vector> created_custom_op_list; + 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();