10 #include "larrecodnn/ImagePatternAlgs/ToolInterfaces/IPointIdAlg.h" 23 std::vector<float>
Run(
std::vector<std::vector<float>>
const& inp2d)
const override;
25 int samples = -1)
const override;
40 :
img::DataProviderAlg(table())
43 fNNetOutputs = table().NNetOutputs();
44 fPatchSizeW = table().PatchSizeW();
45 fPatchSizeD = table().PatchSizeD();
46 fCurrentWireIdx = 99999;
47 fCurrentScaledDrift = 99999;
64 TritonPset.
put(
"outputs",
"[]");
67 triton_client = std::make_unique<lartriton::TritonClient>(TritonPset);
74 mf::LogInfo(
"PointIdAlgSonicTriton") <<
"tensorRT inference context created.";
82 size_t nrows = inp2d.size();
89 auto data1 = std::make_shared<lartriton::TritonInput<float>>();
93 auto&
img = data1->emplace_back();
95 for (
size_t ir = 0; ir < nrows; ++ir) {
96 img.insert(
img.end(), inp2d[ir].begin(), inp2d[ir].end());
99 triton_input.toServer(data1);
105 const auto& triton_output0 =
triton_client->output().at(
"em_trk_none_netout/Softmax");
106 const auto& prob0 = triton_output0.fromServer<
float>();
107 auto ncat0 = triton_output0.sizeDims();
109 const auto& triton_output1 =
triton_client->output().at(
"michel_netout/Sigmoid");
110 const auto& prob1 = triton_output1.fromServer<
float>();
111 auto ncat1 = triton_output1.sizeDims();
113 std::vector<float> out;
114 out.reserve(ncat0 + ncat1);
115 out.insert(out.end(), prob0[0].begin(), prob0[0].end());
116 out.insert(out.end(), prob1[0].begin(), prob1[0].end());
128 if ((samples == 0) || inps.empty() || inps.front().empty() || inps.front().front().empty()) {
129 return std::vector<std::vector<float>>();
132 if ((samples == -1) || (samples > (
long long int)inps.size())) { samples = inps.size(); }
134 size_t usamples = samples;
135 size_t nrows = inps.front().size();
142 auto data1 = std::make_shared<lartriton::TritonInput<float>>();
143 data1->reserve(usamples);
146 for (
size_t idx = 0; idx < usamples; ++idx) {
147 auto&
img = data1->emplace_back();
149 for (
size_t ir = 0; ir < nrows; ++ir) {
150 img.insert(
img.end(), inps[idx][ir].begin(), inps[idx][ir].end());
153 triton_input.toServer(data1);
159 const auto& triton_output0 =
triton_client->output().at(
"em_trk_none_netout/Softmax");
160 const auto& prob0 = triton_output0.fromServer<
float>();
161 auto ncat0 = triton_output0.sizeDims();
163 const auto& triton_output1 =
triton_client->output().at(
"michel_netout/Sigmoid");
164 const auto& prob1 = triton_output1.fromServer<
float>();
165 auto ncat1 = triton_output1.sizeDims();
167 std::vector<std::vector<float>> out;
168 out.reserve(usamples);
169 for (
unsigned i = 0; i < usamples; i++) {
171 auto&
img = out.back();
172 img.reserve(ncat0 + ncat1);
173 img.insert(
img.end(), prob0[i].begin(), prob0[i].end());
174 img.insert(
img.end(), prob1[i].begin(), prob1[i].end());
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
void put(std::string const &key)