Skip to content

Commit

Permalink
Add trace events interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jackm321 committed Mar 14, 2019
1 parent 398135c commit dcabd8d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
8 changes: 7 additions & 1 deletion foxi/onnxifi_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI onnxSetIOAndRunGraph(
const onnxTensorDescriptorV1* inputDescriptors,
uint32_t outputsCount,
const onnxTensorDescriptorV1* outputDescriptors,
onnxMemoryFenceV1* outputFence) {
onnxMemoryFenceV1* outputFence,
onnxTraceEventList* traceEvents) {
return ONNXIFI_STATUS_SUCCESS;
}

ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI
onnxReleaseTraceEvents(onnxTraceEventList* traceEvents) {
return ONNXIFI_STATUS_SUCCESS;
}
65 changes: 64 additions & 1 deletion foxi/onnxifi_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,45 @@
extern "C" {
#endif

typedef struct onnxTraceEvent {
/**
* Human readable name for the event, will be used to match up begin and end
* of an event duration.
*/
const char *eventName;

/**
* Type of the event, can be one of the following:
* 'B': Beginning of event
* 'E': End of event
*/
char eventType;

/**
* Time of the event, in milliseconds since epoch.
*/
uint64_t timestamp;

/**
* Thread Id for this event. All events with the same tid will be grouped
* together in the trace.
*/
uint32_t tid;
} onnxTraceEvent;

typedef struct onnxTraceEventList {
/**
* The number of events in traceEvents.
*/
int32_t numEvents;

/**
* A list of of onnxTraceEvents, the length of which is indicated by
* numEvents.
*/
onnxTraceEvent *traceEvents;
} onnxTraceEventList;

/**
* Generic ONNXIFI extension function pointer.
*
Expand Down Expand Up @@ -109,6 +148,11 @@ typedef ONNXIFI_CHECK_RESULT onnxStatus
* of the call. Reusable synchronization objects are
* generally initialized by the user prior to the
* call.
* @param[out] traceEvents - optional pointer to onnxTraceEventList that can be
* NULL. If non-NULL then the backend is requested to
* populate the onnxTraceEventList with trace events
* describing the timeline of events that occurred
* while running the graph.
*
* @retval ONNXIFI_STATUS_SUCCESS The function call succeeded and the all graph
* inputs and outputs were matched to a memory
Expand Down Expand Up @@ -217,7 +261,26 @@ ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI onnxSetIOAndRunGraph(
const onnxTensorDescriptorV1* inputDescriptors,
uint32_t outputsCount,
const onnxTensorDescriptorV1* outputDescriptors,
onnxMemoryFenceV1* outputFence);
onnxMemoryFenceV1* outputFence,
onnxTraceEventList* traceEvents);

/**
* Release the onnxTraceEvents contained in traceEvents.
*
* @param traceEvents - a list of onnxTraceEvents to be released.
*
* @retval ONNXIFI_STATUS_SUCCESS The function call succeeded and the
* onnxTraceEvents resources were released to the
* operating system.
* @retval ONNXIFI_STATUS_INVALID_POINTER The function call failed because
* onnxTraceEventList pointer is NULL.
* @retval ONNXIFI_STATUS_INTERNAL_ERROR The function call failed because the
* backend experienced an unrecovered
* internal error.
*/

ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI
onnxReleaseTraceEvents(onnxTraceEventList* traceEvents);

#ifdef __cplusplus
} /* extern "C" */
Expand Down

0 comments on commit dcabd8d

Please sign in to comment.