Log telemetry for WinML Native API for setting intra op num usage (#4700)

Co-authored-by: Ryan Lai <ryalai96@gmail.com>
This commit is contained in:
Ryan Lai 2020-08-04 09:44:23 -07:00 committed by GitHub
parent 4bd9e8d05c
commit f9bd52f852
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 1 deletions

View file

@ -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

View file

@ -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();

View file

@ -21,6 +21,7 @@
#include <utility>
#include <variant>
#include <vector>
#include <thread>
// WIL
#include <wil/cppwinrt.h>

View file

@ -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));
}