@@ -112,6 +112,10 @@ InferContext::SendRequest(
112112 }
113113
114114 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+
115119 if (async_) {
116120 uint64_t unique_request_id{(thread_id_ << 48 ) | ((request_id << 16 ) >> 16 )};
117121 infer_data_.options_ ->request_id_ = std::to_string (unique_request_id);
@@ -120,6 +124,7 @@ InferContext::SendRequest(
120124 auto it = async_req_map_
121125 .emplace (infer_data_.options_ ->request_id_ , RequestRecord ())
122126 .first ;
127+ it->second .request_inputs_ = {request_inputs};
123128 it->second .start_time_ = std::chrono::system_clock::now ();
124129 it->second .sequence_end_ = infer_data_.options_ ->sequence_end_ ;
125130 it->second .delayed_ = delayed;
@@ -149,10 +154,10 @@ InferContext::SendRequest(
149154 &results, *(infer_data_.options_ ), infer_data_.valid_inputs_ ,
150155 infer_data_.outputs_ );
151156 thread_stat_->idle_timer .Stop ();
152- RequestRecord::ResponseOutput response_output {};
157+ RequestRecord::ResponseOutput response_outputs {};
153158 if (results != nullptr ) {
154159 if (thread_stat_->status_ .IsOk ()) {
155- response_output = GetOutput (*results);
160+ response_outputs = GetOutputs (*results);
156161 thread_stat_->status_ = ValidateOutputs (results);
157162 }
158163 delete results;
@@ -169,8 +174,9 @@ InferContext::SendRequest(
169174 std::lock_guard<std::mutex> lock (thread_stat_->mu_ );
170175 auto total = end_time_sync - start_time_sync;
171176 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 ));
174180 thread_stat_->status_ =
175181 infer_backend_->ClientInferStat (&(thread_stat_->contexts_stat_ [id_]));
176182 if (!thread_stat_->status_ .IsOk ()) {
@@ -180,15 +186,36 @@ InferContext::SendRequest(
180186 }
181187}
182188
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+
183211const RequestRecord::ResponseOutput
184- InferContext::GetOutput (const cb::InferResult& infer_result)
212+ InferContext::GetOutputs (const cb::InferResult& infer_result)
185213{
186214 RequestRecord::ResponseOutput output{};
187215 for (const auto & requested_output : infer_data_.outputs_ ) {
188216 const uint8_t * buf{nullptr };
189217 size_t byte_size{0 };
190218 infer_result.RawData (requested_output->Name (), &buf, &byte_size);
191-
192219 // The first 4 bytes of BYTES data is a 32-bit integer to indicate the size
193220 // of the rest of the data (which we already know based on byte_size). It
194221 // should be ignored here, as it isn't part of the actual response
@@ -282,7 +309,7 @@ InferContext::AsyncCallbackFuncImpl(cb::InferResult* result)
282309 }
283310 it->second .response_timestamps_ .push_back (
284311 std::chrono::system_clock::now ());
285- it->second .response_outputs_ .push_back (GetOutput (*result));
312+ it->second .response_outputs_ .push_back (GetOutputs (*result));
286313 num_responses_++;
287314 if (is_null_response == true ) {
288315 it->second .has_null_last_response_ = true ;
@@ -296,9 +323,9 @@ InferContext::AsyncCallbackFuncImpl(cb::InferResult* result)
296323 has_received_final_response_ = is_final_response;
297324 thread_stat_->request_records_ .emplace_back (
298325 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_ );
302329 infer_backend_->ClientInferStat (&(thread_stat_->contexts_stat_ [id_]));
303330 thread_stat_->cb_status_ = ValidateOutputs (result);
304331 async_req_map_.erase (request_id);
0 commit comments