Skip to content

Commit 51f1cf6

Browse files
yimingz-atensorflow-copybara
authored andcommitted
Add more tracer
PiperOrigin-RevId: 716347614
1 parent ebb71bf commit 51f1cf6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tensorflow_serving/servables/tensorflow/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,7 @@ cc_library(
11811181
"@org_tensorflow//tensorflow/cc/saved_model:util",
11821182
"@org_tensorflow//tensorflow/core:lib",
11831183
"@org_tensorflow//tensorflow/core:protos_all_cc",
1184+
"@org_tensorflow//tensorflow/core/platform:tracing",
11841185
"@org_tensorflow//tensorflow/core/tfrt/runtime:tf_threadpool_concurrent_work_queue",
11851186
"@org_tensorflow//tensorflow/core/tfrt/saved_model:saved_model_cpu",
11861187
],

tensorflow_serving/servables/tensorflow/tfrt_predict_util.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ limitations under the License.
2929
#include "tensorflow/core/framework/tensor.pb.h"
3030
#include "tensorflow/core/lib/core/errors.h"
3131
#include "tensorflow/core/platform/errors.h"
32+
#include "tensorflow/core/platform/tracing.h" // NOLINT
3233
#include "tensorflow/core/protobuf/error_codes.pb.h"
3334
#include "tensorflow/core/protobuf/named_tensor.pb.h"
3435
#include "tensorflow/core/tfrt/runtime/tf_threadpool_concurrent_work_queue.h"
@@ -190,12 +191,14 @@ absl::Status RunPredict(
190191
}
191192

192193
if (IsOutputFilterEmptyOrFullSet(request, function_metadata.value())) {
194+
TRACELITERAL("Pre process prediction without output filter");
193195
// Pre-processing.
194196
std::vector<Tensor> input_tensors;
195197
TF_RETURN_IF_ERROR(PreProcessPredictionWithoutOutputFilter(
196198
function_metadata.value(), request, &input_tensors));
197199

198200
// Executes requests.
201+
TRACELITERAL("Execute prediction without output filter");
199202
std::vector<Tensor> outputs;
200203
const uint64_t start_microseconds = EnvTime::NowMicros();
201204
if (const auto status =
@@ -213,6 +216,7 @@ absl::Status RunPredict(
213216
end_microseconds - start_microseconds);
214217

215218
// Post-processing.
219+
TRACELITERAL("Post process prediction without output filter");
216220
return PostProcessPredictionResultWithoutOutputFilter(
217221
function_metadata->GetOutputNames(), outputs, option, request,
218222
response);
@@ -229,13 +233,15 @@ absl::Status RunPredict(
229233
}
230234
const SignatureDef& signature = iter->second;
231235

236+
TRACELITERAL("Pre process prediction with output filter");
232237
std::vector<std::pair<string, Tensor>> input_tensors;
233238
std::vector<string> output_tensor_names;
234239
std::vector<string> output_tensor_aliases;
235240
TF_RETURN_IF_ERROR(PreProcessPrediction(signature, request, &input_tensors,
236241
&output_tensor_names,
237242
&output_tensor_aliases));
238243

244+
TRACELITERAL("Execute prediction with output filter");
239245
const uint64_t start_microseconds = EnvTime::NowMicros();
240246
std::vector<Tensor> outputs;
241247
if (const auto status = saved_model->RunByTensorNames(
@@ -253,6 +259,7 @@ absl::Status RunPredict(
253259
/*runtime=*/"TFRT",
254260
end_microseconds - start_microseconds);
255261

262+
TRACELITERAL("Post process prediction with output filter");
256263
return PostProcessPredictionResult(output_tensor_aliases, outputs, option,
257264
response);
258265
}

0 commit comments

Comments
 (0)