|
7 | 7 | extern "C" { |
8 | 8 | #endif |
9 | 9 |
|
| 10 | +typedef struct onnxTraceEvent { |
| 11 | + /** |
| 12 | + * Human readable name for the event, will be used to match up begin and end |
| 13 | + * of an event duration. |
| 14 | + */ |
| 15 | + const char *eventName; |
| 16 | + |
| 17 | + /** |
| 18 | + * Type of the event, can be one of the following: |
| 19 | + * 'B': Beginning of event |
| 20 | + * 'E': End of event |
| 21 | + */ |
| 22 | + char eventType; |
| 23 | + |
| 24 | + /** |
| 25 | + * Time of the event, in milliseconds since epoch. |
| 26 | + */ |
| 27 | + uint64_t timestamp; |
| 28 | + |
| 29 | + /** |
| 30 | + * Thread Id for this event. All events with the same tid will be grouped |
| 31 | + * together in the trace. |
| 32 | + */ |
| 33 | + uint32_t tid; |
| 34 | +} onnxTraceEvent; |
| 35 | + |
| 36 | +typedef struct onnxTraceEventList { |
| 37 | + /** |
| 38 | + * The number of events in traceEvents. |
| 39 | + */ |
| 40 | + uint64_t numEvents; |
| 41 | + |
| 42 | + /** |
| 43 | + * A pointer to an array of pointers to onnxTraceEvents allocated by the onnx |
| 44 | + * backend, the length of which is indicated by numEvents. |
| 45 | + */ |
| 46 | + onnxTraceEvent **traceEvents; |
| 47 | +} onnxTraceEventList; |
| 48 | + |
10 | 49 | /** |
11 | 50 | * Generic ONNXIFI extension function pointer. |
12 | 51 | * |
@@ -109,6 +148,11 @@ typedef ONNXIFI_CHECK_RESULT onnxStatus |
109 | 148 | * of the call. Reusable synchronization objects are |
110 | 149 | * generally initialized by the user prior to the |
111 | 150 | * call. |
| 151 | + * @param[out] traceEvents - optional pointer to onnxTraceEventList that can be |
| 152 | + * NULL. If non-NULL then the backend is requested to |
| 153 | + * populate the onnxTraceEventList with trace events |
| 154 | + * describing the timeline of events that occurred |
| 155 | + * while running the graph. |
112 | 156 | * |
113 | 157 | * @retval ONNXIFI_STATUS_SUCCESS The function call succeeded and the all graph |
114 | 158 | * inputs and outputs were matched to a memory |
@@ -217,7 +261,26 @@ ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI onnxSetIOAndRunGraph( |
217 | 261 | const onnxTensorDescriptorV1* inputDescriptors, |
218 | 262 | uint32_t outputsCount, |
219 | 263 | const onnxTensorDescriptorV1* outputDescriptors, |
220 | | - onnxMemoryFenceV1* outputFence); |
| 264 | + onnxMemoryFenceV1* outputFence, |
| 265 | + onnxTraceEventList* traceEvents); |
| 266 | + |
| 267 | +/** |
| 268 | + * Release the onnxTraceEvents contained in traceEvents. |
| 269 | + * |
| 270 | + * @param traceEvents - a list of onnxTraceEvents to be released. |
| 271 | + * |
| 272 | + * @retval ONNXIFI_STATUS_SUCCESS The function call succeeded and the |
| 273 | + * onnxTraceEvents resources were released to the |
| 274 | + * operating system. |
| 275 | + * @retval ONNXIFI_STATUS_INVALID_POINTER The function call failed because |
| 276 | + * onnxTraceEventList pointer is NULL. |
| 277 | + * @retval ONNXIFI_STATUS_INTERNAL_ERROR The function call failed because the |
| 278 | + * backend experienced an unrecovered |
| 279 | + * internal error. |
| 280 | + */ |
| 281 | + |
| 282 | +ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI |
| 283 | + onnxReleaseTraceEvents(onnxTraceEventList* traceEvents); |
221 | 284 |
|
222 | 285 | #ifdef __cplusplus |
223 | 286 | } /* extern "C" */ |
|
0 commit comments