Skip to content

Commit

Permalink
Merge pull request #659 from jolibrain/trt_mutex
Browse files Browse the repository at this point in the history
Add mutex to TensorRT prediction calls
  • Loading branch information
beniz authored Nov 19, 2019
2 parents ccbc63f + 39b6a25 commit 61ce53a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/backends/tensorrt/tensorrtlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ namespace dd
int TensorRTLib<TInputConnectorStrategy,TOutputConnectorStrategy,TMLModel>::predict(const APIData &ad,
APIData &out)
{
std::lock_guard<std::mutex> lock(_net_mutex); // no concurrent calls since the net is not re-instantiated

APIData ad_output = ad.getobj("parameters").getobj("output");
int blank_label = -1;
std::string out_blob = "prob";
Expand Down
2 changes: 2 additions & 0 deletions src/backends/tensorrt/tensorrtlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ namespace dd

std::vector<float> _floatOut;
std::vector<int> _keepCount;

std::mutex _net_mutex; /**< mutex around net, e.g. no concurrent predict calls as net is not re-instantiated. Use batches instead. */
};

}
Expand Down

0 comments on commit 61ce53a

Please sign in to comment.