Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor WinMLAPI Tests to build both google and taef test based on preprocessor definition #2829

Merged
merged 7 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/winml_unittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ add_winml_test(
SOURCES ${winml_test_api_src}
LIBS winml_test_common
)
target_compile_definitions(winml_test_api PRIVATE BUILD_GOOGLE_TEST)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used?

Copy link
Contributor Author

@ryanlai2 ryanlai2 Jan 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used only in test.h line 4 to determine the correct test header which defines the WinML Test preprocessor definitions. I will make a similar change to the cmake api test in internal WindowsAI as well for BUILD_TAEF_TEST.

target_precompiled_header(winml_test_api testPch.h)

if (onnxruntime_USE_DML)
Expand Down
52 changes: 20 additions & 32 deletions winml/test/api/APITest.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,25 @@
//-----------------------------------------------------------------------------

#pragma once
#include "fileHelpers.h"
namespace APITest {
static void LoadModel(const std::wstring& modelPath,
winrt::Windows::AI::MachineLearning::LearningModel& learningModel) {
std::wstring fullPath = FileHelpers::GetModulePath() + modelPath;
learningModel = winrt::Windows::AI::MachineLearning::LearningModel::LoadFromFilePath(fullPath);
};

#include <gtest/gtest.h>

class APITest : public ::testing::Test
{
protected:
void LoadModel(const std::wstring& modelPath)
{
std::wstring fullPath = FileHelpers::GetModulePath() + modelPath;
m_model = winrt::Windows::AI::MachineLearning::LearningModel::LoadFromFilePath(fullPath);
}

winrt::Windows::AI::MachineLearning::LearningModel m_model = nullptr;
winrt::Windows::AI::MachineLearning::LearningModelDevice m_device = nullptr;
winrt::Windows::AI::MachineLearning::LearningModelSession m_session = nullptr;

uint64_t GetAdapterIdQuadPart()
{
LARGE_INTEGER id;
id.LowPart = m_device.AdapterId().LowPart;
id.HighPart = m_device.AdapterId().HighPart;
return id.QuadPart;
};

_LUID GetAdapterIdAsLUID()
{
_LUID id;
id.LowPart = m_device.AdapterId().LowPart;
id.HighPart = m_device.AdapterId().HighPart;
return id;
}

bool m_runGPUTests = true;
static uint64_t GetAdapterIdQuadPart(winrt::Windows::AI::MachineLearning::LearningModelDevice& device) {
LARGE_INTEGER id;
id.LowPart = device.AdapterId().LowPart;
id.HighPart = device.AdapterId().HighPart;
return id.QuadPart;
};

static _LUID GetAdapterIdAsLUID(winrt::Windows::AI::MachineLearning::LearningModelDevice& device) {
_LUID id;
id.LowPart = device.AdapterId().LowPart;
id.HighPart = device.AdapterId().HighPart;
return id;
}
}; // namespace APITest
Loading