mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-23 19:32:23 +00:00
### Description Merge main to WindowsAI ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Signed-off-by: Nash <george.nash@intel.com> Signed-off-by: Yiming Hu <yiming.hu@amd.com> Signed-off-by: Liqun Fu <liqfu@microsoft.com> Co-authored-by: Kaz Nishimura <kazssym@linuxfront.com> Co-authored-by: Tianlei Wu <tlwu@microsoft.com> Co-authored-by: Nat Kershaw (MSFT) <nakersha@microsoft.com> Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Co-authored-by: Changming Sun <chasun@microsoft.com> Co-authored-by: zesongw <zesong.wang@intel.com> Co-authored-by: Yi Zhang <zhanyi@microsoft.com> Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com> Co-authored-by: Yifan Li <109183385+yf711@users.noreply.github.com> Co-authored-by: simonjub <78098752+simonjub@users.noreply.github.com> Co-authored-by: PeixuanZuo <94887879+PeixuanZuo@users.noreply.github.com> Co-authored-by: Adrian Lizarraga <adlizarraga@microsoft.com> Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com> Co-authored-by: Arthur Islamov <arthur@islamov.ai> Co-authored-by: Jambay Kinley <jambaykinley@microsoft.com> Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com> Co-authored-by: Wei-Sheng Chin <wschin@outlook.com> Co-authored-by: Bowen Bao <bowbao@microsoft.com> Co-authored-by: Hariharan Seshadri <shariharan91@gmail.com> Co-authored-by: Numfor Tiapo <numsmt2@gmail.com> Co-authored-by: Vincent Wang <wangwchpku@outlook.com> Co-authored-by: Pranav Sharma <prs@microsoft.com> Co-authored-by: George Nash <george.nash@intel.com> Co-authored-by: Abhishek Jindal <abjindal@microsoft.com> Co-authored-by: pengwa <pengwa@microsoft.com> Co-authored-by: Yiming Hu <woinck@users.noreply.github.com> Co-authored-by: Jiajia Qin <jiajia.qin@intel.com> Co-authored-by: Lukas Berbuer <36054362+lukasberbuer@users.noreply.github.com> Co-authored-by: Wanming Lin <wanming.lin@intel.com> Co-authored-by: Xavier Dupré <xadupre@users.noreply.github.com> Co-authored-by: aimilefth <60664743+aimilefth@users.noreply.github.com> Co-authored-by: Baiju Meswani <bmeswani@microsoft.com> Co-authored-by: Adam Pocock <adam.pocock@oracle.com> Co-authored-by: Chi Lo <54722500+chilo-ms@users.noreply.github.com> Co-authored-by: RandySheriffH <48490400+RandySheriffH@users.noreply.github.com> Co-authored-by: Randy Shuai <rashuai@microsoft.com> Co-authored-by: Vadym Stupakov <vadim.stupakov@gmail.com> Co-authored-by: Jian Chen <cjian@microsoft.com> Co-authored-by: Brian Lambert <98757707+brian-pieces@users.noreply.github.com> Co-authored-by: Nicolò Lucchesi <nicolo.lucchesi@gmail.com> Co-authored-by: liqun Fu <liqfu@microsoft.com> Co-authored-by: trajep <trajepl@gmail.com> Co-authored-by: Scott McKay <skottmckay@gmail.com> Co-authored-by: Mustafa Ateş Uzun <mustafauzun0@gmail.com> Co-authored-by: MistEO <mistereo@hotmail.com> Co-authored-by: satyajandhyala <satya.k.jandhyala@gmail.com> Co-authored-by: shaahji <96227573+shaahji@users.noreply.github.com> Co-authored-by: Rachel Guo <35738743+YUNQIUGUO@users.noreply.github.com> Co-authored-by: rachguo <rachguo@rachguos-Mini.attlocal.net> Co-authored-by: Caroline Zhu <wolfivyaura@gmail.com> Co-authored-by: Caroline Zhu <carolinezhu@microsoft.com> Co-authored-by: Guenther Schmuelling <guschmue@microsoft.com> Co-authored-by: xhcao <xinghua.cao@intel.com> Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com> Co-authored-by: Xu Xing <xing.xu@intel.com> Co-authored-by: Hector Li <hecli@microsoft.com> Co-authored-by: Ye Wang <52801275+wangyems@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: Benedikt Hilmes <benedikt.hilmes@rwth-aachen.de> Co-authored-by: rachguo <rachguo@rachguos-Mac-mini.local> Co-authored-by: George Wu <jywu@microsoft.com> Co-authored-by: JiCheng <wejoncy@163.com> Co-authored-by: Sheil Kumar <smk2007@gmail.com> Co-authored-by: Sheil Kumar <sheilk@microsoft.com> Co-authored-by: cloudhan <guangyunhan@microsoft.com> Co-authored-by: kyoshisuki <143475866+kyoshisuki@users.noreply.github.com> Co-authored-by: aciddelgado <139922440+aciddelgado@users.noreply.github.com> Co-authored-by: tlwu@microsoft.com <tlwu@a100.crj0ad2y1kku1j4yxl4sj10o4e.gx.internal.cloudapp.net> Co-authored-by: Maximilian Müller <44298237+gedoensmax@users.noreply.github.com> Co-authored-by: Tang, Cheng <souptc@gmail.com> Co-authored-by: Cheng Tang <chenta@microsoft.com@orttrainingdev9.d32nl1ml4oruzj4qz3bqlggovf.px.internal.cloudapp.net> Co-authored-by: Cheng Tang <chenta@microsoft.com> Co-authored-by: Jeff Daily <jeff.daily@amd.com> Co-authored-by: cloudhan <cloudhan@outlook.com> Co-authored-by: Yufeng Li <liyufeng1987@gmail.com> Co-authored-by: Zhang Lei <zhang.huanning@hotmail.com> Co-authored-by: Dwayne Robinson <fdwr@hotmail.com> Co-authored-by: Zhipeng Han <zhipeng.han@outlook.com> Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Patrice Vignola <vignola.patrice@gmail.com> Co-authored-by: kunal-vaishnavi <115581922+kunal-vaishnavi@users.noreply.github.com> Co-authored-by: snadampal <87143774+snadampal@users.noreply.github.com> Co-authored-by: Sumit Agarwal <sumitagarwal330@gmail.com> Co-authored-by: Ashwini Khade <askhade@microsoft.com> Co-authored-by: Yang Gu <yang.gu@intel.com> Co-authored-by: Cheng Tang <chenta@a100.crj0ad2y1kku1j4yxl4sj10o4e.gx.internal.cloudapp.net> Co-authored-by: mindest <30493312+mindest@users.noreply.github.com> Co-authored-by: Scott McKay <Scott.McKay@microsoft.com> Co-authored-by: Xavier Dupre <xadupre@microsoft.com@orttrainingdev9.d32nl1ml4oruzj4qz3bqlggovf.px.internal.cloudapp.net> Co-authored-by: guyang3532 <62738430+guyang3532@users.noreply.github.com> Co-authored-by: Carson M <carson@pyke.io> Co-authored-by: sophies927 <107952697+sophies927@users.noreply.github.com>
338 lines
13 KiB
C++
338 lines
13 KiB
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#include "testPch.h"
|
|
#include "LearningModelAPITest.h"
|
|
#include "APITest.h"
|
|
|
|
using namespace winrt;
|
|
using namespace winml;
|
|
using namespace wfc;
|
|
using namespace wgi;
|
|
using namespace wm;
|
|
using namespace ws;
|
|
using namespace wss;
|
|
|
|
static void LearningModelAPITestsClassSetup() {
|
|
init_apartment();
|
|
#ifdef BUILD_INBOX
|
|
winrt_activation_handler = WINRT_RoGetActivationFactory;
|
|
#endif
|
|
}
|
|
|
|
static void CreateModelFromFilePath() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"squeezenet_modifiedforruntimestests.onnx", learningModel));
|
|
}
|
|
|
|
static void CreateModelFromUnicodeFilePath() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"UnicodePath\\\u3053\u3093\u306B\u3061\u306F maçã\\foo.onnx", learningModel)
|
|
);
|
|
}
|
|
|
|
static void CreateModelFileNotFound() {
|
|
LearningModel learningModel = nullptr;
|
|
|
|
WINML_EXPECT_THROW_SPECIFIC(
|
|
APITest::LoadModel(L"missing_model.onnx", learningModel),
|
|
winrt::hresult_error,
|
|
[](const winrt::hresult_error& e) -> bool { return e.code() == __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); }
|
|
);
|
|
}
|
|
|
|
static void CreateCorruptModel() {
|
|
LearningModel learningModel = nullptr;
|
|
|
|
WINML_EXPECT_THROW_SPECIFIC(
|
|
APITest::LoadModel(L"corrupt-model.onnx", learningModel),
|
|
winrt::hresult_error,
|
|
[](const winrt::hresult_error& e) -> bool { return e.code() == __HRESULT_FROM_WIN32(ERROR_FILE_CORRUPT); }
|
|
);
|
|
}
|
|
|
|
static void CreateModelFromIStorage() {
|
|
std::wstring path = FileHelpers::GetModulePath() + L"squeezenet_modifiedforruntimestests.onnx";
|
|
auto storageFile = ws::StorageFile::GetFileFromPathAsync(path).get();
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(learningModel = LearningModel::LoadFromStorageFileAsync(storageFile).get());
|
|
WINML_EXPECT_TRUE(learningModel != nullptr);
|
|
|
|
// check the author so we know the model was populated correctly.
|
|
std::wstring author(learningModel.Author());
|
|
WINML_EXPECT_EQUAL(L"onnx-caffe2", author);
|
|
}
|
|
|
|
static void CreateModelFromIStorageOutsideCwd() {
|
|
std::wstring path = FileHelpers::GetModulePath() + L"ModelSubdirectory\\ModelInSubdirectory.onnx";
|
|
auto storageFile = ws::StorageFile::GetFileFromPathAsync(path).get();
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(learningModel = LearningModel::LoadFromStorageFileAsync(storageFile).get());
|
|
WINML_EXPECT_TRUE(learningModel != nullptr);
|
|
|
|
// check the author so we know the model was populated correctly.
|
|
std::wstring author(learningModel.Author());
|
|
WINML_EXPECT_EQUAL(L"onnx-caffe2", author);
|
|
}
|
|
|
|
static void CreateModelFromIStream() {
|
|
std::wstring path = FileHelpers::GetModulePath() + L"squeezenet_modifiedforruntimestests.onnx";
|
|
auto storageFile = ws::StorageFile::GetFileFromPathAsync(path).get();
|
|
ws::Streams::IRandomAccessStreamReference streamref;
|
|
storageFile.as(streamref);
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(learningModel = LearningModel::LoadFromStreamAsync(streamref).get());
|
|
WINML_EXPECT_TRUE(learningModel != nullptr);
|
|
|
|
// check the author so we know the model was populated correctly.
|
|
std::wstring author(learningModel.Author());
|
|
WINML_EXPECT_EQUAL(L"onnx-caffe2", author);
|
|
}
|
|
|
|
static void ModelGetAuthor() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"squeezenet_modifiedforruntimestests.onnx", learningModel));
|
|
std::wstring author(learningModel.Author());
|
|
WINML_EXPECT_EQUAL(L"onnx-caffe2", author);
|
|
}
|
|
|
|
static void ModelGetName() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"squeezenet_modifiedforruntimestests.onnx", learningModel));
|
|
std::wstring name(learningModel.Name());
|
|
WINML_EXPECT_EQUAL(L"squeezenet_old", name);
|
|
}
|
|
|
|
static void ModelGetDomain() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"squeezenet_modifiedforruntimestests.onnx", learningModel));
|
|
std::wstring domain(learningModel.Domain());
|
|
WINML_EXPECT_EQUAL(L"test-domain", domain);
|
|
}
|
|
|
|
static void ModelGetDescription() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"squeezenet_modifiedforruntimestests.onnx", learningModel));
|
|
std::wstring description(learningModel.Description());
|
|
WINML_EXPECT_EQUAL(L"test-doc_string", description);
|
|
}
|
|
|
|
static void ModelGetVersion() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"squeezenet_modifiedforruntimestests.onnx", learningModel));
|
|
int64_t version(learningModel.Version());
|
|
(void)(version);
|
|
}
|
|
|
|
typedef std::vector<std::pair<std::wstring, std::wstring>> Metadata;
|
|
|
|
/*
|
|
class MetadataTest : public LearningModelAPITest, public testing::WithParamInterface<std::pair<std::wstring, Metadata>>
|
|
{};
|
|
|
|
TEST_P(MetadataTest, GetMetaData)
|
|
{
|
|
std::wstring fileName;
|
|
std::vector<std::pair<std::wstring, std::wstring>> keyValuePairs;
|
|
|
|
tie(fileName, keyValuePairs) = GetParam();
|
|
WINML_EXPECT_NO_THROW(LoadModel(fileName.c_str()));
|
|
WINML_EXPECT_TRUE(m_model.Metadata() != nullptr);
|
|
WINML_EXPECT_EQUAL(keyValuePairs.size(), m_model.Metadata().Size());
|
|
|
|
auto iter = m_model.Metadata().First();
|
|
for (auto& keyValue : keyValuePairs)
|
|
{
|
|
WINML_EXPECT_TRUE(iter.HasCurrent());
|
|
WINML_EXPECT_EQUAL(keyValue.first, std::wstring(iter.Current().Key()));
|
|
WINML_EXPECT_EQUAL(keyValue.second, std::wstring(iter.Current().Value()));
|
|
iter.MoveNext();
|
|
}
|
|
}
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
|
ModelMetadata,
|
|
MetadataTest,
|
|
::testing::Values(
|
|
std::pair(L"squeezenet_modifiedforruntimestests.onnx", Metadata{}),
|
|
std::pair(L"modelWithMetaData.onnx", Metadata{{L"thisisalongkey", L"thisisalongvalue"}}),
|
|
std::pair(L"modelWith2MetaData.onnx", Metadata{{L"thisisalongkey", L"thisisalongvalue"}, {L"key2", L"val2"}})
|
|
));
|
|
*/
|
|
|
|
static void EnumerateInputs() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"squeezenet_modifiedforruntimestests.onnx", learningModel));
|
|
|
|
// purposely don't cache "InputFeatures" in order to exercise calling it multiple times
|
|
WINML_EXPECT_TRUE(learningModel.InputFeatures().First().HasCurrent());
|
|
|
|
std::wstring name(learningModel.InputFeatures().First().Current().Name());
|
|
WINML_EXPECT_EQUAL(L"data_0", name);
|
|
|
|
// make sure it's either tensor or image
|
|
TensorFeatureDescriptor tensorDescriptor = nullptr;
|
|
learningModel.InputFeatures().First().Current().try_as(tensorDescriptor);
|
|
if (tensorDescriptor == nullptr) {
|
|
ImageFeatureDescriptor imageDescriptor = nullptr;
|
|
WINML_EXPECT_NO_THROW(learningModel.InputFeatures().First().Current().as(imageDescriptor));
|
|
}
|
|
|
|
auto modelDataKind = tensorDescriptor.TensorKind();
|
|
WINML_EXPECT_EQUAL(TensorKind::Float, modelDataKind);
|
|
|
|
WINML_EXPECT_TRUE(tensorDescriptor.IsRequired());
|
|
|
|
std::vector<int64_t> expectedShapes = {1, 3, 224, 224};
|
|
WINML_EXPECT_EQUAL(expectedShapes.size(), tensorDescriptor.Shape().Size());
|
|
for (uint32_t j = 0; j < tensorDescriptor.Shape().Size(); j++) {
|
|
WINML_EXPECT_EQUAL(expectedShapes.at(j), tensorDescriptor.Shape().GetAt(j));
|
|
}
|
|
|
|
auto first = learningModel.InputFeatures().First();
|
|
first.MoveNext();
|
|
WINML_EXPECT_FALSE(first.HasCurrent());
|
|
}
|
|
|
|
static void EnumerateOutputs() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"squeezenet_modifiedforruntimestests.onnx", learningModel));
|
|
|
|
// purposely don't cache "OutputFeatures" in order to exercise calling it multiple times
|
|
std::wstring name(learningModel.OutputFeatures().First().Current().Name());
|
|
WINML_EXPECT_EQUAL(L"softmaxout_1", name);
|
|
|
|
TensorFeatureDescriptor tensorDescriptor = nullptr;
|
|
WINML_EXPECT_NO_THROW(learningModel.OutputFeatures().First().Current().as(tensorDescriptor));
|
|
WINML_EXPECT_TRUE(tensorDescriptor != nullptr);
|
|
|
|
auto tensorName = tensorDescriptor.Name();
|
|
WINML_EXPECT_EQUAL(L"softmaxout_1", tensorName);
|
|
|
|
auto modelDataKind = tensorDescriptor.TensorKind();
|
|
WINML_EXPECT_EQUAL(TensorKind::Float, modelDataKind);
|
|
|
|
WINML_EXPECT_TRUE(tensorDescriptor.IsRequired());
|
|
|
|
std::vector<int64_t> expectedShapes = {1, 1000, 1, 1};
|
|
WINML_EXPECT_EQUAL(expectedShapes.size(), tensorDescriptor.Shape().Size());
|
|
for (uint32_t j = 0; j < tensorDescriptor.Shape().Size(); j++) {
|
|
WINML_EXPECT_EQUAL(expectedShapes.at(j), tensorDescriptor.Shape().GetAt(j));
|
|
}
|
|
|
|
auto first = learningModel.OutputFeatures().First();
|
|
first.MoveNext();
|
|
WINML_EXPECT_FALSE(first.HasCurrent());
|
|
}
|
|
|
|
static void CloseModelCheckMetadata() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"squeezenet_modifiedforruntimestests.onnx", learningModel));
|
|
WINML_EXPECT_NO_THROW(learningModel.Close());
|
|
std::wstring author(learningModel.Author());
|
|
WINML_EXPECT_EQUAL(L"onnx-caffe2", author);
|
|
std::wstring name(learningModel.Name());
|
|
WINML_EXPECT_EQUAL(L"squeezenet_old", name);
|
|
std::wstring domain(learningModel.Domain());
|
|
WINML_EXPECT_EQUAL(L"test-domain", domain);
|
|
std::wstring description(learningModel.Description());
|
|
WINML_EXPECT_EQUAL(L"test-doc_string", description);
|
|
int64_t version(learningModel.Version());
|
|
WINML_EXPECT_EQUAL(123456, version);
|
|
}
|
|
|
|
static void CheckLearningModelPixelRange() {
|
|
std::vector<std::wstring> modelPaths = {// NominalRange_0_255 and image output
|
|
L"Add_ImageNet1920WithImageMetadataBgr8_SRGB_0_255.onnx",
|
|
// Normalized_0_1 and image output
|
|
L"Add_ImageNet1920WithImageMetadataBgr8_SRGB_0_1.onnx",
|
|
// Normalized_1_1 and image output
|
|
L"Add_ImageNet1920WithImageMetadataBgr8_SRGB_1_1.onnx"};
|
|
std::vector<LearningModelPixelRange> pixelRanges = {
|
|
LearningModelPixelRange::ZeroTo255, LearningModelPixelRange::ZeroToOne, LearningModelPixelRange::MinusOneToOne};
|
|
for (uint32_t model_i = 0; model_i < modelPaths.size(); model_i++) {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(modelPaths[model_i], learningModel));
|
|
auto inputs = learningModel.InputFeatures();
|
|
for (auto&& input : inputs) {
|
|
ImageFeatureDescriptor imageDescriptor = nullptr;
|
|
WINML_EXPECT_NO_THROW(input.as(imageDescriptor));
|
|
WINML_EXPECT_EQUAL(imageDescriptor.PixelRange(), pixelRanges[model_i]);
|
|
}
|
|
auto outputs = learningModel.OutputFeatures();
|
|
for (auto&& output : outputs) {
|
|
ImageFeatureDescriptor imageDescriptor = nullptr;
|
|
WINML_EXPECT_NO_THROW(output.as(imageDescriptor));
|
|
WINML_EXPECT_EQUAL(imageDescriptor.PixelRange(), pixelRanges[model_i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void CloseModelCheckEval() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"model.onnx", learningModel));
|
|
LearningModelSession session = nullptr;
|
|
WINML_EXPECT_NO_THROW(session = LearningModelSession(learningModel));
|
|
WINML_EXPECT_NO_THROW(learningModel.Close());
|
|
|
|
std::wstring fullImagePath = FileHelpers::GetModulePath() + L"kitten_224.png";
|
|
StorageFile imagefile = StorageFile::GetFileFromPathAsync(fullImagePath).get();
|
|
IRandomAccessStream stream = imagefile.OpenAsync(FileAccessMode::Read).get();
|
|
SoftwareBitmap softwareBitmap = (BitmapDecoder::CreateAsync(stream).get()).GetSoftwareBitmapAsync().get();
|
|
VideoFrame frame = VideoFrame::CreateWithSoftwareBitmap(softwareBitmap);
|
|
|
|
LearningModelBinding binding = nullptr;
|
|
WINML_EXPECT_NO_THROW(binding = LearningModelBinding(session));
|
|
WINML_EXPECT_NO_THROW(binding.Bind(learningModel.InputFeatures().First().Current().Name(), frame));
|
|
|
|
WINML_EXPECT_NO_THROW(session.Evaluate(binding, L""));
|
|
}
|
|
|
|
static void CloseModelNoNewSessions() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"model.onnx", learningModel));
|
|
WINML_EXPECT_NO_THROW(learningModel.Close());
|
|
LearningModelSession session = nullptr;
|
|
WINML_EXPECT_THROW_SPECIFIC(
|
|
session = LearningModelSession(learningModel),
|
|
winrt::hresult_error,
|
|
[](const winrt::hresult_error& e) -> bool { return e.code() == E_INVALIDARG; }
|
|
);
|
|
}
|
|
|
|
static void CheckMetadataCaseInsensitive() {
|
|
LearningModel learningModel = nullptr;
|
|
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"modelWithMetaData.onnx", learningModel));
|
|
IMapView metadata = learningModel.Metadata();
|
|
WINML_EXPECT_TRUE(metadata.HasKey(L"tHiSiSaLoNgKeY"));
|
|
WINML_EXPECT_EQUAL(metadata.Lookup(L"tHiSiSaLoNgKeY"), L"thisisalongvalue");
|
|
}
|
|
|
|
const LearningModelApiTestsApi& getapi() {
|
|
static LearningModelApiTestsApi api = {
|
|
LearningModelAPITestsClassSetup,
|
|
CreateModelFromFilePath,
|
|
CreateModelFromUnicodeFilePath,
|
|
CreateModelFileNotFound,
|
|
CreateModelFromIStorage,
|
|
CreateModelFromIStorageOutsideCwd,
|
|
CreateModelFromIStream,
|
|
ModelGetAuthor,
|
|
ModelGetName,
|
|
ModelGetDomain,
|
|
ModelGetDescription,
|
|
ModelGetVersion,
|
|
EnumerateInputs,
|
|
EnumerateOutputs,
|
|
CloseModelCheckMetadata,
|
|
CheckLearningModelPixelRange,
|
|
CloseModelCheckEval,
|
|
CloseModelNoNewSessions,
|
|
CheckMetadataCaseInsensitive,
|
|
CreateCorruptModel};
|
|
|
|
if (RuntimeParameterExists(L"noVideoFrameTests")) {
|
|
api.CloseModelCheckEval = SkipTest;
|
|
}
|
|
return api;
|
|
}
|