Add DXResourceBinding sample
This commit is contained in:
Родитель
70c1ff3b45
Коммит
99ed044bfd
|
@ -40,6 +40,9 @@ namespace WinMLSamplesGallery
|
|||
case "AdapterSelection":
|
||||
SampleFrame.Navigate(typeof(Samples.AdapterSelection));
|
||||
break;
|
||||
case "DXResourceBindingORT":
|
||||
SampleFrame.Navigate(typeof(Samples.DXResourceBindingORT));
|
||||
break;
|
||||
}
|
||||
if (sampleMetadata.Docs.Count > 0)
|
||||
DocsHeader.Visibility = Visibility.Visible;
|
||||
|
|
|
@ -82,6 +82,17 @@
|
|||
"CSharpGithubLink": "https://github.com/microsoft/Windows-Machine-Learning/blob/master/Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/AdapterSelection/AdapterSelection.xaml.cs",
|
||||
"Docs": [],
|
||||
"IsRecentlyAdded": true
|
||||
},
|
||||
{
|
||||
"Title": "DX Resource Binding in ORT",
|
||||
"DescriptionShort": "Learn how to bind DirectX Resources using ONNX Runtime",
|
||||
"Description": "The sample showcases how to create and bind OrtValue objects from ID3D12 Resources using the ONNX Runtime C-API.",
|
||||
"Icon": "\uE155",
|
||||
"Tag": "DXResourceBindingORT",
|
||||
"XAMLGithubLink": "https://github.com/microsoft/Windows-Machine-Learning/blob/master/Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/AdapterSelection/AdapterSelection.xaml",
|
||||
"CSharpGithubLink": "https://github.com/microsoft/Windows-Machine-Learning/blob/master/Samples/WinMLSamplesGallery/WinMLSamplesGallery/Samples/AdapterSelection/AdapterSelection.xaml.cs",
|
||||
"Docs": [],
|
||||
"IsRecentlyAdded": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<Page
|
||||
x:Class="WinMLSamplesGallery.Samples.DXResourceBindingORT"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local_controls="using:WinMLSamplesGallery.Controls"
|
||||
xmlns:local_samples="using:WinMLSamplesGallery.Samples"
|
||||
mc:Ignorable="d"
|
||||
FontFamily="Arial">
|
||||
|
||||
<Page.Resources>
|
||||
</Page.Resources>
|
||||
|
||||
<StackPanel>
|
||||
<TextBlock>Hello world</TextBlock>
|
||||
</StackPanel>
|
||||
</Page>
|
|
@ -0,0 +1,25 @@
|
|||
using Microsoft.AI.MachineLearning;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Graphics.Imaging;
|
||||
using Windows.Media;
|
||||
using Windows.Storage;
|
||||
using WinMLSamplesGalleryNative;
|
||||
|
||||
namespace WinMLSamplesGallery.Samples
|
||||
{
|
||||
public sealed partial class DXResourceBindingORT : Page
|
||||
{
|
||||
public DXResourceBindingORT()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
System.Diagnostics.Debug.WriteLine("Hello I'm in this sample");
|
||||
WinMLSamplesGalleryNative.DXResourceBinding.BindDXResourcesUsingORT();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@
|
|||
<None Remove="SamplesGrid.xaml" />
|
||||
<None Remove="SampleBasePage.xaml" />
|
||||
<None Remove="Image.xaml" />
|
||||
<None Remove="Samples\DXResourceBindingORT\DXResourceBindingORT.xaml" />
|
||||
<None Remove="Samples\ImageClassifier.xaml" />
|
||||
<None Remove="Samples\ImageEffects.xaml" />
|
||||
<None Remove="Samples\ObjectDetector\ObjectDetector.xaml" />
|
||||
|
@ -163,6 +164,12 @@
|
|||
<Folder Include="Samples\AdapterSelection\Docs\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Update="Samples\DXResourceBindingORT\DXResourceBindingORT.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="DownloadContentFiles" BeforeTargets="BeforeBuild">
|
||||
<!-- Small models. These models get shipped in the store app by default. -->
|
||||
<DownloadFile Condition="!Exists('$(MSBuildProjectDirectory)\Models\densenet-9.onnx')" SourceUrl="https://github.com/onnx/models/blob/main/vision/classification/densenet-121/model/densenet-9.onnx?raw=true" DestinationFolder="$(MSBuildProjectDirectory)\Models">
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AI.MachineLearning" Version="1.9.1" />
|
||||
<PackageReference Include="Microsoft.ML.OnnxRuntime.DirectML" Version="1.10.0" />
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="1.3.5" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -0,0 +1,352 @@
|
|||
#define NOMINMAX
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include "pch.h"
|
||||
#include "DXResourceBinding.h"
|
||||
#include "DXResourceBinding.g.cpp"
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
#include <string_view>
|
||||
#include <span>
|
||||
#include <optional>
|
||||
#include <memory>
|
||||
|
||||
#include <windows.h>
|
||||
#include <d3d12.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
// Specifying the path so as not to include the Microsoft.AI.MachineLearning version of
|
||||
// these files
|
||||
#include "..\packages\Microsoft.ML.OnnxRuntime.DirectML.1.10.0\build\native\include\dml_provider_factory.h"
|
||||
#include "..\packages\Microsoft.ML.OnnxRuntime.DirectML.1.10.0\build\native\include\onnxruntime_cxx_api.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define THROW_IF_FAILED(hr) {HRESULT localHr = (hr); if (FAILED(hr)) throw hr;}
|
||||
#define RETURN_IF_FAILED(hr) {HRESULT localHr = (hr); if (FAILED(hr)) return hr;}
|
||||
#define THROW_IF_NOT_OK(status) {auto localStatus = (status); if (localStatus) throw E_FAIL;}
|
||||
#define RETURN_HR_IF_NOT_OK(status) {auto localStatus = (status); if (localStatus) return E_FAIL;}
|
||||
|
||||
template <typename T>
|
||||
using BaseType =
|
||||
std::remove_cv_t<
|
||||
std::remove_reference_t<
|
||||
std::remove_pointer_t<
|
||||
std::remove_all_extents_t<T>
|
||||
>
|
||||
>
|
||||
>;
|
||||
|
||||
template<typename T>
|
||||
using deleting_unique_ptr = std::unique_ptr<T, std::function<void(T*)>>;
|
||||
|
||||
template <typename C, typename T = BaseType<decltype(*std::declval<C>().data())>>
|
||||
T GetElementCount(C const& range)
|
||||
{
|
||||
return std::accumulate(range.begin(), range.end(), static_cast<T>(1), std::multiplies<T>());
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Ort::Value CreateTensorValueUsingD3DResource(
|
||||
// ID3D12Device* d3dDevice,
|
||||
// OrtDmlApi const& ortDmlApi,
|
||||
// Ort::MemoryInfo const& memoryInformation,
|
||||
// std::span<const int64_t> dimensions,
|
||||
// ONNXTensorElementDataType elementDataType,
|
||||
// size_t elementByteSize,
|
||||
// /*out*/ void** dmlEpResourceWrapper
|
||||
//);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace winrt::WinMLSamplesGalleryNative::implementation
|
||||
{
|
||||
int DXResourceBinding::BindDXResourcesUsingORT() {
|
||||
const wchar_t* modelFilePath = L"../WinMLSamplesGallery/models/squeezenet1.1-7.onnx";
|
||||
const char* modelInputTensorName = "data";
|
||||
const char* modelOutputTensorName = "squeezenet0_flatten0_reshape0";
|
||||
const std::array<int64_t, 4> inputShape = { 1, 3, 224, 224 };
|
||||
const std::array<int64_t, 2> outputShape = { 1, 1000 };
|
||||
|
||||
const bool passTensorsAsD3DResources = true;
|
||||
|
||||
LARGE_INTEGER startTime;
|
||||
LARGE_INTEGER d3dDeviceCreationTime;
|
||||
LARGE_INTEGER sessionCreationTime;
|
||||
LARGE_INTEGER tensorCreationTime;
|
||||
LARGE_INTEGER bindingTime;
|
||||
LARGE_INTEGER runTime;
|
||||
LARGE_INTEGER synchronizeOutputsTime;
|
||||
LARGE_INTEGER cpuFrequency;
|
||||
QueryPerformanceFrequency(&cpuFrequency);
|
||||
QueryPerformanceCounter(&startTime);
|
||||
|
||||
try
|
||||
{
|
||||
winrt::com_ptr<ID3D12Device> d3d12Device;
|
||||
THROW_IF_FAILED(D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&d3d12Device)));
|
||||
QueryPerformanceCounter(&d3dDeviceCreationTime);
|
||||
|
||||
OrtApi const& ortApi = Ort::GetApi(); // Uses ORT_API_VERSION
|
||||
const OrtDmlApi* ortDmlApi;
|
||||
THROW_IF_NOT_OK(ortApi.GetExecutionProviderApi("DML", ORT_API_VERSION, reinterpret_cast<const void**>(&ortDmlApi)));
|
||||
|
||||
// ONNX Runtime setup
|
||||
Ort::Env ortEnvironment(ORT_LOGGING_LEVEL_WARNING, "DirectML_Direct3D_TensorAllocation_Test");
|
||||
Ort::SessionOptions sessionOptions;
|
||||
sessionOptions.SetExecutionMode(ExecutionMode::ORT_SEQUENTIAL);
|
||||
sessionOptions.DisableMemPattern();
|
||||
sessionOptions.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_ALL);
|
||||
ortApi.AddFreeDimensionOverrideByName(sessionOptions, "batch_size", 1);
|
||||
OrtSessionOptionsAppendExecutionProvider_DML(sessionOptions, 0);
|
||||
Ort::Session session = Ort::Session(ortEnvironment, modelFilePath, sessionOptions);
|
||||
QueryPerformanceCounter(&sessionCreationTime);
|
||||
|
||||
Ort::IoBinding ioBinding = Ort::IoBinding::IoBinding(session);
|
||||
const char* memoryInformationName = passTensorsAsD3DResources ? "DML" : "Cpu";
|
||||
Ort::MemoryInfo memoryInformation(memoryInformationName, OrtAllocatorType::OrtDeviceAllocator, 0, OrtMemType::OrtMemTypeDefault);
|
||||
// Not needed: Ort::Allocator allocator(session, memoryInformation);
|
||||
|
||||
// Create input tensor.
|
||||
Ort::Value inputTensor(nullptr);
|
||||
std::vector<float> inputTensorValues(static_cast<size_t>(GetElementCount(inputShape)), 0.0f);
|
||||
std::iota(inputTensorValues.begin(), inputTensorValues.end(), 0.0f);
|
||||
winrt::com_ptr<IUnknown> inputTensorEpWrapper;
|
||||
|
||||
if (passTensorsAsD3DResources)
|
||||
{
|
||||
// Create empty D3D resource for input.
|
||||
inputTensor = CreateTensorValueUsingD3DResource(
|
||||
d3d12Device.get(),
|
||||
*ortDmlApi,
|
||||
memoryInformation,
|
||||
inputShape,
|
||||
ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT,
|
||||
sizeof(float),
|
||||
/*out*/ IID_PPV_ARGS_Helper(inputTensorEpWrapper.put())
|
||||
);
|
||||
}
|
||||
else // CPU tensor
|
||||
{
|
||||
inputTensor = Ort::Value::CreateTensor<float>(memoryInformation, inputTensorValues.data(), inputTensorValues.size(), inputShape.data(), 4);
|
||||
}
|
||||
|
||||
// Create output tensor on device memory.
|
||||
Ort::Value outputTensor(nullptr);
|
||||
std::vector<float> outputTensorValues(static_cast<size_t>(GetElementCount(outputShape)), 0.0f);
|
||||
winrt::com_ptr<IUnknown> outputTensorEpWrapper;
|
||||
|
||||
if (passTensorsAsD3DResources)
|
||||
{
|
||||
outputTensor = CreateTensorValueUsingD3DResource(
|
||||
d3d12Device.get(),
|
||||
*ortDmlApi,
|
||||
memoryInformation,
|
||||
outputShape,
|
||||
ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT,
|
||||
sizeof(float),
|
||||
/*out*/ IID_PPV_ARGS_Helper(outputTensorEpWrapper.put())
|
||||
);
|
||||
}
|
||||
else // CPU tensor
|
||||
{
|
||||
outputTensor = Ort::Value::CreateTensor<float>(memoryInformation, outputTensorValues.data(), outputTensorValues.size(), outputShape.data(), 4);
|
||||
}
|
||||
|
||||
QueryPerformanceCounter(&tensorCreationTime);
|
||||
|
||||
////////////////////////////////////////
|
||||
// Bind the tensor inputs to the model, and run it.
|
||||
ioBinding.BindInput(modelInputTensorName, inputTensor);
|
||||
ioBinding.BindOutput(modelOutputTensorName, outputTensor);
|
||||
ioBinding.SynchronizeInputs();
|
||||
QueryPerformanceCounter(&bindingTime);
|
||||
|
||||
Ort::RunOptions runOptions;
|
||||
|
||||
// TODO: Upload inputTensorValues to GPU inputTensor.
|
||||
|
||||
printf("Beginning execution.\n");
|
||||
printf("Running Session.\n");
|
||||
session.Run(runOptions, ioBinding);
|
||||
QueryPerformanceCounter(&runTime);
|
||||
printf("Synchronizing outputs.\n");
|
||||
ioBinding.SynchronizeOutputs();
|
||||
QueryPerformanceCounter(&synchronizeOutputsTime);
|
||||
printf("Finished execution.\n");
|
||||
|
||||
auto printDuration = [=](char const* message, LARGE_INTEGER qpcTime) mutable
|
||||
{
|
||||
double durationMs = static_cast<double>(qpcTime.QuadPart - startTime.QuadPart);
|
||||
durationMs /= static_cast<double>(cpuFrequency.QuadPart);
|
||||
durationMs *= 1000.0;
|
||||
printf("%s % 12.6f\n", message, durationMs);
|
||||
|
||||
startTime = qpcTime;
|
||||
};
|
||||
printDuration("d3dDeviceCreationTime ...", d3dDeviceCreationTime);
|
||||
printDuration("sessionCreationTime .....", sessionCreationTime);
|
||||
printDuration("tensorCreationTime ......", tensorCreationTime);
|
||||
printDuration("bindingTime .............", bindingTime);
|
||||
printDuration("runTime .................", runTime);
|
||||
printDuration("synchronizeOutputsTime ..", synchronizeOutputsTime);
|
||||
|
||||
// TODO: Download inputTensorValues from GPU outputTensor.
|
||||
|
||||
////////////////////////////////////////
|
||||
// Print the top results if the output tensors were on the CPU.
|
||||
if (!passTensorsAsD3DResources)
|
||||
{
|
||||
#if 1 // Print first 10 values.
|
||||
for (int i = 0; i <= std::min(outputTensorValues.size(), size_t(10)); ++i)
|
||||
{
|
||||
printf("output[%d] = %f\n", i, outputTensorValues[i]);
|
||||
}
|
||||
#else // Print top 10.
|
||||
std::vector<uint32_t> indices(outputTensorValues.size(), 0);
|
||||
std::iota(indices.begin(), indices.end(), 0);
|
||||
sort(
|
||||
indices.begin(),
|
||||
indices.end(),
|
||||
[&](uint32_t a, uint32_t b)
|
||||
{
|
||||
return (outputTensorValues[a] > outputTensorValues[b]);
|
||||
}
|
||||
);
|
||||
for (int i = 0; i <= std::min(indices.size(), size_t(10)); ++i)
|
||||
{
|
||||
printf("output[%d] = %f\n", indices[i], outputTensorValues[indices[i]]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (Ort::Exception const& exception)
|
||||
{
|
||||
printf("Error running model inference: %s\n", exception.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (std::exception const& exception)
|
||||
{
|
||||
printf("Error running model inference: %s\n", exception.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
winrt::com_ptr<ID3D12Resource> CreateD3D12ResourceForTensor(
|
||||
ID3D12Device* d3dDevice,
|
||||
size_t elementByteSize,
|
||||
std::span<const int64_t> tensorDimensions
|
||||
)
|
||||
{
|
||||
// Try to allocate the backing memory for the caller
|
||||
auto bufferSize = GetElementCount(tensorDimensions);
|
||||
size_t bufferByteSize = static_cast<size_t>(bufferSize * elementByteSize);
|
||||
|
||||
// DML needs the resources' sizes to be a multiple of 4 bytes
|
||||
(bufferByteSize += 3) &= ~3;
|
||||
|
||||
D3D12_HEAP_PROPERTIES heapProperties = {
|
||||
D3D12_HEAP_TYPE_DEFAULT,
|
||||
D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
|
||||
D3D12_MEMORY_POOL_UNKNOWN,
|
||||
0,
|
||||
0
|
||||
};
|
||||
D3D12_RESOURCE_DESC resourceDesc = {
|
||||
D3D12_RESOURCE_DIMENSION_BUFFER,
|
||||
0,
|
||||
static_cast<uint64_t>(bufferByteSize),
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
DXGI_FORMAT_UNKNOWN,
|
||||
{1, 0},
|
||||
D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
|
||||
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS
|
||||
};
|
||||
|
||||
winrt::com_ptr<ID3D12Resource> gpuResource;
|
||||
THROW_IF_FAILED(d3dDevice->CreateCommittedResource(
|
||||
&heapProperties,
|
||||
D3D12_HEAP_FLAG_NONE,
|
||||
&resourceDesc,
|
||||
D3D12_RESOURCE_STATE_COMMON,
|
||||
nullptr,
|
||||
__uuidof(ID3D12Resource),
|
||||
/*out*/ gpuResource.put_void()
|
||||
));
|
||||
|
||||
return gpuResource;
|
||||
}
|
||||
|
||||
Ort::Value CreateTensorValueFromExistingD3DResource(
|
||||
OrtDmlApi const& ortDmlApi,
|
||||
Ort::MemoryInfo const& memoryInformation,
|
||||
ID3D12Resource* d3dResource,
|
||||
std::span<const int64_t> tensorDimensions,
|
||||
ONNXTensorElementDataType elementDataType,
|
||||
/*out*/ void** dmlEpResourceWrapper // Must stay alive with Ort::Value.
|
||||
)
|
||||
{
|
||||
*dmlEpResourceWrapper = nullptr;
|
||||
|
||||
void* dmlAllocatorResource;
|
||||
THROW_IF_NOT_OK(ortDmlApi.CreateGPUAllocationFromD3DResource(d3dResource, &dmlAllocatorResource));
|
||||
auto deleter = [&](void*) {ortDmlApi.FreeGPUAllocation(dmlAllocatorResource); };
|
||||
deleting_unique_ptr<void> dmlAllocatorResourceCleanup(dmlAllocatorResource, deleter);
|
||||
|
||||
size_t tensorByteSize = static_cast<size_t>(d3dResource->GetDesc().Width);
|
||||
Ort::Value newValue(
|
||||
Ort::Value::CreateTensor(
|
||||
memoryInformation,
|
||||
dmlAllocatorResource,
|
||||
tensorByteSize,
|
||||
tensorDimensions.data(),
|
||||
tensorDimensions.size(),
|
||||
elementDataType
|
||||
)
|
||||
);
|
||||
|
||||
// Return values and the wrapped resource.
|
||||
// TODO: Is there some way to get Ort::Value to just own the D3DResource
|
||||
// directly so that it gets freed after execution or session destruction?
|
||||
*dmlEpResourceWrapper = dmlAllocatorResource;
|
||||
dmlAllocatorResourceCleanup.release();
|
||||
|
||||
return newValue;
|
||||
}
|
||||
|
||||
Ort::Value CreateTensorValueUsingD3DResource(
|
||||
ID3D12Device* d3d12Device,
|
||||
OrtDmlApi const& ortDmlApi,
|
||||
Ort::MemoryInfo const& memoryInformation,
|
||||
std::span<const int64_t> tensorDimensions,
|
||||
ONNXTensorElementDataType elementDataType,
|
||||
size_t elementByteSize,
|
||||
/*out*/ void** dmlEpResourceWrapper // Must stay alive with Ort::Value.
|
||||
)
|
||||
{
|
||||
// Create empty resource (values don't matter because we won't read them back anyway).
|
||||
winrt::com_ptr<ID3D12Resource> d3dResource = CreateD3D12ResourceForTensor(
|
||||
d3d12Device,
|
||||
sizeof(float),
|
||||
tensorDimensions
|
||||
);
|
||||
|
||||
return CreateTensorValueFromExistingD3DResource(
|
||||
ortDmlApi,
|
||||
memoryInformation,
|
||||
d3dResource.get(),
|
||||
tensorDimensions,
|
||||
ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT,
|
||||
/*out*/ dmlEpResourceWrapper
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
#include "DXResourceBinding.g.h"
|
||||
|
||||
namespace winrt::WinMLSamplesGalleryNative::implementation
|
||||
{
|
||||
struct DXResourceBinding : DXResourceBindingT<DXResourceBinding>
|
||||
{
|
||||
DXResourceBinding() = default;
|
||||
static int BindDXResourcesUsingORT();
|
||||
};
|
||||
}
|
||||
namespace winrt::WinMLSamplesGalleryNative::factory_implementation
|
||||
{
|
||||
struct DXResourceBinding : DXResourceBindingT<DXResourceBinding, implementation::DXResourceBinding>
|
||||
{
|
||||
};
|
||||
}
|
||||
|
|
@ -23,4 +23,10 @@ namespace WinMLSamplesGalleryNative
|
|||
static String[] GetAdapters();
|
||||
static Microsoft.AI.MachineLearning.LearningModelDevice CreateLearningModelDeviceFromAdapter(String description);
|
||||
}
|
||||
|
||||
[default_interface]
|
||||
runtimeclass DXResourceBinding
|
||||
{
|
||||
static Int32 BindDXResourcesUsingORT();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.ML.OnnxRuntime.DirectML.1.10.0\build\native\Microsoft.ML.OnnxRuntime.DirectML.props" Condition="Exists('..\packages\Microsoft.ML.OnnxRuntime.DirectML.1.10.0\build\native\Microsoft.ML.OnnxRuntime.DirectML.props')" />
|
||||
<Import Project="..\packages\Microsoft.AI.DirectML.1.8.0\build\Microsoft.AI.DirectML.props" Condition="Exists('..\packages\Microsoft.AI.DirectML.1.8.0\build\Microsoft.AI.DirectML.props')" />
|
||||
<Import Project="..\packages\Microsoft.AI.MachineLearning.1.9.1\build\native\Microsoft.AI.MachineLearning.props" Condition="Exists('..\packages\Microsoft.AI.MachineLearning.1.9.1\build\native\Microsoft.AI.MachineLearning.props')" />
|
||||
<Import Project="..\packages\Microsoft.AI.DirectML.1.5.1\build\Microsoft.AI.DirectML.props" Condition="Exists('..\packages\Microsoft.AI.DirectML.1.5.1\build\Microsoft.AI.DirectML.props')" />
|
||||
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.210930.14\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210930.14\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<CppWinRTOptimized>true</CppWinRTOptimized>
|
||||
|
@ -124,6 +125,7 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)../WinMLSamplesGallery/Models/;$(MSBuildThisFileDirectory)../../build/native/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
|
@ -143,6 +145,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="AdapterList.h" />
|
||||
<ClInclude Include="DXResourceBinding.h" />
|
||||
<ClInclude Include="EncryptedModels.h" />
|
||||
<ClInclude Include="OpenCVImage.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
|
@ -151,6 +154,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AdapterList.cpp" />
|
||||
<ClCompile Include="DXResourceBinding.cpp" />
|
||||
<ClCompile Include="EncryptedModels.cpp" />
|
||||
<ClCompile Include="OpenCVImage.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
|
@ -179,8 +183,9 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.210930.14\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210930.14\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
<Import Project="..\packages\Microsoft.AI.DirectML.1.5.1\build\Microsoft.AI.DirectML.targets" Condition="Exists('..\packages\Microsoft.AI.DirectML.1.5.1\build\Microsoft.AI.DirectML.targets')" />
|
||||
<Import Project="..\packages\Microsoft.AI.MachineLearning.1.9.1\build\native\Microsoft.AI.MachineLearning.targets" Condition="Exists('..\packages\Microsoft.AI.MachineLearning.1.9.1\build\native\Microsoft.AI.MachineLearning.targets')" />
|
||||
<Import Project="..\packages\Microsoft.AI.DirectML.1.8.0\build\Microsoft.AI.DirectML.targets" Condition="Exists('..\packages\Microsoft.AI.DirectML.1.8.0\build\Microsoft.AI.DirectML.targets')" />
|
||||
<Import Project="..\packages\Microsoft.ML.OnnxRuntime.DirectML.1.10.0\build\native\Microsoft.ML.OnnxRuntime.DirectML.targets" Condition="Exists('..\packages\Microsoft.ML.OnnxRuntime.DirectML.1.10.0\build\native\Microsoft.ML.OnnxRuntime.DirectML.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
|
@ -188,10 +193,12 @@
|
|||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210930.14\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.210930.14\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210930.14\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.210930.14\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.AI.DirectML.1.5.1\build\Microsoft.AI.DirectML.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.AI.DirectML.1.5.1\build\Microsoft.AI.DirectML.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.AI.DirectML.1.5.1\build\Microsoft.AI.DirectML.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.AI.DirectML.1.5.1\build\Microsoft.AI.DirectML.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.AI.MachineLearning.1.9.1\build\native\Microsoft.AI.MachineLearning.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.AI.MachineLearning.1.9.1\build\native\Microsoft.AI.MachineLearning.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.AI.MachineLearning.1.9.1\build\native\Microsoft.AI.MachineLearning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.AI.MachineLearning.1.9.1\build\native\Microsoft.AI.MachineLearning.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.AI.DirectML.1.8.0\build\Microsoft.AI.DirectML.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.AI.DirectML.1.8.0\build\Microsoft.AI.DirectML.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.AI.DirectML.1.8.0\build\Microsoft.AI.DirectML.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.AI.DirectML.1.8.0\build\Microsoft.AI.DirectML.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.OnnxRuntime.DirectML.1.10.0\build\native\Microsoft.ML.OnnxRuntime.DirectML.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.OnnxRuntime.DirectML.1.10.0\build\native\Microsoft.ML.OnnxRuntime.DirectML.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.ML.OnnxRuntime.DirectML.1.10.0\build\native\Microsoft.ML.OnnxRuntime.DirectML.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ML.OnnxRuntime.DirectML.1.10.0\build\native\Microsoft.ML.OnnxRuntime.DirectML.targets'))" />
|
||||
</Target>
|
||||
<Target Name="CopyNeutral" AfterTargets="Build">
|
||||
<Copy SourceFiles="$(OutDir)\WinMLSamplesGalleryNative.winmd" DestinationFolder="$(SolutionDir)$(MSBuildProjectName)\bin\neutral\WinMLSamplesGalleryNative.winmd" />
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
<ClCompile Include="AdapterList.cpp">
|
||||
<Filter>AdapterList</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DXResourceBinding.cpp">
|
||||
<Filter>DXResourceBinding</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
|
@ -30,6 +33,9 @@
|
|||
<ClInclude Include="AdapterList.h">
|
||||
<Filter>AdapterList</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DXResourceBinding.h">
|
||||
<Filter>DXResourceBinding</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Resource.rc" />
|
||||
|
@ -60,5 +66,8 @@
|
|||
<Filter Include="AdapterList">
|
||||
<UniqueIdentifier>{9df6a233-c2c6-4062-b738-31f7ba631acd}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="DXResourceBinding">
|
||||
<UniqueIdentifier>{393a0b12-622a-4d4c-b4a6-ed0bb1b2e285}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AI.DirectML" version="1.5.1" targetFramework="native" />
|
||||
<package id="Microsoft.AI.DirectML" version="1.8.0" targetFramework="native" />
|
||||
<package id="Microsoft.AI.MachineLearning" version="1.9.1" targetFramework="native" />
|
||||
<package id="Microsoft.ML.OnnxRuntime.DirectML" version="1.10.0" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.210930.14" targetFramework="native" />
|
||||
</packages>
|
Загрузка…
Ссылка в новой задаче