Skip to content

Commit

Permalink
[TensorRT EP] Fix concurrency issue for TRT custom op list (microsoft…
Browse files Browse the repository at this point in the history
…#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: microsoft#20089
  • Loading branch information
chilo-ms authored and Ted Themistokleous committed May 7, 2024
1 parent 636a40c commit adc852e
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ extern TensorrtLogger& GetTensorrtLogger();
common::Status CreateTensorRTCustomOpDomainList(std::vector<OrtCustomOpDomain*>& domain_list, const std::string extra_plugin_lib_paths) {
static std::unique_ptr<OrtCustomOpDomain> custom_op_domain = std::make_unique<OrtCustomOpDomain>();
static std::vector<std::unique_ptr<TensorRTCustomOp>> created_custom_op_list;
static OrtMutex mutex;
std::lock_guard<OrtMutex> 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();
Expand Down

0 comments on commit adc852e

Please sign in to comment.