Skip to content

Commit 3c426e0

Browse files
author
REDMOND\jingf
committed
N/A
1 parent cd3c2ed commit 3c426e0

File tree

8 files changed

+74
-37
lines changed

8 files changed

+74
-37
lines changed

Samples/SampleSharedLib/SampleSharedLib/SampleSharedLib.vcxproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\..\BatchSupport\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\BatchSupport\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.props')" />
3+
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.props')" />
44
<ItemGroup Label="ProjectConfigurations">
55
<ProjectConfiguration Include="Debug_NuGet|Win32">
66
<Configuration>Debug_NuGet</Configuration>
@@ -69,7 +69,7 @@
6969
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
7070
<ConfigurationType>StaticLibrary</ConfigurationType>
7171
<UseDebugLibraries>false</UseDebugLibraries>
72-
<PlatformToolset>v142</PlatformToolset>
72+
<PlatformToolset>v143</PlatformToolset>
7373
<WholeProgramOptimization>true</WholeProgramOptimization>
7474
<CharacterSet>Unicode</CharacterSet>
7575
</PropertyGroup>
@@ -251,13 +251,13 @@
251251
</ItemGroup>
252252
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
253253
<ImportGroup Label="ExtensionTargets">
254-
<Import Project="..\..\BatchSupport\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\BatchSupport\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.targets')" />
254+
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.targets')" />
255255
</ImportGroup>
256256
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
257257
<PropertyGroup>
258258
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
259259
</PropertyGroup>
260-
<Error Condition="!Exists('..\..\BatchSupport\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\BatchSupport\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.props'))" />
261-
<Error Condition="!Exists('..\..\BatchSupport\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\BatchSupport\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.targets'))" />
260+
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.props'))" />
261+
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.220131.2\build\native\Microsoft.Windows.CppWinRT.targets'))" />
262262
</Target>
263263
</Project>

Samples/Tutorial Samples/WinMLPIXSample/WinMLPIXSample.sln

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.32126.315
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.1.32210.238
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinMLPIXSample", "WinMLPIXSample\WinMLPIXSample.vcxproj", "{3F9AE007-1715-46FF-8A52-E0A420290FCC}"
7+
ProjectSection(ProjectDependencies) = postProject
8+
{12103A5B-677A-4286-83D2-54EAB9010C16} = {12103A5B-677A-4286-83D2-54EAB9010C16}
9+
EndProjectSection
10+
EndProject
11+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleSharedLib", "..\..\SampleSharedLib\SampleSharedLib\SampleSharedLib.vcxproj", "{12103A5B-677A-4286-83D2-54EAB9010C16}"
712
EndProject
813
Global
914
GlobalSection(SolutionConfigurationPlatforms) = preSolution
15+
Debug_NuGet|x64 = Debug_NuGet|x64
16+
Debug_NuGet|x86 = Debug_NuGet|x86
1017
Debug|x64 = Debug|x64
1118
Debug|x86 = Debug|x86
1219
Release|x64 = Release|x64
1320
Release|x86 = Release|x86
1421
EndGlobalSection
1522
GlobalSection(ProjectConfigurationPlatforms) = postSolution
23+
{3F9AE007-1715-46FF-8A52-E0A420290FCC}.Debug_NuGet|x64.ActiveCfg = Debug|x64
24+
{3F9AE007-1715-46FF-8A52-E0A420290FCC}.Debug_NuGet|x64.Build.0 = Debug|x64
25+
{3F9AE007-1715-46FF-8A52-E0A420290FCC}.Debug_NuGet|x86.ActiveCfg = Debug|Win32
26+
{3F9AE007-1715-46FF-8A52-E0A420290FCC}.Debug_NuGet|x86.Build.0 = Debug|Win32
1627
{3F9AE007-1715-46FF-8A52-E0A420290FCC}.Debug|x64.ActiveCfg = Debug|x64
1728
{3F9AE007-1715-46FF-8A52-E0A420290FCC}.Debug|x64.Build.0 = Debug|x64
1829
{3F9AE007-1715-46FF-8A52-E0A420290FCC}.Debug|x86.ActiveCfg = Debug|Win32
@@ -21,6 +32,18 @@ Global
2132
{3F9AE007-1715-46FF-8A52-E0A420290FCC}.Release|x64.Build.0 = Release|x64
2233
{3F9AE007-1715-46FF-8A52-E0A420290FCC}.Release|x86.ActiveCfg = Release|Win32
2334
{3F9AE007-1715-46FF-8A52-E0A420290FCC}.Release|x86.Build.0 = Release|Win32
35+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Debug_NuGet|x64.ActiveCfg = Debug_NuGet|x64
36+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Debug_NuGet|x64.Build.0 = Debug_NuGet|x64
37+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Debug_NuGet|x86.ActiveCfg = Debug_NuGet|Win32
38+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Debug_NuGet|x86.Build.0 = Debug_NuGet|Win32
39+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Debug|x64.ActiveCfg = Debug|x64
40+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Debug|x64.Build.0 = Debug|x64
41+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Debug|x86.ActiveCfg = Debug|Win32
42+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Debug|x86.Build.0 = Debug|Win32
43+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Release|x64.ActiveCfg = Release|x64
44+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Release|x64.Build.0 = Release|x64
45+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Release|x86.ActiveCfg = Release|Win32
46+
{12103A5B-677A-4286-83D2-54EAB9010C16}.Release|x86.Build.0 = Release|Win32
2447
EndGlobalSection
2548
GlobalSection(SolutionProperties) = preSolution
2649
HideSolutionNode = FALSE

