5 #include "model_config.pb.h"
14 namespace inferenceserver {
24 template <
typename IO>
27 dims_(model_info.shape().begin(), model_info.shape().
end()),
31 shape_(fullShape_.begin() + (noBatch_ ? 0 : 1), fullShape_.
end()),
32 variableDims_(anyNeg(shape_)),
33 productDims_(variableDims_ ? -1 : dimProduct(shape_)),
34 dname_(model_info.datatype()),
50 nic::InferRequestedOutput::Create(ioptr,
name_);
54 template <
typename IO>
57 for (
unsigned i = 0;
i < newShape.size(); ++
i) {
58 result &= setShape(
i, newShape[
i], canThrow);
63 template <
typename IO>
65 std::stringstream
msg;
66 unsigned full_loc = loc + (noBatch_ ? 0 : 1);
69 if (full_loc >= fullShape_.size()) {
70 msg << name_ <<
" setShape(): dimension " << full_loc <<
" out of bounds (" << fullShape_.size() <<
")";
79 if (
val != fullShape_[full_loc]) {
80 if (dims_[full_loc] == -1) {
81 fullShape_[full_loc] =
val;
84 msg << name_ <<
" setShape(): attempt to change value of non-variable shape dimension " << loc;
97 template <
typename IO>
101 fullShape_[0] = batchSize_;
106 template <
typename DT>
108 const auto& data_in = *ptr;
112 throw cms::Exception(
"TritonDataError") <<
name_ <<
" input(): input vector has size " << data_in.size()
113 <<
" but specified batch size is " <<
batchSize_;
120 throw cms::Exception(
"TritonDataError") <<
name_ <<
" input(): inconsistent byte size " <<
sizeof(
DT)
124 for (
unsigned i0 = 0; i0 <
batchSize_; ++i0) {
125 const DT* arr = data_in[i0].data();
127 name_ +
" input(): unable to set data for batch entry " + std::to_string(i0));
135 template <
typename DT>
142 throw cms::Exception(
"TritonDataError") <<
name_ <<
" output(): inconsistent byte size " <<
sizeof(
DT)
149 size_t contentByteSize;
152 if (contentByteSize != expectedContentByteSize) {
153 throw cms::Exception(
"TritonDataError") <<
name_ <<
" output(): unexpected content byte size " << contentByteSize
154 <<
" (expected " << expectedContentByteSize <<
")";
157 const DT*
r1 = reinterpret_cast<const DT*>(r0);
159 for (
unsigned i0 = 0; i0 <
batchSize_; ++i0) {
160 auto offset = i0 * nOutput;