LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TritonClient.h
Go to the documentation of this file.
1 #ifndef NuSonic_Triton_TritonClient
2 #define NuSonic_Triton_TritonClient
3 
5 
6 namespace fhicl {
7  class ParameterSet;
8 }
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include "grpc_client.h"
15 
16 namespace nic = triton::client;
17 
18 namespace lartriton {
19 
20  class TritonClient {
21  public:
22  struct ServerSideStats {
23  uint64_t inference_count_;
24  uint64_t execution_count_;
25  uint64_t success_count_;
26  uint64_t cumm_time_ns_;
27  uint64_t queue_time_ns_;
31  };
32 
33  //constructor
34  TritonClient(const fhicl::ParameterSet& params);
35 
36  //accessors
37  TritonInputMap& input() { return input_; }
38  const TritonOutputMap& output() const { return output_; }
39  unsigned batchSize() const { return batchSize_; }
40  bool verbose() const { return verbose_; }
41  bool setBatchSize(unsigned bsize);
42 
43  //main operation
44  void dispatch()
45  {
46  start();
47  evaluate();
48  }
49 
50  //helper
51  void reset();
52 
53  protected:
54  //helper
55  bool getResults(std::shared_ptr<nic::InferResult> results);
56 
57  void start();
58  void evaluate();
59  void finish(bool success);
60 
61  void reportServerSideStats(const ServerSideStats& stats) const;
62  ServerSideStats summarizeServerStats(const inference::ModelStatistics& start_status,
63  const inference::ModelStatistics& end_status) const;
64 
65  inference::ModelStatistics getServerSideStatus() const;
66 
67  //members
70  unsigned allowedTries_, tries_;
71  std::string serverURL_;
72  unsigned maxBatchSize_;
73  unsigned batchSize_;
74  bool noBatch_;
75  bool verbose_;
76 
77  //IO pointers for triton
78  std::vector<nic::InferInput*> inputsTriton_;
79  std::vector<const nic::InferRequestedOutput*> outputsTriton_;
80 
81  std::unique_ptr<nic::InferenceServerGrpcClient> client_;
82  //stores timeout, model name and version
83  nic::InferOptions options_;
84  };
85 
86 }
87 #endif
nic::InferOptions options_
Definition: TritonClient.h:83
std::unordered_map< std::string, TritonOutputData > TritonOutputMap
Definition: TritonData.h:106
const TritonOutputMap & output() const
Definition: TritonClient.h:38
TritonInputMap & input()
Definition: TritonClient.h:37
std::vector< const nic::InferRequestedOutput * > outputsTriton_
Definition: TritonClient.h:79
TritonOutputMap output_
Definition: TritonClient.h:69
std::unique_ptr< nic::InferenceServerGrpcClient > client_
Definition: TritonClient.h:81
parameter set interface
unsigned batchSize() const
Definition: TritonClient.h:39
TritonInputMap input_
Definition: TritonClient.h:68
bool verbose() const
Definition: TritonClient.h:40
std::vector< nic::InferInput * > inputsTriton_
Definition: TritonClient.h:78
std::unordered_map< std::string, TritonInputData > TritonInputMap
Definition: TritonData.h:104