diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 58607a217f..bffba861c9 100755 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -285,7 +285,7 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home "-Donnxruntime_RUN_ONNX_TESTS=" + ("ON" if args.enable_onnx_tests else "OFF"), "-Donnxruntime_BUILD_WINML_TESTS=" + ("OFF" if args.skip_winml_tests else "ON"), "-Donnxruntime_GENERATE_TEST_REPORTS=ON", - "-Donnxruntime_DEV_MODE=" + ("OFF" if args.android or args.use_winml and not args.skip_winml_tests else "ON"), + "-Donnxruntime_DEV_MODE=" + ("OFF" if args.android else "ON"), "-DPYTHON_EXECUTABLE=" + sys.executable, "-Donnxruntime_USE_CUDA=" + ("ON" if args.use_cuda else "OFF"), "-Donnxruntime_USE_NSYNC=" + ("OFF" if is_windows() or not args.use_nsync else "ON"), diff --git a/winml/lib/Api/LearningModel.cpp b/winml/lib/Api/LearningModel.cpp index 1984612fd9..3a4e210cef 100644 --- a/winml/lib/Api/LearningModel.cpp +++ b/winml/lib/Api/LearningModel.cpp @@ -57,7 +57,7 @@ void LearningModel::Initialize() { WINML_THROW_IF_FAILED(adapter_->CreateModelInfo(model_proto_.get(), model_info_.put())); } -void LearningModel::LogCreationEvent(bool fromStream) { +void LearningModel::LogCreationEvent(bool /*fromStream*/) { auto input_descriptors = InputFeatures(); bool use_fp16 = false; for (auto descriptor : input_descriptors) { diff --git a/winml/test/common/protobufHelpers.cpp b/winml/test/common/protobufHelpers.cpp index 0870b43765..a5bc12a70e 100644 --- a/winml/test/common/protobufHelpers.cpp +++ b/winml/test/common/protobufHelpers.cpp @@ -1,325 +1,331 @@ -// LotusRT +#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS + +// LotusRT #include "core/framework/allocatormgr.h" -// #include "core/session/inference_session.h" #include "core/common/logging/logging.h" #include "core/common/logging/sinks/clog_sink.h" #include "protobufHelpers.h" + +#pragma warning(push) +#pragma warning(disable : 4100) #include "onnx/onnx-ml.pb.h" +#pragma warning(pop) + #include #include #include "winrt/Windows.Storage.Streams.h" -#pragma warning(disable : 4244) - using namespace winrt::Windows::Storage::Streams; using namespace winrt::Windows::AI::MachineLearning; using namespace winrt::Windows::Foundation::Collections; // Copy and pasted from LOTUS as is. temporary code to load tensors from protobufs -int FdOpen(const std::string& name) -{ - int fd = -1; +int FdOpen(const std::string& name) { + int fd = -1; #ifdef _WIN32 - _sopen_s(&fd, name.c_str(), _O_RDONLY | _O_SEQUENTIAL | _O_BINARY, _SH_DENYWR, _S_IREAD | _S_IWRITE); + _sopen_s(&fd, name.c_str(), _O_RDONLY | _O_SEQUENTIAL | _O_BINARY, _SH_DENYWR, _S_IREAD | _S_IWRITE); #else - fd = open(name.c_str(), O_RDONLY); + fd = open(name.c_str(), O_RDONLY); #endif - return fd; + return fd; }; // Copy and pasted from LOTUS as is. temporary code to load tensors from protobufs -void FdClose(int fd) -{ - if (fd >= 0) - { +void FdClose(int fd) { + if (fd >= 0) { #ifdef _WIN32 - _close(fd); + _close(fd); #else - close(fd); + close(fd); #endif - } + } } // Copy and pasted from LOTUS as is. temporary code to load tensors from protobufs -bool LoadTensorFromPb(onnx::TensorProto& tensor, std::wstring filePath) -{ - // setup a string converter - using convert_type = std::codecvt_utf8; - std::wstring_convert converter; +bool LoadTensorFromPb(onnx::TensorProto& tensor, std::wstring filePath) { + // setup a string converter + using convert_type = std::codecvt_utf8; + std::wstring_convert converter; - // use converter (.to_bytes: wstr->str, .from_bytes: str->wstr) - std::string file = converter.to_bytes(filePath.c_str()); + // use converter (.to_bytes: wstr->str, .from_bytes: str->wstr) + std::string file = converter.to_bytes(filePath.c_str()); - std::ifstream stream(file, std::ios::binary | std::ios::ate); - std::streamsize size = stream.tellg(); - stream.seekg(0, std::ios::beg); - - std::vector buffer(size); - if (stream.read(buffer.data(), size)) - { - return tensor.ParseFromArray(buffer.data(), static_cast(size)); - } - else - { - return false; - } + std::ifstream stream(file, std::ios::binary | std::ios::ate); + std::streamsize size = stream.tellg(); + stream.seekg(0, std::ios::beg); + std::vector buffer(size); + if (stream.read(buffer.data(), size)) { + return tensor.ParseFromArray(buffer.data(), static_cast(size)); + } else { + return false; + } } template -std::vector GetTensorDataFromTensorProto(onnx::TensorProto tensorProto, int elementCount) -{ - if (tensorProto.has_raw_data()) - { - std::vector tensorData; - auto& values = tensorProto.raw_data(); - EXPECT_EQ(elementCount, values.size() / sizeof(DataType)) << L"TensorProto elementcount should match raw data buffer size in elements."; - - tensorData = std::vector(elementCount); - memcpy(tensorData.data(), values.data(), values.size()); - return tensorData; - } - else - { - return std::vector(std::begin(tensorProto.float_data()), std::end(tensorProto.float_data())); - } +std::vector GetTypeSpecificDataFromTensorProto( + onnx::TensorProto /*tensorProto*/){ + static_assert(false, "UNDEFINED! TensorProto methods aren't templated, so add a new template specialization."); +} +template <> +std::vector GetTypeSpecificDataFromTensorProto( + onnx::TensorProto tensorProto){ + return std::vector(std::begin(tensorProto.float_data()), std::end(tensorProto.float_data())); +} +template <> +std::vector GetTypeSpecificDataFromTensorProto( + onnx::TensorProto tensorProto){ + return std::vector(std::begin(tensorProto.int32_data()), std::end(tensorProto.int32_data())); +} +template <> +std::vector GetTypeSpecificDataFromTensorProto( + onnx::TensorProto tensorProto){ + return std::vector(std::begin(tensorProto.int64_data()), std::end(tensorProto.int64_data())); } -static -std::vector GetTensorStringDataFromTensorProto( +template +std::vector GetTensorDataFromTensorProto( + onnx::TensorProto tensorProto, + uint64_t elementCount) { + if (tensorProto.has_raw_data()) { + std::vector tensorData; + auto& values = tensorProto.raw_data(); + EXPECT_EQ(elementCount, values.size() / sizeof(DataType)) << L"TensorProto elementcount should match raw data buffer size in elements."; + + tensorData = std::vector(elementCount); + memcpy(tensorData.data(), values.data(), values.size()); + return tensorData; + } else { + return GetTypeSpecificDataFromTensorProto(tensorProto); + } +} + +static std::vector GetTensorStringDataFromTensorProto( onnx::TensorProto tensorProto, - int elementCount) -{ - EXPECT_EQ(tensorProto.string_data_size(), elementCount); - auto& values = tensorProto.string_data(); - auto returnVector = std::vector(elementCount); - std::transform(std::begin(values), std::end(values), std::begin(returnVector), - [](auto& value) { return winrt::to_hstring(value); }); - return returnVector; + uint64_t elementCount) { + EXPECT_EQ(tensorProto.string_data_size(), elementCount); + auto& values = tensorProto.string_data(); + auto returnVector = std::vector(elementCount); + std::transform(std::begin(values), std::end(values), std::begin(returnVector), + [](auto& value) { return winrt::to_hstring(value); }); + return returnVector; } ITensor ProtobufHelpers::LoadTensorFromProtobufFile( const std::wstring& filePath, - bool isFp16) -{ - // load from the file path into the onnx format - onnx::TensorProto tensorProto; - if (LoadTensorFromPb(tensorProto, filePath)) - { - std::vector tensorShape = std::vector(tensorProto.dims().begin(), tensorProto.dims().end()); - int64_t initialValue = 1; - auto elementCount = std::accumulate(tensorShape.begin(), tensorShape.end(), initialValue, std::multiplies()); + bool isFp16) { + // load from the file path into the onnx format + onnx::TensorProto tensorProto; + if (LoadTensorFromPb(tensorProto, filePath)) { + std::vector tensorShape = std::vector(tensorProto.dims().begin(), tensorProto.dims().end()); + int64_t initialValue = 1; + int64_t elementCount = std::accumulate(tensorShape.begin(), tensorShape.end(), initialValue, std::multiplies()); - if (!tensorProto.has_data_type()) - { - std::cerr << "WARNING: Loading unknown TensorProto datatype.\n"; - } - if (isFp16) - { - return TensorFloat16Bit::CreateFromIterable(tensorShape, GetTensorDataFromTensorProto(tensorProto, elementCount)); - } - switch (tensorProto.data_type()) - { - case(onnx::TensorProto::DataType::TensorProto_DataType_FLOAT): - return TensorFloat::CreateFromIterable(tensorShape, GetTensorDataFromTensorProto(tensorProto, elementCount)); - case(onnx::TensorProto::DataType::TensorProto_DataType_INT32): - return TensorInt32Bit::CreateFromIterable(tensorShape, GetTensorDataFromTensorProto(tensorProto, elementCount)); - case(onnx::TensorProto::DataType::TensorProto_DataType_INT64): - return TensorInt64Bit::CreateFromIterable(tensorShape, GetTensorDataFromTensorProto(tensorProto, elementCount)); - case(onnx::TensorProto::DataType::TensorProto_DataType_STRING): - return TensorString::CreateFromIterable(tensorShape, GetTensorStringDataFromTensorProto(tensorProto, elementCount)); - default: - ADD_FAILURE() << L"Tensor type for creating tensor from protobuf file not supported."; - break; - } + if (!tensorProto.has_data_type()) { + std::cerr << "WARNING: Loading unknown TensorProto datatype.\n"; } - return nullptr; + if (isFp16) { + return TensorFloat16Bit::CreateFromIterable(tensorShape, GetTensorDataFromTensorProto(tensorProto, elementCount)); + } + switch (tensorProto.data_type()) { + case (onnx::TensorProto::DataType::TensorProto_DataType_FLOAT): + return TensorFloat::CreateFromIterable(tensorShape, GetTensorDataFromTensorProto(tensorProto, elementCount)); + case (onnx::TensorProto::DataType::TensorProto_DataType_INT32): + return TensorInt32Bit::CreateFromIterable(tensorShape, GetTensorDataFromTensorProto(tensorProto, elementCount)); + case (onnx::TensorProto::DataType::TensorProto_DataType_INT64): + return TensorInt64Bit::CreateFromIterable(tensorShape, GetTensorDataFromTensorProto(tensorProto, elementCount)); + case (onnx::TensorProto::DataType::TensorProto_DataType_STRING): + return TensorString::CreateFromIterable(tensorShape, GetTensorStringDataFromTensorProto(tensorProto, elementCount)); + default: + ADD_FAILURE() << L"Tensor type for creating tensor from protobuf file not supported."; + break; + } + } + return nullptr; } TensorFloat16Bit ProtobufHelpers::LoadTensorFloat16FromProtobufFile( - const std::wstring& filePath) -{ - // load from the file path into the onnx format - onnx::TensorProto tensorProto; - if (LoadTensorFromPb(tensorProto, filePath)) - { - if (tensorProto.has_data_type()) - { - EXPECT_EQ(onnx::TensorProto::DataType::TensorProto_DataType_FLOAT16, tensorProto.data_type()); - } - else - { - std::cerr << "Loading unknown TensorProto datatype as TensorFloat16Bit.\n"; - } - - auto shape = winrt::single_threaded_vector(std::vector(tensorProto.dims().begin(), tensorProto.dims().end())); - TensorFloat16Bit singleTensorValue = TensorFloat16Bit::Create(shape.GetView()); - - uint16_t* data; - winrt::com_ptr spTensorValueNative; - singleTensorValue.as(spTensorValueNative); - uint32_t sizeInBytes; - spTensorValueNative->GetBuffer(reinterpret_cast(&data), &sizeInBytes); - - EXPECT_TRUE(tensorProto.has_raw_data()) << L"Float16 tensor proto buffers are expected to contain raw data."; - - auto& raw_data = tensorProto.raw_data(); - auto buff = raw_data.c_str(); - const size_t type_size = sizeof(uint16_t); - - memcpy((void*)data, (void*)buff, raw_data.size() * sizeof(char)); - - return singleTensorValue; + const std::wstring& filePath) { + // load from the file path into the onnx format + onnx::TensorProto tensorProto; + if (LoadTensorFromPb(tensorProto, filePath)) { + if (tensorProto.has_data_type()) { + EXPECT_EQ(onnx::TensorProto::DataType::TensorProto_DataType_FLOAT16, tensorProto.data_type()); + } else { + std::cerr << "Loading unknown TensorProto datatype as TensorFloat16Bit.\n"; } - return nullptr; + + auto shape = winrt::single_threaded_vector(std::vector(tensorProto.dims().begin(), tensorProto.dims().end())); + TensorFloat16Bit singleTensorValue = TensorFloat16Bit::Create(shape.GetView()); + + uint16_t* data; + winrt::com_ptr spTensorValueNative; + singleTensorValue.as(spTensorValueNative); + uint32_t sizeInBytes; + spTensorValueNative->GetBuffer(reinterpret_cast(&data), &sizeInBytes); + + EXPECT_TRUE(tensorProto.has_raw_data()) << L"Float16 tensor proto buffers are expected to contain raw data."; + + auto& raw_data = tensorProto.raw_data(); + auto buff = raw_data.c_str(); + const size_t type_size = sizeof(uint16_t); + + memcpy((void*)data, (void*)buff, raw_data.size() * sizeof(char)); + + return singleTensorValue; + } + return nullptr; } winrt::Windows::AI::MachineLearning::LearningModel ProtobufHelpers::CreateModel( winrt::Windows::AI::MachineLearning::TensorKind kind, const std::vector& shape, - uint32_t num_elements) -{ - onnx::ModelProto model; - model.set_ir_version(onnx::Version::IR_VERSION); + uint32_t num_elements) { + onnx::ModelProto model; + model.set_ir_version(onnx::Version::IR_VERSION); - // Set opset import - auto opsetimportproto = model.add_opset_import(); - opsetimportproto->set_version(7); + // Set opset import + auto opsetimportproto = model.add_opset_import(); + opsetimportproto->set_version(7); - onnx::GraphProto& graph = *model.mutable_graph(); + onnx::GraphProto& graph = *model.mutable_graph(); - uint32_t begin = 0; - uint32_t end = num_elements - 1; - for (uint32_t i = begin; i <= end; i++) - { - onnx::NodeProto& node = *graph.add_node(); - node.set_op_type("Identity"); - if (i == begin && i == end) - { - node.add_input("input"); - node.add_output("output"); - } - else if (i == begin) - { - node.add_input("input"); - node.add_output("output" + std::to_string(i)); + uint32_t begin = 0; + uint32_t end = num_elements - 1; + for (uint32_t i = begin; i <= end; i++) { + onnx::NodeProto& node = *graph.add_node(); + node.set_op_type("Identity"); + if (i == begin && i == end) { + node.add_input("input"); + node.add_output("output"); + } else if (i == begin) { + node.add_input("input"); + node.add_output("output" + std::to_string(i)); - } - else if (i == end) - { - node.add_input("output" + std::to_string(i-1)); - node.add_output("output"); - } - else - { - node.add_input("output" + std::to_string(i-1)); - node.add_output("output" + std::to_string(i)); - } + } else if (i == end) { + node.add_input("output" + std::to_string(i - 1)); + node.add_output("output"); + } else { + node.add_input("output" + std::to_string(i - 1)); + node.add_output("output" + std::to_string(i)); } + } - onnx::TensorProto_DataType dataType; - switch (kind) - { - case TensorKind::Float: dataType = onnx::TensorProto_DataType_FLOAT; break; - case TensorKind::UInt8: dataType = onnx::TensorProto_DataType_UINT8; break; - case TensorKind::Int8: dataType = onnx::TensorProto_DataType_INT8; break; - case TensorKind::UInt16: dataType = onnx::TensorProto_DataType_UINT16; break; - case TensorKind::Int16: dataType = onnx::TensorProto_DataType_INT16; break; - case TensorKind::Int32: dataType = onnx::TensorProto_DataType_INT32; break; - case TensorKind::Int64: dataType = onnx::TensorProto_DataType_INT64; break; - case TensorKind::String: dataType = onnx::TensorProto_DataType_STRING; break; - case TensorKind::Boolean: dataType = onnx::TensorProto_DataType_BOOL; break; - case TensorKind::Float16: dataType = onnx::TensorProto_DataType_FLOAT16; break; - case TensorKind::Double: dataType = onnx::TensorProto_DataType_DOUBLE; break; - case TensorKind::UInt32: dataType = onnx::TensorProto_DataType_UINT32; break; - case TensorKind::UInt64: dataType = onnx::TensorProto_DataType_UINT64; break; + onnx::TensorProto_DataType dataType; + switch (kind) { + case TensorKind::Float: + dataType = onnx::TensorProto_DataType_FLOAT; + break; + case TensorKind::UInt8: + dataType = onnx::TensorProto_DataType_UINT8; + break; + case TensorKind::Int8: + dataType = onnx::TensorProto_DataType_INT8; + break; + case TensorKind::UInt16: + dataType = onnx::TensorProto_DataType_UINT16; + break; + case TensorKind::Int16: + dataType = onnx::TensorProto_DataType_INT16; + break; + case TensorKind::Int32: + dataType = onnx::TensorProto_DataType_INT32; + break; + case TensorKind::Int64: + dataType = onnx::TensorProto_DataType_INT64; + break; + case TensorKind::String: + dataType = onnx::TensorProto_DataType_STRING; + break; + case TensorKind::Boolean: + dataType = onnx::TensorProto_DataType_BOOL; + break; + case TensorKind::Float16: + dataType = onnx::TensorProto_DataType_FLOAT16; + break; + case TensorKind::Double: + dataType = onnx::TensorProto_DataType_DOUBLE; + break; + case TensorKind::UInt32: + dataType = onnx::TensorProto_DataType_UINT32; + break; + case TensorKind::UInt64: + dataType = onnx::TensorProto_DataType_UINT64; + break; default: - return nullptr; + return nullptr; + } + + char dim_param = 'a'; + // input + { + onnx::ValueInfoProto& variable = *graph.add_input(); + variable.set_name("input"); + variable.mutable_type()->mutable_tensor_type()->set_elem_type(dataType); + for (auto dim : shape) { + if (dim == -1) { + variable.mutable_type()->mutable_tensor_type()->mutable_shape()->add_dim()->set_dim_param(&dim_param, 1); + dim_param++; + } else { + variable.mutable_type()->mutable_tensor_type()->mutable_shape()->add_dim()->set_dim_value(dim); + } } - char dim_param = 'a'; - // input - { - onnx::ValueInfoProto& variable = *graph.add_input(); - variable.set_name("input"); - //onnx::TypeProto_Tensor* pTensor = variable.mutable_type()->mutable_tensor_type(); - variable.mutable_type()->mutable_tensor_type()->set_elem_type(dataType); - for (auto dim : shape) - { - if (dim == -1) - { - variable.mutable_type()->mutable_tensor_type()->mutable_shape()->add_dim()->set_dim_param(&dim_param, 1); - dim_param++; - } - else - { - variable.mutable_type()->mutable_tensor_type()->mutable_shape()->add_dim()->set_dim_value(dim); - } - } + if (shape.size() > 0) { + variable.mutable_type()->mutable_tensor_type()->mutable_shape()->mutable_dim(0)->set_denotation("DATA_BATCH"); + } + } - if (shape.size() > 0) - { - variable.mutable_type()->mutable_tensor_type()->mutable_shape()->mutable_dim(0)->set_denotation("DATA_BATCH"); - } + // output + { + onnx::ValueInfoProto& variable = *graph.add_output(); + variable.set_name("output"); + variable.mutable_type()->mutable_tensor_type()->set_elem_type(dataType); + for (auto dim : shape) { + if (dim == -1) { + variable.mutable_type()->mutable_tensor_type()->mutable_shape()->add_dim()->set_dim_param(&dim_param, 1); + dim_param++; + } else { + variable.mutable_type()->mutable_tensor_type()->mutable_shape()->add_dim()->set_dim_value(dim); + } + } + } + + struct BufferStreamAdapter : public std::streambuf { + RandomAccessStreamReference BufferAsRandomAccessStreamReference() { + auto buffer = m_dataWriter.DetachBuffer(); + m_dataWriter = DataWriter(); + + InMemoryRandomAccessStream stream; + stream.WriteAsync(buffer).get(); + return RandomAccessStreamReference::CreateFromStream(stream); } - // output - { - onnx::ValueInfoProto& variable = *graph.add_output(); - variable.set_name("output"); - //onnx::TypeProto_Tensor* pTensor = variable.mutable_type()->mutable_tensor_type(); - variable.mutable_type()->mutable_tensor_type()->set_elem_type(dataType); - for (auto dim : shape) - { - if (dim == -1) - { - variable.mutable_type()->mutable_tensor_type()->mutable_shape()->add_dim()->set_dim_param(&dim_param, 1); - dim_param++; - } - else - { - variable.mutable_type()->mutable_tensor_type()->mutable_shape()->add_dim()->set_dim_value(dim); - } - } + protected: + virtual int_type overflow(int_type c) { + if (c != EOF) { + // convert lowercase to uppercase + auto temp = static_cast(c); + + m_dataWriter.WriteByte(temp); + } + return c; } - struct BufferStreamAdapter : public std::streambuf - { - RandomAccessStreamReference BufferAsRandomAccessStreamReference() - { - auto buffer = m_dataWriter.DetachBuffer(); - m_dataWriter = DataWriter(); + private: + DataWriter m_dataWriter; + }; - InMemoryRandomAccessStream stream; - stream.WriteAsync(buffer).get(); - return RandomAccessStreamReference::CreateFromStream(stream); - } + auto size = model.ByteSize(); + auto raw_array = std::unique_ptr(new char[size]); + model.SerializeToArray(raw_array.get(), size); - protected: - virtual int_type overflow(int_type c) { - if (c != EOF) { - // convert lowercase to uppercase - auto temp = static_cast(c); + BufferStreamAdapter buffer; + std::ostream os(&buffer); - m_dataWriter.WriteByte(temp); - } - return c; - } + os.write(raw_array.get(), size); - private: - DataWriter m_dataWriter; - }; - - auto size = model.ByteSize(); - auto raw_array = std::unique_ptr(new char[size]); - model.SerializeToArray(raw_array.get(), size); - - BufferStreamAdapter buffer; - std::ostream os(&buffer); - - os.write(raw_array.get(), size); - - return LearningModel::LoadFromStream(buffer.BufferAsRandomAccessStreamReference()); + return LearningModel::LoadFromStream(buffer.BufferAsRandomAccessStreamReference()); } diff --git a/winml/test/scenario/cppwinrt/scenariotestscppwinrt.cpp b/winml/test/scenario/cppwinrt/scenariotestscppwinrt.cpp index e3454f5d6f..c4dab13598 100644 --- a/winml/test/scenario/cppwinrt/scenariotestscppwinrt.cpp +++ b/winml/test/scenario/cppwinrt/scenariotestscppwinrt.cpp @@ -111,7 +111,7 @@ ILearningModelFeatureValue MakeTensor(const ITensorFeatureDescriptor& descriptor } } -ILearningModelFeatureValue MakeImage(const IImageFeatureDescriptor& descriptor, winrt::Windows::Foundation::IInspectable data) +ILearningModelFeatureValue MakeImage(const IImageFeatureDescriptor& /*descriptor*/, winrt::Windows::Foundation::IInspectable data) { VideoFrame videoFrame = nullptr; if (data != nullptr) @@ -577,7 +577,10 @@ TEST_F(ScenarioCppWinrtGpuTest, DISABLED_Scenario9_LoadBindEval_InputTensorGPU) auto outputtensordescriptor = model.OutputFeatures().First().Current().as(); auto outputtensorshape = outputtensordescriptor.Shape(); - VideoFrame outputimage(BitmapPixelFormat::Rgba8, outputtensorshape.GetAt(3), outputtensorshape.GetAt(2)); + VideoFrame outputimage( + BitmapPixelFormat::Rgba8, + static_cast(outputtensorshape.GetAt(3)), + static_cast(outputtensorshape.GetAt(2))); ImageFeatureValue outputTensor = ImageFeatureValue::CreateFromVideoFrame(outputimage); EXPECT_NO_THROW(modelBinding.Bind(model.OutputFeatures().First().Current().Name(), outputTensor)); @@ -920,7 +923,10 @@ TEST_F(ScenarioCppWinrtTest, DISABLED_Scenario22_ImageBindingAsCPUTensor) // Bind output auto outputtensordescriptor = model.OutputFeatures().First().Current().as(); auto outputtensorshape = outputtensordescriptor.Shape(); - VideoFrame outputimage(BitmapPixelFormat::Bgra8, outputtensorshape.GetAt(3), outputtensorshape.GetAt(2)); + VideoFrame outputimage( + BitmapPixelFormat::Bgra8, + static_cast(outputtensorshape.GetAt(3)), + static_cast(outputtensorshape.GetAt(2))); ImageFeatureValue outputTensor = ImageFeatureValue::CreateFromVideoFrame(outputimage); EXPECT_NO_THROW(binding.Bind(model.OutputFeatures().First().Current().Name(), outputTensor)); @@ -1061,10 +1067,12 @@ TEST_F(ScenarioCppWinrtGpuTest, DISABLED_Scenario22_ImageBindingAsGPUTensor) ); // Create the GPU upload buffer. + CD3DX12_HEAP_PROPERTIES props(D3D12_HEAP_TYPE_UPLOAD); + auto buffer = CD3DX12_RESOURCE_DESC::Buffer(bufferbytesize); EXPECT_NO_THROW(pD3D12Device->CreateCommittedResource( - &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD), + &props, D3D12_HEAP_FLAG_NONE, - &CD3DX12_RESOURCE_DESC::Buffer(bufferbytesize), + &buffer, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, __uuidof(ID3D12Resource), @@ -1094,7 +1102,10 @@ TEST_F(ScenarioCppWinrtGpuTest, DISABLED_Scenario22_ImageBindingAsGPUTensor) auto outputtensordescriptor = model.OutputFeatures().First().Current().as(); auto outputtensorshape = outputtensordescriptor.Shape(); - VideoFrame outputimage(BitmapPixelFormat::Rgba8, outputtensorshape.GetAt(3), outputtensorshape.GetAt(2)); + VideoFrame outputimage( + BitmapPixelFormat::Rgba8, + static_cast(outputtensorshape.GetAt(3)), + static_cast(outputtensorshape.GetAt(2))); ImageFeatureValue outputTensor = ImageFeatureValue::CreateFromVideoFrame(outputimage); EXPECT_NO_THROW(modelBinding.Bind(model.OutputFeatures().First().Current().Name(), outputTensor)); @@ -1195,7 +1206,10 @@ TEST_F(ScenarioCppWinrtGpuTest, DISABLED_SyncVsAsync) auto outputtensordescriptor = model.OutputFeatures().First().Current().as(); auto outputtensorshape = outputtensordescriptor.Shape(); - VideoFrame outputimage(BitmapPixelFormat::Rgba8, outputtensorshape.GetAt(3), outputtensorshape.GetAt(2)); + VideoFrame outputimage( + BitmapPixelFormat::Rgba8, + static_cast(outputtensorshape.GetAt(3)), + static_cast(outputtensorshape.GetAt(2))); ImageFeatureValue outputTensor = ImageFeatureValue::CreateFromVideoFrame(outputimage); EXPECT_NO_THROW(modelBinding.Bind(model.OutputFeatures().First().Current().Name(), outputTensor)); @@ -1218,7 +1232,9 @@ TEST_F(ScenarioCppWinrtGpuTest, DISABLED_SyncVsAsync) bindings[i].Bind(inputFeatureDescriptor.Current().Name(), imagetensor); bindings[i].Bind( model.OutputFeatures().First().Current().Name(), - VideoFrame(BitmapPixelFormat::Rgba8, outputtensorshape.GetAt(3), outputtensorshape.GetAt(2))); + VideoFrame(BitmapPixelFormat::Rgba8, + static_cast(outputtensorshape.GetAt(3)), + static_cast(outputtensorshape.GetAt(2)))); } auto startAsync = std::chrono::high_resolution_clock::now(); @@ -1285,7 +1301,10 @@ TEST_F(ScenarioCppWinrtGpuTest, DISABLED_CustomCommandQueueWithFence) auto outputtensordescriptor = model.OutputFeatures().First().Current().as(); auto outputtensorshape = outputtensordescriptor.Shape(); - VideoFrame outputimage(BitmapPixelFormat::Rgba8, outputtensorshape.GetAt(3), outputtensorshape.GetAt(2)); + VideoFrame outputimage( + BitmapPixelFormat::Rgba8, + static_cast(outputtensorshape.GetAt(3)), + static_cast(outputtensorshape.GetAt(2))); ImageFeatureValue outputTensor = ImageFeatureValue::CreateFromVideoFrame(outputimage); EXPECT_NO_THROW(modelBinding.Bind(model.OutputFeatures().First().Current().Name(), outputTensor)); @@ -1420,7 +1439,7 @@ TEST_F(ScenarioCppWinrtTest, EncryptedStream) LearningModel model = nullptr; EXPECT_NO_THROW(model = LearningModel::LoadFromStream(RandomAccessStreamReference::CreateFromStream(decryptedStream))); LearningModelSession session = nullptr; - EXPECT_NO_THROW(auto session = LearningModelSession(model)); + EXPECT_NO_THROW(session = LearningModelSession(model)); } TEST_F(ScenarioCppWinrtGpuTest, DeviceLostRecovery)