Skip to content

Commit

Permalink
Can't use DXGI to print adapter name of VPU (#274)
Browse files Browse the repository at this point in the history
* Fix vpu break, can't print adaptername using dxcore

* Spacing
  • Loading branch information
Ryan Lai committed Aug 29, 2019
1 parent c5a78b0 commit 5ddf3a2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
21 changes: 14 additions & 7 deletions Tools/WinMLRunner/src/LearningModelDeviceHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <Windows.Graphics.DirectX.Direct3D11.interop.h>
#include "Windows.AI.MachineLearning.Native.h"
#include <codecvt>
#include "OutputHelper.h"
using namespace winrt::Windows::Graphics::DirectX::Direct3D11;

#ifdef DXCORE_SUPPORTED_BUILD
Expand Down Expand Up @@ -83,11 +84,14 @@ void PopulateLearningModelDeviceList(CommandLineArgs& args, std::vector<Learning
com_ptr<IInspectable> inspectableDevice;
hr = CreateDirect3D11DeviceFromDXGIDevice(dxgiDevice.get(), inspectableDevice.put());
THROW_IF_FAILED(hr);
deviceList.push_back({
LearningModelDeviceWithMetadata learningModelDeviceWithMetadata =
{
LearningModelDevice::CreateFromDirect3D11Device(inspectableDevice.as<IDirect3DDevice>()),
deviceType,
deviceCreationLocation
});
};
OutputHelper::PrintLearningModelDevice(learningModelDeviceWithMetadata);
deviceList.push_back(learningModelDeviceWithMetadata);
}
#ifdef DXCORE_SUPPORTED_BUILD
else if ((TypeHelper::GetWinmlDeviceKind(deviceType) != LearningModelDeviceKind::Cpu) &&
Expand Down Expand Up @@ -216,11 +220,14 @@ void PopulateLearningModelDeviceList(CommandLineArgs& args, std::vector<Learning
#endif
else
{
deviceList.push_back({
LearningModelDevice(TypeHelper::GetWinmlDeviceKind(deviceType)),
deviceType,
deviceCreationLocation
});
LearningModelDeviceWithMetadata learningModelDeviceWithMetadata =
{
LearningModelDevice( TypeHelper::GetWinmlDeviceKind(deviceType)),
deviceType,
deviceCreationLocation
};
OutputHelper::PrintLearningModelDevice(learningModelDeviceWithMetadata);
deviceList.push_back(learningModelDeviceWithMetadata);
}
}
catch (...)
Expand Down
6 changes: 3 additions & 3 deletions Tools/WinMLRunner/src/OutputHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ class OutputHelper
std::cout << std::endl;
}

void PrintLearningModelDevice(const LearningModelDeviceWithMetadata& device)
static void PrintLearningModelDevice(const LearningModelDeviceWithMetadata& device)
{
if (device.DeviceType == DeviceType::CPU)
{
std::cout << "\nCreating Session with CPU device" << std::endl;
std::cout << "\nCreated LearningModelDevice with CPU device" << std::endl;
return;
}

Expand All @@ -185,7 +185,7 @@ class OutputHelper
DXGI_ADAPTER_DESC description;
if (SUCCEEDED(adapter->GetDesc(&description)))
{
std::wcout << L"\nCreating Session with GPU: " << description.Description << std::endl;
std::wcout << L"\nCreated LearningModelDevice with GPU: " << description.Description << std::endl;
}
}
else
Expand Down
1 change: 0 additions & 1 deletion Tools/WinMLRunner/src/Run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ HRESULT CreateSession(LearningModelSession& session, LearningModel& model, const
}
try
{
output.PrintLearningModelDevice(learningModelDevice);
CreateSessionConsideringSupportForSessionOptions(session, model, profiler, args, learningModelDevice);
}
catch (hresult_error hr)
Expand Down

0 comments on commit 5ddf3a2

Please sign in to comment.