diff --git a/winml/lib/Api/LearningModelSessionOptions.cpp b/winml/lib/Api/LearningModelSessionOptions.cpp index 72c5c9a6ea..952cf067fe 100644 --- a/winml/lib/Api/LearningModelSessionOptions.cpp +++ b/winml/lib/Api/LearningModelSessionOptions.cpp @@ -38,6 +38,7 @@ uint32_t LearningModelSessionOptions::GetIntraOpNumThreads() { STDMETHODIMP LearningModelSessionOptions::SetIntraOpNumThreadsOverride(uint32_t intraOpNumThreads) noexcept { intra_op_num_threads_override_ = intraOpNumThreads; + telemetry_helper.SetIntraOpNumThreadsOverride(intraOpNumThreads); return S_OK; } } // namespace WINMLP diff --git a/winml/lib/Common/inc/WinMLTelemetryHelper.h b/winml/lib/Common/inc/WinMLTelemetryHelper.h index a4bac4c788..7606d5bba0 100644 --- a/winml/lib/Common/inc/WinMLTelemetryHelper.h +++ b/winml/lib/Common/inc/WinMLTelemetryHelper.h @@ -34,6 +34,7 @@ class Profiler; #define WINML_TLM_MODEL_CREATION_VERSION 0 #define WINML_TLM_RUNTIME_ERROR_VERSION 0 #define WINML_TLM_RUNTIME_PERF_VERSION 0 +#define WINML_TLM_NATIVE_API_INTRAOP_THREADS_VERSION 0 #define WinMLTraceLoggingWrite(hProvider, EventName, ...) \ TraceLoggingWrite(hProvider, \ @@ -94,7 +95,8 @@ class WinMLTelemetryHelper { uint32_t type_constraint_count, uint32_t attribute_count, uint32_t default_attribute_count); - + void SetIntraOpNumThreadsOverride( + uint32_t num_threads); void EndRuntimeSession() { ++runtime_session_id_; }; bool IsMeasureSampled(); diff --git a/winml/lib/Common/inc/common.h b/winml/lib/Common/inc/common.h index edecd5a006..ccfa418b49 100644 --- a/winml/lib/Common/inc/common.h +++ b/winml/lib/Common/inc/common.h @@ -21,6 +21,7 @@ #include #include #include +#include // WIL #include diff --git a/winml/lib/Telemetry/WinMLTelemetryHelper.cpp b/winml/lib/Telemetry/WinMLTelemetryHelper.cpp index 28cda97634..48de3e28e8 100644 --- a/winml/lib/Telemetry/WinMLTelemetryHelper.cpp +++ b/winml/lib/Telemetry/WinMLTelemetryHelper.cpp @@ -106,4 +106,21 @@ void WinMLTelemetryHelper::RegisterOperatorSetSchema( TraceLoggingInt32(default_attribute_count, "defaultAttributeCount"), TraceLoggingInt32(runtime_session_id_, "runtime_session_id_"), TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES)); +} + +void WinMLTelemetryHelper::SetIntraOpNumThreadsOverride( + uint32_t num_threads_override) { + if (!telemetry_enabled_) + return; + WinMLTraceLoggingWrite( + provider_, + "SetIntraOpNumThreadsOverride", + TraceLoggingKeyword(WINML_PROVIDER_KEYWORD_DEFAULT), + TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), + //Telemetry info + TraceLoggingUInt8(WINML_TLM_NATIVE_API_INTRAOP_THREADS_VERSION, "schemaVersion"), + // num threads info + TraceLoggingInt32(num_threads_override, "numThreadsOverride"), + TraceLoggingInt32(std::thread::hardware_concurrency(), "maxThreadsOnMachine"), + TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES)); } \ No newline at end of file