mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
winml/ was previously excluded from lintrunner config. This change includes the directory and adds the clang-format config file specific to winml/ that fits existing style. --------- Signed-off-by: Justin Chu <justinchu@microsoft.com>
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#include "lib/Telemetry/pch.h"
|
|
|
|
#include "inc/TelemetryEvent.h"
|
|
|
|
using namespace _winmlt;
|
|
|
|
static uint64_t s_event_id = 0;
|
|
|
|
static const char* EventCategoryToString(EventCategory category) {
|
|
switch (category) {
|
|
case EventCategory::kModelLoad:
|
|
return "Model load";
|
|
case EventCategory::kSessionCreation:
|
|
return "Session creation";
|
|
case EventCategory::kBinding:
|
|
return "Binding";
|
|
case EventCategory::kEvaluation:
|
|
return "Evaluation";
|
|
default:
|
|
throw std::invalid_argument("category");
|
|
}
|
|
}
|
|
|
|
TelemetryEvent::TelemetryEvent(EventCategory category) {
|
|
auto is_provider_enabled = TraceLoggingProviderEnabled(
|
|
winml_trace_logging_provider, WINEVENT_LEVEL_VERBOSE, WINML_PROVIDER_KEYWORD_START_STOP
|
|
);
|
|
|
|
if (is_provider_enabled) {
|
|
category_ = category;
|
|
event_id_ = InterlockedIncrement(&s_event_id);
|
|
|
|
WinMLTraceLoggingWrite(
|
|
winml_trace_logging_provider,
|
|
"started event",
|
|
TraceLoggingString(EventCategoryToString(category_), "event"),
|
|
TraceLoggingInt64(event_id_.value(), "eventId"),
|
|
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_START_STOP)
|
|
);
|
|
}
|
|
}
|
|
|
|
TelemetryEvent::~TelemetryEvent() {
|
|
if (event_id_.has_value()) {
|
|
WinMLTraceLoggingWrite(
|
|
winml_trace_logging_provider,
|
|
"stopped event",
|
|
TraceLoggingString(EventCategoryToString(category_), "event"),
|
|
TraceLoggingInt64(event_id_.value(), "eventId"),
|
|
TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_START_STOP)
|
|
);
|
|
}
|
|
}
|