Samples/Tutorial Samples/WinMLPIXSample/WinMLPIXSample/WinMLHelper.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,26 @@
55
void LoadModel()
66
{
77
// load the model
8+
auto modelPath = static_cast<hstring>(FileHelper::GetModulePath().c_str()) + modelName;
89
printf("Loading modelfile '%ws' on the '%s' device\n", modelPath.c_str(), deviceName.c_str());
910
DWORD ticks = GetTickCount();
1011
model = LearningModel::LoadFromFilePath(modelPath);
1112
ticks = GetTickCount() - ticks;
1213
printf("model file loaded in %d ticks\n", ticks);
1314
}
1415

15-
VideoFrame LoadImageFile(hstring filePath)
16+
VideoFrame LoadImageFile()
1617
{
1718
printf("Loading the image...\n");
1819
DWORD ticks = GetTickCount();
1920
VideoFrame inputImage = nullptr;
2021

21-
TCHAR buffer[MAX_PATH] = { 0 };
22-
wstring dir;
23-
GetCurrentDirectory(MAX_PATH, buffer);
24-
dir.assign(buffer).append(filePath);
22+
auto imagePath = static_cast<hstring>(FileHelper::GetModulePath().c_str()) + imageName;
2523

2624
try
2725
{
2826
// open the file
29-
StorageFile file = StorageFile::GetFileFromPathAsync(dir).get();
27+
StorageFile file = StorageFile::GetFileFromPathAsync(imagePath).get();
3028
// get a stream on it
3129
auto stream = file.OpenAsync(FileAccessMode::Read).get();
3230
// Create the decoder from the stream
@@ -124,10 +122,11 @@ void PrintResults(IVectorView<float> results)
124122
void LoadLabels()
125123
{
126124
// Parse labels from labels file. We know the file's entries are already sorted in order.
127-
ifstream labelFile{ labelsFilePath, ifstream::in };
125+
auto labelsFilePath = static_cast<hstring>(FileHelper::GetModulePath().c_str()) + labelsName;
126+
ifstream labelFile{ labelsFilePath.c_str(), ifstream::in};
128127
if (labelFile.fail())
129128
{
130-
printf("failed to load the %s file. Make sure it exists in the same folder as the app\r\n", labelsFilePath.c_str());
129+
printf("failed to load the %s file. Make sure it exists in the same folder as the app\r\n", labelsName.c_str());
131130
exit(EXIT_FAILURE);
132131
}
133132

Samples/Tutorial Samples/WinMLPIXSample/WinMLPIXSample/WinMLHelper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ using namespace winrt::Windows::Storage;
1414
using namespace std;
1515

1616
// Global variables
17-
static hstring modelPath = L".\\Assets\\SqueezeNet.onnx";
17+
static hstring modelName = L"SqueezeNet.onnx";
1818
static string deviceName = "default";
19-
static hstring imagePath = L"\\Assets\\kitten_224.png";
19+
static hstring imageName = L"kitten_224.png";
2020
static LearningModel model = nullptr;
2121
static LearningModelSession session = nullptr;
2222
static LearningModelBinding binding = nullptr;
2323
static VideoFrame imageFrame = nullptr;
24-
static string labelsFilePath = ".\\Assets\\Labels.txt";
24+
static hstring labelsName = L"Labels.txt";
2525
static vector<string> labels;
2626

2727
// Forward declarations
2828
void LoadModel();
29-
VideoFrame LoadImageFile(hstring filePath);
29+
VideoFrame LoadImageFile();
3030
void CreateSession(ID3D12CommandQueue* commandQueue);
3131
void BindModel();
3232
void EvaluateModel();

Samples/Tutorial Samples/WinMLPIXSample/WinMLPIXSample/WinMLPIXSample.vcxproj

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@
7777
<ClCompile>
7878
<Optimization>Disabled</Optimization>
7979
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
80+
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\..\SampleSharedLib\SampleSharedLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
8081
</ClCompile>
8182
<Link>
8283
<SubSystem>Console</SubSystem>
8384
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
84-
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">ole32.lib;oleaut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
85+
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\SampleSharedLib.lib;ole32.lib;oleaut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
8586
</Link>
8687
</ItemDefinitionGroup>
8788
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
@@ -95,12 +96,14 @@
9596
<FunctionLevelLinking>true</FunctionLevelLinking>
9697
<IntrinsicFunctions>true</IntrinsicFunctions>
9798
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
99+
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\..\SampleSharedLib\SampleSharedLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
98100
</ClCompile>
99101
<Link>
100102
<SubSystem>Console</SubSystem>
101103
<EnableCOMDATFolding>true</EnableCOMDATFolding>
102104
<OptimizeReferences>true</OptimizeReferences>
103105
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
106+
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\SampleSharedLib.lib;ole32.lib;oleaut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
104107
</Link>
105108
</ItemDefinitionGroup>
106109
<ItemGroup>
@@ -117,14 +120,26 @@
117120
<ClCompile Include="WinMLHelper.cpp" />
118121
</ItemGroup>
119122
<ItemGroup>
120-
<None Include="Assets\SqueezeNet.onnx" />
123+
<CopyFileToFolders Include="..\..\..\..\SharedContent\models\SqueezeNet.onnx">
124+
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</DeploymentContent>
125+
<FileType>Document</FileType>
126+
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
127+
</CopyFileToFolders>
121128
<None Include="packages.config" />
122129
<None Include="PropertySheet.props" />
123130
<None Include="readme.md" />
124-
<Text Include="Assets\Labels.txt" />
125131
</ItemGroup>
126132
<ItemGroup>
127-
<Image Include="Assets\kitten_224.png" />
133+
<CopyFileToFolders Include="..\..\..\..\SharedContent\media\kitten_224.png">
134+
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</DeploymentContent>
135+
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
136+
</CopyFileToFolders>
137+
</ItemGroup>
138+
<ItemGroup>
139+
<CopyFileToFolders Include="Assets\Labels.txt">
140+
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</DeploymentContent>
141+
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
142+
</CopyFileToFolders>
128143
</ItemGroup>
129144
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
130145
<ImportGroup Label="ExtensionTargets">

Samples/Tutorial Samples/WinMLPIXSample/WinMLPIXSample/WinMLPIXSample.vcxproj.filters

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
1111
</Filter>
1212
<Filter Include="Resource Files">
13-
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
13+
<UniqueIdentifier>{5f44b9c5-7076-4e47-ace0-bb83f8c4913b}</UniqueIdentifier>
1414
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
1515
</Filter>
1616
</ItemGroup>
@@ -42,19 +42,17 @@
4242
<ItemGroup>
4343
<None Include="PropertySheet.props" />
4444
<None Include="packages.config" />
45-
<None Include="Assets\SqueezeNet.onnx">
46-
<Filter>Resource Files</Filter>
47-
</None>
4845
<None Include="readme.md" />
4946
</ItemGroup>
5047
<ItemGroup>
51-
<Text Include="Assets\Labels.txt">
48+
<CopyFileToFolders Include="..\..\..\..\SharedContent\media\kitten_224.png">
5249
<Filter>Resource Files</Filter>
53-
</Text>
54-
</ItemGroup>
55-
<ItemGroup>
56-
<Image Include="Assets\kitten_224.png">
50+
</CopyFileToFolders>
51+
<CopyFileToFolders Include="Assets\Labels.txt">
52+
<Filter>Resource Files</Filter>
53+
</CopyFileToFolders>
54+
<CopyFileToFolders Include="..\..\..\..\SharedContent\models\SqueezeNet.onnx">
5755
<Filter>Resource Files</Filter>
58-
</Image>
56+
</CopyFileToFolders>
5957
</ItemGroup>
6058
</Project>

Samples/Tutorial Samples/WinMLPIXSample/WinMLPIXSample/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ void GetD3D12CommandAssets()
7373
d3d12Device->CreateCommandList(0, type, commandAllocator, nullptr, __uuidof(ID3D12CommandList), (void**)&commandList);
7474
}
7575

76-
void LoadAndEvaluate(ID3D12CommandQueue* commandQueue)
76+
void LoadAndEvaluate()
7777
{
7878
// Setting markers for each step, these markers will split the commands into sections for easier debugging
7979
PIXSetMarker(commandQueue, color, "Start loading model...");
8080
LoadModel();
8181

8282
PIXSetMarker(commandQueue, color, "Start loading image...");
83-
LoadImageFile(imagePath);
83+
LoadImageFile();
8484

8585
PIXSetMarker(commandQueue, color, "Start creating session...");
8686
CreateSession(commandQueue);
@@ -109,7 +109,7 @@ void CaptureWithUserSetMarker()
109109
PIXBeginEvent(commandQueue, color, "WinMLPIXSample");
110110

111111
// Do the ML computation
112-
LoadAndEvaluate(commandQueue);
112+
LoadAndEvaluate();
113113

114114
// End PIX event
115115
PIXEndEvent(commandQueue);

Samples/Tutorial Samples/WinMLPIXSample/WinMLPIXSample/pch.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@
1616
#include <d3d12.h>
1717
#include <dxgi1_4.h>
1818

19-
#include "pix3.h"
19+
#include "pix3.h"
20+
21+
#include "FileHelper.h"

0 commit comments

Comments
 (0)