Skip to content

Commit

Permalink
[TensorRT EP] Fix concurrency issue for TRT custom op list (#20093)
Browse files Browse the repository at this point in the history
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: #20089
  • Loading branch information
chilo-ms authored and YUNQIUGUO committed Mar 27, 2024
1 parent c9ebded commit ed4edfe
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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 ed4edfe

Please sign in to comment.