@@ -112,6 +112,10 @@ InferContext::SendRequest(
112
112
}
113
113
114
114
thread_stat_->num_sent_requests_ ++;
115
+
116
+ // Parse the request inputs to save in the profile export file
117
+ RequestRecord::RequestInput request_inputs{GetInputs ()};
118
+
115
119
if (async_) {
116
120
uint64_t unique_request_id{(thread_id_ << 48 ) | ((request_id << 16 ) >> 16 )};
117
121
infer_data_.options_ ->request_id_ = std::to_string (unique_request_id);
@@ -120,6 +124,7 @@ InferContext::SendRequest(
120
124
auto it = async_req_map_
121
125
.emplace (infer_data_.options_ ->request_id_ , RequestRecord ())
122
126
.first ;
127
+ it->second .request_inputs_ = {request_inputs};
123
128
it->second .start_time_ = std::chrono::system_clock::now ();
124
129
it->second .sequence_end_ = infer_data_.options_ ->sequence_end_ ;
125
130
it->second .delayed_ = delayed;
@@ -149,10 +154,10 @@ InferContext::SendRequest(
149
154
&results, *(infer_data_.options_ ), infer_data_.valid_inputs_ ,
150
155
infer_data_.outputs_ );
151
156
thread_stat_->idle_timer .Stop ();
152
- RequestRecord::ResponseOutput response_output {};
157
+ RequestRecord::ResponseOutput response_outputs {};
153
158
if (results != nullptr ) {
154
159
if (thread_stat_->status_ .IsOk ()) {
155
- response_output = GetOutput (*results);
160
+ response_outputs = GetOutputs (*results);
156
161
thread_stat_->status_ = ValidateOutputs (results);
157
162
}
158
163
delete results;
@@ -169,8 +174,9 @@ InferContext::SendRequest(
169
174
std::lock_guard<std::mutex> lock (thread_stat_->mu_ );
170
175
auto total = end_time_sync - start_time_sync;
171
176
thread_stat_->request_records_ .emplace_back (RequestRecord (
172
- start_time_sync, std::move (end_time_syncs), {response_output},
173
- infer_data_.options_ ->sequence_end_ , delayed, sequence_id, false ));
177
+ start_time_sync, std::move (end_time_syncs), {request_inputs},
178
+ {response_outputs}, infer_data_.options_ ->sequence_end_ , delayed,
179
+ sequence_id, false ));
174
180
thread_stat_->status_ =
175
181
infer_backend_->ClientInferStat (&(thread_stat_->contexts_stat_ [id_]));
176
182
if (!thread_stat_->status_ .IsOk ()) {
@@ -180,15 +186,36 @@ InferContext::SendRequest(
180
186
}
181
187
}
182
188
189
+ const RequestRecord::RequestInput
190
+ InferContext::GetInputs ()
191
+ {
192
+ RequestRecord::RequestInput input{};
193
+ for (const auto & request_input : infer_data_.valid_inputs_ ) {
194
+ const uint8_t * buf{nullptr };
195
+ size_t byte_size{0 };
196
+ std::string data_type{request_input->Datatype ()};
197
+ request_input->RawData (&buf, &byte_size);
198
+
199
+ // The first 4 bytes of BYTES data is a 32-bit integer to indicate the size
200
+ // of the rest of the data (which we already know based on byte_size). It
201
+ // should be ignored here, as it isn't part of the actual request
202
+ if (data_type == " BYTES" && byte_size >= 4 ) {
203
+ buf += 4 ;
204
+ byte_size -= 4 ;
205
+ }
206
+ input.emplace (request_input->Name (), RecordData (buf, byte_size, data_type));
207
+ }
208
+ return input;
209
+ }
210
+
183
211
const RequestRecord::ResponseOutput
184
- InferContext::GetOutput (const cb::InferResult& infer_result)
212
+ InferContext::GetOutputs (const cb::InferResult& infer_result)
185
213
{
186
214
RequestRecord::ResponseOutput output{};
187
215
for (const auto & requested_output : infer_data_.outputs_ ) {
188
216
const uint8_t * buf{nullptr };
189
217
size_t byte_size{0 };
190
218
infer_result.RawData (requested_output->Name (), &buf, &byte_size);
191
-
192
219
// The first 4 bytes of BYTES data is a 32-bit integer to indicate the size
193
220
// of the rest of the data (which we already know based on byte_size). It
194
221
// should be ignored here, as it isn't part of the actual response
@@ -282,7 +309,7 @@ InferContext::AsyncCallbackFuncImpl(cb::InferResult* result)
282
309
}
283
310
it->second .response_timestamps_ .push_back (
284
311
std::chrono::system_clock::now ());
285
- it->second .response_outputs_ .push_back (GetOutput (*result));
312
+ it->second .response_outputs_ .push_back (GetOutputs (*result));
286
313
num_responses_++;
287
314
if (is_null_response == true ) {
288
315
it->second .has_null_last_response_ = true ;
@@ -296,9 +323,9 @@ InferContext::AsyncCallbackFuncImpl(cb::InferResult* result)
296
323
has_received_final_response_ = is_final_response;
297
324
thread_stat_->request_records_ .emplace_back (
298
325
it->second .start_time_ , it->second .response_timestamps_ ,
299
- it->second .response_outputs_ , it->second .sequence_end_ ,
300
- it->second .delayed_ , it->second .sequence_id_ ,
301
- it->second .has_null_last_response_ );
326
+ it->second .request_inputs_ , it->second .response_outputs_ ,
327
+ it->second .sequence_end_ , it->second .delayed_ ,
328
+ it->second .sequence_id_ , it-> second . has_null_last_response_ );
302
329
infer_backend_->ClientInferStat (&(thread_stat_->contexts_stat_ [id_]));
303
330
thread_stat_->cb_status_ = ValidateOutputs (result);
304
331
async_req_map_.erase (request_id);
0 commit comments