Add more details to the invoke call trace.

It is always useful information to know if the TPU invoke is Async or not, and if the GPU invoke on the old path or new path.
This can make it obvious in the perfetto trace.

PiperOrigin-RevId: 517162515
This commit is contained in:
MediaPipe Team 2023-03-16 10:35:07 -07:00 committed by Copybara-Service
parent 3b66ac0623
commit a9e956baa1
4 changed files with 16 additions and 2 deletions

View File

@ -141,7 +141,7 @@ InferenceCalculatorGlAdvancedImpl::GpuInferenceRunner::Process(
} }
// Run inference. // Run inference.
{ {
MEDIAPIPE_PROFILING(GPU_TASK_INVOKE, cc); MEDIAPIPE_PROFILING(GPU_TASK_INVOKE_ADVANCED, cc);
return tflite_gpu_runner_->Invoke(); return tflite_gpu_runner_->Invoke();
} }
})); }));

View File

@ -136,6 +136,8 @@ message GraphTrace {
GPU_TASK_INVOKE = 16; GPU_TASK_INVOKE = 16;
TPU_TASK_INVOKE = 17; TPU_TASK_INVOKE = 17;
CPU_TASK_INVOKE = 18; CPU_TASK_INVOKE = 18;
GPU_TASK_INVOKE_ADVANCED = 19;
TPU_TASK_INVOKE_ASYNC = 20;
} }
// The timing for one packet set being processed at one caclulator node. // The timing for one packet set being processed at one caclulator node.

View File

@ -112,6 +112,10 @@ struct TraceEvent {
static constexpr EventType GPU_TASK_INVOKE = GraphTrace::GPU_TASK_INVOKE; static constexpr EventType GPU_TASK_INVOKE = GraphTrace::GPU_TASK_INVOKE;
static constexpr EventType TPU_TASK_INVOKE = GraphTrace::TPU_TASK_INVOKE; static constexpr EventType TPU_TASK_INVOKE = GraphTrace::TPU_TASK_INVOKE;
static constexpr EventType CPU_TASK_INVOKE = GraphTrace::CPU_TASK_INVOKE; static constexpr EventType CPU_TASK_INVOKE = GraphTrace::CPU_TASK_INVOKE;
static constexpr EventType GPU_TASK_INVOKE_ADVANCED =
GraphTrace::GPU_TASK_INVOKE_ADVANCED;
static constexpr EventType TPU_TASK_INVOKE_ASYNC =
GraphTrace::TPU_TASK_INVOKE_ASYNC;
}; };
// Packet trace log buffer. // Packet trace log buffer.

View File

@ -57,7 +57,6 @@ struct hash<mediapipe::TaskId> {
namespace mediapipe { namespace mediapipe {
namespace { namespace {
void BasicTraceEventTypes(TraceEventRegistry* result) { void BasicTraceEventTypes(TraceEventRegistry* result) {
// The initializer arguments below are: event_type, description, // The initializer arguments below are: event_type, description,
// is_packet_event, is_stream_event, id_event_data. // is_packet_event, is_stream_event, id_event_data.
@ -84,6 +83,15 @@ void BasicTraceEventTypes(TraceEventRegistry* result) {
"A time measured by GPU clock and by CPU clock.", true, false}, "A time measured by GPU clock and by CPU clock.", true, false},
{TraceEvent::PACKET_QUEUED, "An input queue size when a packet arrives.", {TraceEvent::PACKET_QUEUED, "An input queue size when a packet arrives.",
true, true, false}, true, true, false},
{TraceEvent::GPU_TASK_INVOKE, "CPU timing for initiating a GPU task."},
{TraceEvent::TPU_TASK_INVOKE, "CPU timing for initiating a TPU task."},
{TraceEvent::CPU_TASK_INVOKE, "CPU timing for initiating a CPU task."},
{TraceEvent::GPU_TASK_INVOKE_ADVANCED,
"CPU timing for initiating a GPU task bypassing the TFLite "
"interpreter."},
{TraceEvent::TPU_TASK_INVOKE_ASYNC,
"CPU timing for async initiation of a TPU task."},
}; };
for (const TraceEventType& t : basic_types) { for (const TraceEventType& t : basic_types) {
(*result)[t.event_type()] = t; (*result)[t.event_type()] = t;