10 #include "grpc_client.h" 13 namespace nic = nvidia::inferenceserver::client;
21 std::vector<float>
Run(
std::vector<std::vector<float>>
const& inp2d)
const override;
23 int samples = -1)
const override;
61 <<
"error: unable to create client for inference: " <<
err <<
std::endl;
68 <<
"error: failed to get model metadata: " <<
err <<
std::endl;
73 <<
"error: failed to get model config: " <<
err <<
std::endl;
91 mf::LogInfo(
"PointIdAlgTriton") <<
"tensorRT inference context created.";
100 size_t nrows = inp2d.size(), ncols = inp2d.front().size();
106 nic::InferInput* triton_input;
107 auto err = nic::InferInput::Create(
113 std::shared_ptr<nic::InferInput> triton_input_ptr(triton_input);
114 std::vector<nic::InferInput*> triton_inputs = {triton_input_ptr.get()};
118 err = triton_input_ptr->Reset();
121 <<
"failed resetting Triton model input: " <<
err <<
std::endl;
124 size_t sbuff_byte_size = (nrows * ncols) *
sizeof(
float);
125 std::vector<float> fa(sbuff_byte_size);
128 for (
size_t ir = 0; ir <
nrows; ++ir) {
131 err = triton_input_ptr->AppendRaw(reinterpret_cast<uint8_t*>(fa.data()), sbuff_byte_size);
138 nic::InferResult* results;
143 <<
"failed sending Triton synchronous infer request: " <<
err <<
std::endl;
145 std::shared_ptr<nic::InferResult> results_ptr;
146 results_ptr.
reset(results);
150 std::vector<float> out;
153 size_t rbuff0_byte_size;
154 results_ptr->RawData(
triton_modmet.outputs(0).name(), (
const uint8_t**)&prb0, &rbuff0_byte_size);
155 size_t ncat0 = rbuff0_byte_size/
sizeof(
float);
158 size_t rbuff1_byte_size;
159 results_ptr->RawData(
triton_modmet.outputs(1).name(), (
const uint8_t**)&prb1, &rbuff1_byte_size);
160 size_t ncat1 = rbuff1_byte_size/
sizeof(
float);
162 for(
unsigned j = 0; j < ncat0; j++) out.push_back(*(prb0 + j ));
163 for(
unsigned j = 0; j < ncat1; j++) out.push_back(*(prb1 + j ));
169 std::vector<std::vector<float>>
172 if ((samples == 0) || inps.empty() || inps.front().empty() || inps.front().front().empty()) {
173 return std::vector<std::vector<float>>();
176 if ((samples == -1) || (samples > (
long long int)inps.size())) { samples = inps.size(); }
178 size_t usamples = samples;
179 size_t nrows = inps.front().size(), ncols = inps.front().front().size();
185 nic::InferInput* triton_input;
186 auto err = nic::InferInput::Create(
192 std::shared_ptr<nic::InferInput> triton_input_ptr(triton_input);
193 std::vector<nic::InferInput*> triton_inputs = {triton_input_ptr.get()};
196 err = triton_input_ptr->Reset();
199 <<
"failed resetting Triton model input: " <<
err <<
std::endl;
202 size_t sbuff_byte_size = (nrows * ncols) *
sizeof(
float);
203 std::vector<std::vector<float>> fa(usamples, std::vector<float>(sbuff_byte_size));
205 for (
size_t idx = 0; idx < usamples; ++idx) {
207 for (
size_t ir = 0; ir <
nrows; ++ir) {
210 err = triton_input_ptr->AppendRaw(reinterpret_cast<uint8_t*>(fa[idx].
data()), sbuff_byte_size);
219 nic::InferResult* results;
224 <<
"failed sending Triton synchronous infer request: " <<
err <<
std::endl;
226 std::shared_ptr<nic::InferResult> results_ptr;
227 results_ptr.
reset(results);
231 std::vector<std::vector<float>> out;
234 size_t rbuff0_byte_size;
235 results_ptr->RawData(
triton_modmet.outputs(0).name(), (
const uint8_t**)&prb0, &rbuff0_byte_size);
236 size_t ncat0 = rbuff0_byte_size/(usamples*
sizeof(
float));
239 size_t rbuff1_byte_size;
240 results_ptr->RawData(
triton_modmet.outputs(1).name(), (
const uint8_t**)&prb1, &rbuff1_byte_size);
241 size_t ncat1 = rbuff1_byte_size/(usamples*
sizeof(
float));
243 for(
unsigned i = 0; i < usamples; i++) {
244 std::vector<float> vprb;
245 for(
unsigned j = 0; j < ncat0; j++) vprb.push_back(*(prb0 + i*ncat0 + j ));
246 for(
unsigned j = 0; j < ncat1; j++) vprb.push_back(*(prb1 + i*ncat1 + j ));
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
DataProviderAlg(const fhicl::ParameterSet &pset)
void err(const char *fmt,...)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
unsigned nrows(sqlite3 *db, std::string const &tablename)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)