@@ -84,6 +84,7 @@ InferResponseComplete(
84
84
std::unique_ptr<InferResponse> infer_response;
85
85
std::vector<std::shared_ptr<PbTensor>> output_tensors;
86
86
std::shared_ptr<PbError> pb_error;
87
+ std::string parameters_string;
87
88
88
89
if (response != nullptr ) {
89
90
try {
@@ -153,21 +154,64 @@ InferResponseComplete(
153
154
output_tensors.clear ();
154
155
}
155
156
156
- // TODO: [DLIS-7864] Pass response parameters from BLS response.
157
+ try {
158
+ triton::common::TritonJson::Value parameters_json (
159
+ triton::common::TritonJson::ValueType::OBJECT);
160
+ uint32_t parameter_count;
161
+ THROW_IF_TRITON_ERROR (
162
+ TRITONSERVER_InferenceResponseParameterCount (response, ¶meter_count));
163
+ for (size_t i = 0 ; i < parameter_count; i++) {
164
+ const char * name;
165
+ TRITONSERVER_ParameterType type;
166
+ const void * vvalue;
167
+ THROW_IF_TRITON_ERROR (
168
+ TRITONSERVER_InferenceResponseParameter (response, i, &name, &type, &vvalue));
169
+ if (type == TRITONSERVER_PARAMETER_INT) {
170
+ THROW_IF_TRITON_ERROR (parameters_json.AddInt (
171
+ name, *(reinterpret_cast <const int64_t *>(vvalue))));
172
+ } else if (type == TRITONSERVER_PARAMETER_BOOL) {
173
+ THROW_IF_TRITON_ERROR (parameters_json.AddBool (
174
+ name, *(reinterpret_cast <const bool *>(vvalue))));
175
+ } else if (type == TRITONSERVER_PARAMETER_STRING) {
176
+ std::string string = reinterpret_cast <const char *>(vvalue);
177
+ THROW_IF_TRITON_ERROR (parameters_json.AddString (name, string));
178
+ } else if (type == TRITONSERVER_PARAMETER_DOUBLE) {
179
+ THROW_IF_TRITON_ERROR (parameters_json.AddDouble (
180
+ name, *(reinterpret_cast <const double *>(vvalue))));
181
+ } else {
182
+ throw PythonBackendException ((std::string (" Unsupported parameter type for parameter '" ) + name + " '." ))
183
+ }
184
+ }
185
+
186
+ triton::common::TritonJson::WriteBuffer buffer;
187
+ THROW_IF_TRITON_ERROR (parameters_json.Write (&buffer));
188
+ parameters_string = buffer.Contents ();
189
+ }
190
+ catch (const PythonBackendException& pb_exception) {
191
+ if (response != nullptr ) {
192
+ LOG_IF_ERROR (
193
+ TRITONSERVER_InferenceResponseDelete (response),
194
+ " Failed to delete inference response." );
195
+
196
+ response = nullptr ;
197
+ }
198
+ pb_error = std::make_shared<PbError>(pb_exception.what ());
199
+ }
200
+
157
201
if (!infer_payload->IsDecoupled ()) {
158
202
infer_response = std::make_unique<InferResponse>(
159
- output_tensors, pb_error, " " /* parameters */ ,
203
+ output_tensors, pb_error, parameters_string ,
160
204
true /* is_last_response */ );
161
205
} else {
162
206
if ((flags & TRITONSERVER_RESPONSE_COMPLETE_FINAL) == 0 ) {
163
207
// Not the last response.
164
208
infer_response = std::make_unique<InferResponse>(
165
- output_tensors, pb_error, " " /* parameters */ ,
209
+ output_tensors, pb_error, parameters_string ,
166
210
false /* is_last_response */ , userp /* id */ );
167
211
} else {
168
212
// The last response.
169
213
infer_response = std::make_unique<InferResponse>(
170
- output_tensors, pb_error, " " /* parameters */ ,
214
+ output_tensors, pb_error, parameters_string ,
171
215
true /* is_last_response */ , userp /* id */ );
172
216
}
173
217
}
0 commit comments