16 std::vector<float>
Run(
std::vector<std::vector<float>>
const& inp2d)
const override;
18 int samples = -1)
const override;
57 TritonPset.
put(
"outputs",
"[]");
60 triton_client = std::make_unique<lartriton::TritonClient>(TritonPset);
67 mf::LogInfo(
"PointIdAlgSonicTriton") <<
"tensorRT inference context created.";
76 size_t nrows = inp2d.size();
83 auto data1 = std::make_shared<lartriton::TritonInput<float>>();
87 auto&
img = data1->emplace_back();
89 for (
size_t ir = 0; ir <
nrows; ++ir) {
90 img.insert(
img.end(), inp2d[ir].begin(), inp2d[ir].end());
93 triton_input.toServer(data1);
99 const auto& triton_output0 =
triton_client->output().at(
"em_trk_none_netout/Softmax");
100 const auto& prob0 = triton_output0.fromServer<
float>();
101 auto ncat0 = triton_output0.sizeDims();
103 const auto& triton_output1 =
triton_client->output().at(
"michel_netout/Sigmoid");
104 const auto& prob1 = triton_output1.fromServer<
float>();
105 auto ncat1 = triton_output1.sizeDims();
107 std::vector<float> out;
108 out.reserve(ncat0+ncat1);
109 out.insert(out.end(), prob0[0].begin(), prob0[0].end());
110 out.insert(out.end(), prob1[0].begin(), prob1[0].end());
118 std::vector<std::vector<float>>
121 if ((samples == 0) || inps.empty() || inps.front().empty() || inps.front().front().empty()) {
122 return std::vector<std::vector<float>>();
125 if ((samples == -1) || (samples > (
long long int)inps.size())) { samples = inps.size(); }
127 size_t usamples = samples;
128 size_t nrows = inps.front().size();
135 auto data1 = std::make_shared<lartriton::TritonInput<float>>();
136 data1->reserve(usamples);
139 for (
size_t idx = 0; idx < usamples; ++idx) {
140 auto&
img = data1->emplace_back();
142 for (
size_t ir = 0; ir <
nrows; ++ir) {
143 img.insert(
img.end(), inps[idx][ir].begin(), inps[idx][ir].end());
146 triton_input.toServer(data1);
152 const auto& triton_output0 =
triton_client->output().at(
"em_trk_none_netout/Softmax");
153 const auto& prob0 = triton_output0.fromServer<
float>();
154 auto ncat0 = triton_output0.sizeDims();
156 const auto& triton_output1 =
triton_client->output().at(
"michel_netout/Sigmoid");
157 const auto& prob1 = triton_output1.fromServer<
float>();
158 auto ncat1 = triton_output1.sizeDims();
160 std::vector<std::vector<float>> out;
161 out.reserve(usamples);
162 for(
unsigned i = 0; i < usamples; i++) {
164 auto&
img = out.back();
165 img.reserve(ncat0+ncat1);
166 img.insert(
img.end(), prob0[i].begin(), prob0[i].end());
167 img.insert(
img.end(), prob1[i].begin(), prob1[i].end());
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
DataProviderAlg(const fhicl::ParameterSet &pset)
unsigned nrows(sqlite3 *db, std::string const &tablename)
void put(std::string const &key)