Skip to content

Commit b2ab7be

Browse files
committed
Add telemetry for DXResourceBinding sample
1 parent d253e0a commit b2ab7be

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/DXResourceBindingORT/DXResourceBindingORT.xaml.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public sealed partial class DXResourceBindingORT : Page
3131
public DXResourceBindingORT()
3232
{
3333
this.InitializeComponent();
34+
35+
// Run in background thread to avoid blocking UI on sample launch
36+
Task.Run(() => SetModelNameForTelemetry());
3437
}
3538

3639
private async void LaunchWindow(object sender, RoutedEventArgs e)
@@ -105,5 +108,17 @@ public void StopAllEvents()
105108
{
106109
pageExited = true;
107110
}
111+
112+
// Session must be created for telemety to be sent
113+
private void SetModelNameForTelemetry()
114+
{
115+
var modelName = "squeezenet1.1-7.onnx";
116+
var modelPath = Path.Join(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "Models", modelName);
117+
var model = LearningModel.LoadFromFilePath(modelPath);
118+
var device = new LearningModelDevice(LearningModelDeviceKind.Cpu);
119+
var options = new LearningModelSessionOptions();
120+
SampleBasePage.SetModelNameForTelemetry("SqueezeNet", "AdapterSelection", model);
121+
new LearningModelSession(model, device, options);
122+
}
108123
}
109124
}

0 commit comments

Comments
 (0)